Hey, could someone help me convert this inline ASM code to MASM ? I am not that good at it so it would help a lot. I have been trying and searching on Google but nothing can help me do it. Thanks you. :bgrin:
__asm
{
mov rcx, [VarOne]
mov rdx, [VarTwo]
mov rax, [VarThree]
call[VarFour]
mov[VarFive], rax
}
VarOne = UINT64
VarTwo = UINT64
VarThree = DWORD64
VarFour = const BYTE*
VarFive = DWORD64
mov rcx,VarOne
mov rdx,VarTwo
mov rax,VarThree
call VarFour
mov VarFive, rax
(https://wasm.in/styles/smiles_s/smile3.gif)
Thanks ! But I don't understand how to do the parameters. It's like this :
.code
PROC func ???
mov rcx,VarOne
mov rdx,VarTwo
mov rax,VarThree
call VarFour
mov VarFive, rax
ENDP
END
I have got this:
.code
myfunc PROC varone:UINT64, vartwo:UINT64, varthree:DWORD64, varfour:const BYTE*, varfive:DWORD64
mov rcx, varone
mov rdx, vartwo
mov rax, varthree
call varfour
mov varfive, rax
myfunc ENDP
END
I get syntax error : byte on line 3 and unmatched block nesting : myfunc on line 9
myfunc PROC varone:QWORD, vartwo:QWORD, varthree:QWORD, varfour:PTR, varfive:QWORD
@giraffe,
Things do not work like that. You must read an introductory text first.
Try this:
https://software.intel.com/en-us/articles/introduction-to-x64-assembly
No RET in source.
.code
myfunc PROC varone:QWORD, vartwo:QWORD, varthree:QWORD
local varfive:QWORD
mov varone,rcx
mov vartwo,rdx
mov varthree,r8
call varfour
mov rax,varfive
leave
retn
myfunc endp
MASM makes an RBP stack frame whenever there are either LOCAL variables or function arguments. When it does that it will automatically insert LEAVE at the end of the function before a RET.
This means that:
myFunc2 proc varOne:qword, varTwo:qword
ret
myFunc2 endp
myFunc1 proc varOne:qword, varTwo:qword, varThree:qword, varFour:ptr, varFive:qword
mov varOne, rcx
mov varTwo, rdx
mov varThree, r8
mov varFour, r9
sub rsp, 20h
call r9
mov rax, varFive
ret
myFunc1 endp
will be coded as:
00000000 myFunc2 proc varOne:qword, varTwo:qword
00000000 55 * push rbp
00000001 48/ 8B EC * mov rbp, rsp
ret
00000004 C9 * leave
00000005 C3 * ret 00000h
00000006 myFunc2 endp
00000006 myFunc1 proc varOne:qword, varTwo:qword, varThree:qword, varFour:ptr, varFive:qword
00000006 55 * push rbp
00000007 48/ 8B EC * mov rbp, rsp
0000000A 48/ 89 4D 10 mov varOne, rcx
0000000E 48/ 89 55 18 mov varTwo, rdx
00000012 4C/ 89 45 20 mov varThree, r8
00000016 4C/ 89 4D 28 mov varFour, r9
0000001A 48/ 83 EC 20 sub rsp, 20h
0000001E 41/ FF D1 call r9
00000021 48/ 8B 45 30 mov rax, varFive
ret
00000025 C9 * leave
00000026 C3 * ret 00000h
00000027 myFunc1 endp
Instructions with an asterisc are produced by the MASM engine by its own initiative.