flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > How to use macro with multi line args? For Stack vars define |
| Author |
|
|
Geist-Z 18 Sep 2026, 05:45
Here is my Liunx x86_64 syscall macro
Free to use ;;rdi,rsi,rdx,r10,r8,r9 sc_var_pos = 0 macro sc_var number, [args] { common mov r0, number forward if ~ args eq if sc_var_pos = 0 mov r1, args push r1 else if sc_var_pos = 1 mov r2, args push r2 else if sc_var_pos = 2 mov r3, args push r3 else if sc_var_pos = 3 mov r4, args push r4 else if sc_var_pos = 4 mov r5, args push r5 else if sc_var_pos = 5 mov r6, args push r6 end if end if sc_var_pos = sc_var_pos + 1 common sc if sc_var_pos > 5 pop r6 end if if sc_var_pos > 4 pop r5 end if if sc_var_pos > 3 pop r4 end if if sc_var_pos > 2 pop r3 end if if sc_var_pos > 1 pop r2 end if if sc_var_pos > 0 pop r1 end if sc_var_pos = 0 } |
|||
|
|
revolution 18 Sep 2026, 05:59
The general case is this:
Code: macro x [args] { forward args } x \ nop, \ ud2 x inc ax, <add bx,cx>, \ cpuid, hlt Code: 00000000 90 nop 00000001 0F0B ud2 00000003 40 inc ax 00000004 01CB add bx,cx 00000006 0FA2 cpuid 00000008 F4 hlt |
|||
|
|
Geist-Z 18 Sep 2026, 06:15
Huge Thanks! ypa!!!
|
|||
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.