Hi Nasmers,
I use these macros to declare a function:
%imacro PROC 2
%1:
%push %1
enter %2, 0
%endmacro
; just for markup
%imacro ENDPROC 0
%pop
%endmacro
Now I want something that "preserves" my registers, i.e. push when entering into a function, and pop them at exit. Note that my function can have multiple exit points. My wish is:
PROC some.function, 0
PRESERVE ebx, ecx, esi
; blabla
EXIT
ENDPROC
I tried the following:
; save all registers into $_regs variable, and push them all
%imacro PRESERVE 1-*
%define $_regs
%rep %0
%define $_regs %+ %1
push %1
%rotate 1
%endrep
%endmacro
But I don't know if this code is correct because I don't know how to verify. The EXIT macro should pop all "preserved" registers in inverse order. How can I achieve this?