Rev 6614 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5195 | clevermous | 1 | ; Magic for proc32.inc: prologue/epilogue for esp-based addressing |
2 | ; fpo stands from Frame Pointer Omission |
||
3 | macro fpo_prologue procname,flag,parmbytes,localbytes,reglist |
||
4 | { |
||
5 | local loc,regcount |
||
6 | loc = (localbytes+3) and (not 3) |
||
7 | regcount = 0 |
||
8 | irps reg, reglist |
||
9 | \{ |
||
10 | regcount = regcount+1 |
||
11 | push reg |
||
12 | \} |
||
6614 | clevermous | 13 | if loc |
14 | sub esp, loc |
||
15 | end if |
||
16 | parmbase@proc equ esp+4+loc+regcount*4 |
||
17 | localbase@proc equ esp |
||
18 | fpo_localsize = loc |
||
6767 | clevermous | 19 | fpo_delta = 0 |
5195 | clevermous | 20 | } |
21 | macro fpo_epilogue procname,flag,parmbytes,localbytes,reglist |
||
22 | { |
||
6767 | clevermous | 23 | if fpo_localsize |
24 | add esp, fpo_localsize |
||
25 | end if |
||
5195 | clevermous | 26 | irps reg, reglist \{ reverse pop reg \} |
27 | if flag and 10000b |
||
28 | retn |
||
29 | else |
||
30 | retn parmbytes |
||
31 | end if |
||
32 | } |
||
6767 | clevermous | 33 | macro deflocal@proc name,def,[val] |
34 | { |
||
35 | common |
||
36 | deflocal@proc name#_unique_suffix,def,val |
||
37 | all@vars equ all@vars,name |
||
38 | name equ name#_unique_suffix+fpo_delta |
||
39 | } |
||
40 | macro defargs@proc [arg] |
||
41 | { |
||
42 | common |
||
43 | rawargs equ |
||
44 | srcargs equ arg |
||
45 | forward |
||
46 | rawargs equ rawargs,arg#_unique_suffix |
||
47 | common |
||
48 | match =,tmp,rawargs \{ |
||
49 | defargs@proc tmp |
||
50 | uniqargs equ args@proc |
||
51 | restore args@proc |
||
52 | args@proc equ uniqargs,srcargs |
||
53 | \} |
||
54 | forward |
||
55 | arg equ arg#_unique_suffix+fpo_delta |
||
56 | } |
||
57 | macro stdcall proc,[arg] ; directly call STDCALL procedure |
||
58 | { common |
||
59 | fpo_delta_base = fpo_delta |
||
60 | if ~ arg eq |
||
61 | reverse |
||
62 | pushd arg |
||
63 | fpo_delta = fpo_delta + 4 |
||
64 | common |
||
65 | end if |
||
66 | call proc |
||
67 | fpo_delta = fpo_delta_base |
||
68 | } |
||
69 | macro ccall proc,[arg] ; directly call CDECL procedure |
||
70 | { common |
||
71 | fpo_delta_base = fpo_delta |
||
72 | size@ccall = 0 |
||
73 | if ~ arg eq |
||
74 | reverse |
||
75 | pushd arg |
||
76 | fpo_delta = fpo_delta + 4 |
||
77 | size@ccall = size@ccall+4 |
||
78 | common |
||
79 | end if |
||
80 | call proc |
||
81 | if size@ccall |
||
82 | add esp, size@ccall |
||
83 | end if |
||
84 | fpo_delta = fpo_delta_base |
||
85 | } |
||
86 | fpo_delta = 0 |