CallR / RetR (only 64-bit JWASM, MASM and POASM projects)


As the Retn instruction is not supported by the 64-bit MASM compiler (ml64), Héctor A. Medina has developed two Easy Code built-in pseudo-opcodes, CallR and RetR, 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 accepts 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.


WARNING: RetR modifies the Rax register.

REMARKS: CallR and RetR are only available for 64-bit JWASM, MASM and POASM projects. Despite the Retn instruction is supported by the 64-bit JWASM and POASM compilers, CallR and RetR are also available as a complement.