Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inline assembler tests for i386, arm, arm64, riscv32 and riscv64 #24564

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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