CallR / RetR / CallRA / RetRA (only 64-bit ASMC, JWASM, MASM, POASM and UASM projects)
As the Retn
instruction is not
supported by the 64-bit MASM compiler (ml64),
Héctor A. Medina has developed four Easy
Code
built-in pseudo-opcodes, CallR
/
RetR
/
CallRA
and
RetRA,
which work like Call
and Retn
respectively. These pseudo-opcodes are used in the following way:
wndMainProcedure Proc
hWnd:QWORD,
uMsg:QWORD,
wParam:QWORD,
lParam:QWORD
Mov
hWnd, Rcx
Mov
uMsg, Rdx
Mov
wParam, R8
Mov
lParam, R9
CallR
Label
;RetR
returns here
Ret
Label:
RetR
wndMainProcedure EndP
Besides, CallR
and CallRA
accept an OPTIONAL second argument as the return
address:
wndMainProcedure Proc
hWnd:QWORD,
uMsg:QWORD,
wParam:QWORD,
lParam:QWORD
Mov
hWnd, Rcx
Mov
uMsg, Rdx
Mov
wParam, R8
Mov
lParam, R9
CallR
Label, RetAddr
;Code
line
;Code
line
RetAddr:
;RetR
returns here
Ret
Label:
RetR
wndMainProcedure EndP
The 64-bit ECClock MASM example, in the
EasyCode\Examples\Masm\x64 folder, uses
CallR
and RetR.
IMPORTANT: In the examples
above, you can use CallR
/ RetR
or CallRA
/
RetRA
indistinctly, but
take into account that CallRA
/
RetRA
keep the stack aligned,
while CallR
/ RetR
DO NOT.
WARNING: RetR and RetRA modify the Rax register.
REMARKS: CallR,
RetR,
CallRA
and RetRA
are only available for 64-bit ASMC, JWASM, MASM, POASM and UASM
projects. Despite the Retn
instruction is supported by the 64-bit ASMC, JWASM,
POASM
and UASM compilers, CallR,
RetR,
CallRA
and
RetRA
are also available as a
complement.