Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ;------------------------- |
2 | ; |
||
3 | ; ASM JJ's 2 C macros ;-) |
||
4 | ; |
||
5 | ; version history: |
||
6 | ; |
||
7 | ; *0.01(02/08/05): if_e, if_ne, if_a, if_b |
||
8 | ; *0.02(02/09/05): push_abc, pop_abc |
||
9 | ; ch_sign, abs |
||
10 | ; |
||
11 | ; E.X.: if_e dword [x],100,.end_if |
||
12 | ; if x = 100 do the instrucsions to .end_if: |
||
13 | ; == |
||
14 | macro if_e arg1,arg2,label |
||
15 | { |
||
16 | if arg1 eq 0 | arg2 eq 0 | arg1 eqtype 12 | arg2 eqtype 12 |
||
17 | cmp arg1,arg2 |
||
18 | jne label |
||
19 | else |
||
20 | push edx |
||
21 | mov edx,arg1 |
||
22 | cmp edx,arg2 |
||
23 | pop edx |
||
24 | jne label |
||
25 | end if |
||
26 | } |
||
27 | |||
28 | ; != |
||
29 | macro if_ne arg1,arg2,label |
||
30 | { |
||
31 | if arg1 eq 0 | arg2 eq 0 | arg1 eqtype 12 | arg2 eqtype 12 |
||
32 | cmp arg1,arg2 |
||
33 | je label |
||
34 | else |
||
35 | push edx |
||
36 | mov edx,arg1 |
||
37 | cmp edx,arg2 |
||
38 | pop edx |
||
39 | je label |
||
40 | end if |
||
41 | } |
||
42 | |||
43 | ; > |
||
44 | macro if_a arg1,arg2,label |
||
45 | { |
||
46 | if arg1 eq 0 | arg2 eq 0 | arg1 eqtype 12 | arg2 eqtype 12 |
||
47 | cmp arg1,arg2 |
||
48 | jbe label |
||
49 | else |
||
50 | push edx |
||
51 | mov edx,arg1 |
||
52 | cmp edx,arg2 |
||
53 | pop edx |
||
54 | jbe label |
||
55 | end if |
||
56 | } |
||
57 | |||
58 | ; < |
||
59 | macro if_b arg1,arg2,label |
||
60 | { |
||
61 | if arg1 eq 0 | arg2 eq 0 | arg1 eqtype 12 | arg2 eqtype 12 |
||
62 | cmp arg1,arg2 |
||
63 | jae label |
||
64 | else |
||
65 | push edx |
||
66 | mov edx,arg1 |
||
67 | cmp edx,arg2 |
||
68 | pop edx |
||
69 | jae label |
||
70 | end if |
||
71 | } |
||
72 | |||
73 | macro push_abc |
||
74 | { |
||
75 | push eax |
||
76 | push ebx |
||
77 | push ecx |
||
78 | push edx |
||
79 | push edi |
||
80 | push esi |
||
81 | } |
||
82 | |||
83 | macro pop_abc |
||
84 | { |
||
85 | pop esi |
||
86 | pop edi |
||
87 | pop edx |
||
88 | pop ecx |
||
89 | pop ebx |
||
90 | pop eax |
||
91 | } |
||
92 | |||
93 | UNDER_0 equ 0x7FFFFFFF |
||
94 | ; changes sign e.x. ch_sign -1 = 1 |
||
95 | macro ch_sign arg |
||
96 | { |
||
97 | push edx |
||
98 | mov edx,0 |
||
99 | sub edx,arg |
||
100 | pop edx |
||
101 | } |
||
102 | |||
103 | ; absolut e.x. abs -24 = 24 |
||
104 | macro abs arg |
||
105 | { |
||
106 | local .end_if |
||
107 | if_a arg,UNDER_0,.end_if |
||
108 | ch_sign arg |
||
109 | .end_if: |
||
110 | } |
||
111 | ;--------------------------------------- |
||
112 | |||
113 |