Hi, I'm trying to write a pair of macros for %defining and %undefing procedure parameters aliases. So far I have:
%define sysv_nth_arg(n) sysv_arg_ %+ n
%define sysv_arg_0 rdi
%define sysv_arg_1 rsi
%define sysv_arg_2 rdx
%define sysv_arg_3 RCX
%define sysv_arg_4 R8
%define sysv_arg_5 R9
; proc procedure_name [arg..]
;
; aliases arguments names inside procedure body,
; every fun should have a matching endproc
%macro proc 1-7
%ifdef proc_name
%fatal You forgot endproc
%endif
%define proc_name %1
proc_name:
%assign arg_i 0
; argument aliases
%rep (%0 - 1)
%rotate 1
%xdefine %1 sysv_nth_arg(arg_i)
%assign arg_i arg_i+1
%endrep
%endmacro
%macro endproc 0
; TODO
%endmacro
SECTION .text ; code section
global sha1_init:function
proc main, argc, argv
I want reg names here: argc, argv
endproc
But not here: argc, argv
But I don't know how to go about the undefining part.