| 1 |
|
| 2 |
; the symbol 'frame' keeps track of how much stack space is |
| 3 |
; being used locally in order to be able to track where the |
| 4 |
; routine parameters arew relative to the current value of |
| 5 |
; the stack pointer in rsp |
| 6 |
|
| 7 |
; save registers on the stack and adjust 'frame' accordingly |
| 8 |
|
| 9 |
%macro f_push 1-* |
| 10 |
%rep %0 |
| 11 |
push %1 |
| 12 |
%rotate 1 |
| 13 |
%assign frame frame + 8 |
| 14 |
%endrep |
| 15 |
%endmacro |
| 16 |
|
| 17 |
; restore a register from the stack and adjust 'frame' accordingly |
| 18 |
|
| 19 |
%macro f_pop 1 |
| 20 |
%rep %0 |
| 21 |
%rotate -1 |
| 22 |
pop %1 |
| 23 |
%endrep |
| 24 |
%assign frame frame - 8 |
| 25 |
%endmacro |
| 26 |
|
| 27 |
; restore registers from the stack at the end of a routine where |
| 28 |
; 'frame' does not need to be adjusted because it won't be used |
| 29 |
; again |
| 30 |
|
| 31 |
%macro f_pop 2-* |
| 32 |
%rep %0 |
| 33 |
%rotate -1 |
| 34 |
pop %1 |
| 35 |
%endrep |
| 36 |
%endmacro |
| 37 |
|
| 38 |
; obtain some local space on the stack |
| 39 |
|
| 40 |
%macro f_add 1 |
| 41 |
sub rsp,%1 |
| 42 |
%assign frame frame + %1 |
| 43 |
%endmacro |
| 44 |
|
| 45 |
; return local space on the stack at the end of a routine without the |
| 46 |
; need to adjust 'frame' |
| 47 |
|
| 48 |
%macro f_sub 1 |
| 49 |
add rsp,%1 |
| 50 |
%endmacro |
| 51 |
|
| 52 |
%assign frame 0 |
| 53 |
|
| 54 |
%define x86_regs rbx,rsi,rdi,rbp |