Skip to content

Commit

Permalink
Add inline assembler tests for i386, arm, arm64, riscv32 and riscv64 (#…
Browse files Browse the repository at this point in the history
…24564)

This fixes one error in #24544 .
I tested this on Raspberry Pi Pico (arm) and Raspberry Pi 3(arm64).
It is not tested on i386, riscv32 and riscv64 CPU.
  • Loading branch information
demotomohiro authored Dec 24, 2024
1 parent e2a3063 commit fc80671
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions tests/compiler/tasm.nim
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
discard """
disabled: "arm64"
"""

proc testAsm() =
let src = 41
var dst = 0

asm """
mov %1, %0\n\t
add $1, %0
: "=r" (`dst`)
: "r" (`src`)"""
when defined(i386) or defined(amd64):
asm """
mov %1, %0\n\t
add $1, %0
: "=r" (`dst`)
: "r" (`src`)"""
elif defined(arm) or defined(arm64):
asm """
mov %0, %1\n\t
add %0, %0, #1
: "=r" (`dst`)
: "r" (`src`)"""
elif defined(riscv32) or defined(riscv64):
asm """
addi %0, %1, 0\n\t
addi %0, %0, 1
: "=r" (`dst`)
: "r" (`src)"""

doAssert dst == 42

Expand Down

0 comments on commit fc80671

Please sign in to comment.