tasm.nim 581 B

1234567891011121314151617181920212223242526272829
  1. proc testAsm() =
  2. let src = 41
  3. var dst = 0
  4. when defined(i386) or defined(amd64):
  5. asm """
  6. mov %1, %0\n\t
  7. add $1, %0
  8. : "=r" (`dst`)
  9. : "r" (`src`)"""
  10. elif defined(arm) or defined(arm64):
  11. asm """
  12. mov %0, %1\n\t
  13. add %0, %0, #1
  14. : "=r" (`dst`)
  15. : "r" (`src`)"""
  16. elif defined(riscv32) or defined(riscv64):
  17. asm """
  18. addi %0, %1, 0\n\t
  19. addi %0, %0, 1
  20. : "=r" (`dst`)
  21. : "r" (`src)"""
  22. doAssert dst == 42
  23. when defined(gcc) or defined(clang) and not defined(cpp):
  24. {.passc: "-std=c99".}
  25. testAsm()