-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathyosefk-MASM-x64.asm
53 lines (42 loc) · 1.29 KB
/
yosefk-MASM-x64.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
;.MODEL FLAT, STDCALL
option prologue:none ; turn off default prologue creation
option epilogue:none ; turn off default epilogue creation
_text SEGMENT
option prologue:none ; turn off default prologue creation
option epilogue:none ; turn off default epilogue creation
; in vs2010, right click on Project / Build Customization, enable MASM
; add an .asm file to the project
; you should see a MASM category under Project / Properties
; you should see "compile" under right click on the .asm file.
getRSP PROC
mov rax, rsp
add rax, 8
ret
getRSP ENDP
getRBP PROC
mov rax, rbp
ret
getRBP ENDP
; http://msdn.microsoft.com/en-us/library/ms235286.aspx
; The x64 Application Binary Interface (ABI) is a 4 register fast-call calling convention,
; with stack-backing for those registers. There is a strict one-to-one correspondence between
; arguments in a function, and the registers for those arguments. Any argument that doesn’t fit
; in 8 bytes, or is not 1, 2, 4, or 8 bytes, must be passed by reference.
; The arguments are passed in registers RCX, RDX, R8, and R9
setRSP PROC
mov rsp, RCX
add rsp, 2
ret
setRSP ENDP
setRBP PROC
mov rbp, RCX
ret
setRBP ENDP
setRSPRBP PROC
mov rsp, RCX
mov rbp, RDX
ret
setRSPRBP ENDP
; ending!
_text ENDS
END