First question by new masm32.com user; also a first-time user of UASM.
I compiled a one instruction fastcall routine 32-bit that simply loads its first argument to eax, and I get what I'd expect, a "mov eax,ecx" opcode. Note the source opcode was "mov eax,arg1" -- changed in the list file to mov eax,ecx (as if arg1 was a text equated to "ecx").
UASM v2.49, Jun 21 2019, Masm-compatible assembler.
.586
.model flat, fastcall
.code
.listall
00000000 xyz proc arg1:ptr
00000000 8BC1 mov eax, ecx
00000002 ret
00000002 C3 * retn
00000003 xyz endp
end
00000003 * _TEXT ends
But a similar thing in 64-bit generates an ebp stack frame, and then attempts to load the 1st argument from its homing area (which arg1 has yet to be stored to). Here the source file opcode was "mov rax,arg1" and the arg1 was NOT changed to rcx (as was done in the 32-bit case).
UASM v2.49, Jun 21 2019, Masm-compatible assembler.
.x64
.model flat, fastcall
.code
.listall
00000000 xyz proc arg1:ptr
00000000 55 * push rbp
00000001 488BEC * mov rbp, rsp
00000004 488B4510 mov rax, arg1
00000008 ret
00000008 C9 * leave
00000009 C3 * retn
0000000A xyz endp
end
0000000A * _TEXT ends
I would have hoped for just a "mov rax,rcx" opcode in the 64-bit case -- I don't see how the 64-bit code can even work, as arg1 has never been stored to the stack. How can I get the 64-bit case to generate only a "mov rax,rcx" opcode, as was done in the 32-bit case?
Thanks!