Rev 134 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 134 | Rev 485 | ||
---|---|---|---|
1 | macro debug_print str |
1 | macro debug_print str |
2 | { |
2 | { |
3 | local ..string, ..label |
3 | local ..string, ..label |
4 | 4 | ||
5 | jmp ..label |
5 | jmp ..label |
6 | ..string db str,0 |
6 | ..string db str,0 |
7 | ..label: |
7 | ..label: |
8 | 8 | ||
9 | pushf |
9 | pushf |
10 | pushad |
10 | pushad |
11 | mov edx,..string |
11 | mov edx,..string |
12 | call debug_outstr |
12 | call debug_outstr |
13 | popad |
13 | popad |
14 | popf |
14 | popf |
15 | } |
15 | } |
16 | 16 | ||
17 | dps fix debug_print |
17 | dps fix debug_print |
18 | 18 | ||
19 | macro debug_print_dec arg |
19 | macro debug_print_dec arg |
20 | { |
20 | { |
21 | pushf |
21 | pushf |
22 | pushad |
22 | pushad |
23 | if ~arg eq eax |
23 | if ~arg eq eax |
24 | mov eax,arg |
24 | mov eax,arg |
25 | end if |
25 | end if |
26 | call debug_outdec |
26 | call debug_outdec |
27 | popad |
27 | popad |
28 | popf |
28 | popf |
29 | } |
29 | } |
30 | 30 | ||
31 | dpd fix debug_print_dec |
31 | dpd fix debug_print_dec |
32 | 32 | ||
33 | ;--------------------------------- |
33 | ;--------------------------------- |
34 | debug_outdec: ;(eax - num, edi-str) |
34 | debug_outdec: ;(eax - num, edi-str) |
35 | push 10 ;2 |
35 | push 10 ;2 |
36 | pop ecx ;1 |
36 | pop ecx ;1 |
37 | push -'0' ;2 |
37 | push -'0' ;2 |
38 | .l0: |
38 | .l0: |
39 | xor edx,edx ;2 |
39 | xor edx,edx ;2 |
40 | div ecx ;2 |
40 | div ecx ;2 |
41 | push edx ;1 |
41 | push edx ;1 |
42 | test eax,eax ;2 |
42 | test eax,eax ;2 |
43 | jnz .l0 ;2 |
43 | jnz .l0 ;2 |
44 | .l1: |
44 | .l1: |
45 | pop eax ;1 |
45 | pop eax ;1 |
46 | add al,'0' ;2 |
46 | add al,'0' ;2 |
47 | call debug_outchar ; stosb |
47 | call debug_outchar ; stosb |
48 | jnz .l1 ;2 |
48 | jnz .l1 ;2 |
49 | ret ;1 |
49 | ret ;1 |
50 | ;--------------------------------- |
50 | ;--------------------------------- |
51 | 51 | ||
52 | debug_outchar: ; al - char |
52 | debug_outchar: ; al - char |
53 | pushf |
53 | pushf |
54 | pushad |
54 | pushad |
55 | mov cl,al |
55 | mov cl,al |
56 | mov eax,63 |
56 | mov eax,63 |
57 | mov ebx,1 |
57 | mov ebx,1 |
58 | int 0x40 |
58 | mcall |
59 | popad |
59 | popad |
60 | popf |
60 | popf |
61 | ret |
61 | ret |
62 | 62 | ||
63 | debug_outstr: |
63 | debug_outstr: |
64 | mov eax,63 |
64 | mov eax,63 |
65 | mov ebx,1 |
65 | mov ebx,1 |
66 | @@: |
66 | @@: |
67 | mov cl,[edx] |
67 | mov cl,[edx] |
68 | test cl,cl |
68 | test cl,cl |
69 | jz @f |
69 | jz @f |
70 | int 40h |
70 | int 40h |
71 | inc edx |
71 | inc edx |
72 | jmp @b |
72 | jmp @b |
73 | @@: |
73 | @@: |
74 | ret |
74 | ret |
75 | 75 | ||
76 | _debug_crlf db 13, 10, 0 |
76 | _debug_crlf db 13, 10, 0 |
77 | 77 | ||
78 | macro newline |
78 | macro newline |
79 | { |
79 | { |
80 | pushf |
80 | pushf |
81 | pushad |
81 | pushad |
82 | mov edx, _debug_crlf |
82 | mov edx, _debug_crlf |
83 | call debug_outstr |
83 | call debug_outstr |
84 | popad |
84 | popad |
85 | popf |
85 | popf |
86 | } |
86 | } |
87 | 87 | ||
88 | macro print message |
88 | macro print message |
89 | { |
89 | { |
90 | dps message |
90 | dps message |
91 | newline |
91 | newline |
92 | } |
92 | } |
93 | 93 | ||
94 | macro pregs |
94 | macro pregs |
95 | { |
95 | { |
96 | dps "EAX: " |
96 | dps "EAX: " |
97 | dpd eax |
97 | dpd eax |
98 | dps " EBX: " |
98 | dps " EBX: " |
99 | dpd ebx |
99 | dpd ebx |
100 | newline |
100 | newline |
101 | dps "ECX: " |
101 | dps "ECX: " |
102 | dpd ecx |
102 | dpd ecx |
103 | dps " EDX: " |
103 | dps " EDX: " |
104 | dpd edx |
104 | dpd edx |
105 | newline |
105 | newline |
106 | } |
106 | } |
107 | 107 | ||
108 | macro debug_print_hex arg |
108 | macro debug_print_hex arg |
109 | { |
109 | { |
110 | pushf |
110 | pushf |
111 | pushad |
111 | pushad |
112 | if ~arg eq eax |
112 | if ~arg eq eax |
113 | mov eax, arg |
113 | mov eax, arg |
114 | end if |
114 | end if |
115 | call debug_outhex |
115 | call debug_outhex |
116 | popad |
116 | popad |
117 | popf |
117 | popf |
118 | } |
118 | } |
119 | dph fix debug_print_hex |
119 | dph fix debug_print_hex |
120 | 120 | ||
121 | debug_outhex: |
121 | debug_outhex: |
122 | ; eax - number |
122 | ; eax - number |
123 | mov edx, 8 |
123 | mov edx, 8 |
124 | .new_char: |
124 | .new_char: |
125 | rol eax, 4 |
125 | rol eax, 4 |
126 | movzx ecx, al |
126 | movzx ecx, al |
127 | and cl, 0x0f |
127 | and cl, 0x0f |
128 | mov cl, [__hexdigits + ecx] |
128 | mov cl, [__hexdigits + ecx] |
129 | pushad |
129 | pushad |
130 | mcall 63, 1 |
130 | mcall 63, 1 |
131 | popad |
131 | popad |
132 | dec edx |
132 | dec edx |
133 | jnz .new_char |
133 | jnz .new_char |
134 | ret |
134 | ret |
135 | 135 | ||
136 | __hexdigits: |
136 | __hexdigits: |
137 | db '0123456789ABCDEF' |
137 | db '0123456789ABCDEF' |