Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7113 GerdtR 1
dps fix debug_print
2
dpd fix debug_print_dec
3
dpds fix debug_print_dec_sign
4
dnl fix debug_newline
5
dpsP fix debug_printP
6
 
7
;if ~(newline eq)
8
  newline fix debug_newline
9
;end if
10
 
11
 
12
macro debug_print str
13
{
14
   local ..string, ..label
15
 
16
   jmp ..label
17
   ..string db str,0
18
  ..label:
19
 
20
   pushf
21
   pushad
22
   mov	edx,..string
23
   call debug_outstr
24
   popad
25
   popf
26
}
27
 
28
 
29
 
30
macro debug_print_dec arg
31
{
32
   pushf
33
   pushad
34
   if ~arg eq eax
35
     mov  eax,arg
36
   end if
37
   call debug_outdec
38
   popad
39
   popf
40
}
41
 
42
macro debug_print_dec_sign arg
43
{
44
local .sign,.rtrn
45
   pushf
46
   pushad
47
   if ~arg eq eax
48
     mov  eax,arg
49
   end if
50
   test eax,80000000h
51
   jnz	.sign
52
   call debug_outdec
53
   popad
54
   popf
55
   jmp .rtrn
56
.sign:
57
   not	eax
58
   inc	eax
59
   push eax
60
   mov	cl,'-'
61
   mov	eax,63
62
   mov	ebx,1
63
   int	0x40
64
   pop	eax
65
   call debug_outdec
66
   popad
67
   popf
68
.rtrn:
69
}
70
 
71
;---------------------------------
72
debug_outdec:		;(eax - num, edi-str)
73
	push 10 	;2
74
	pop ecx 	;1
75
	push -'0'	;2
76
    .l0:
77
	xor edx,edx	;2
78
	div ecx 	;2
79
	push edx	;1
80
	test eax,eax	;2
81
	jnz .l0 	;2
82
    .l1:
83
	pop eax 	;1
84
	add al,'0'	;2
85
	call debug_outchar ; stosb
86
	jnz .l1 	;2
87
	ret		;1
88
;---------------------------------
89
 
90
debug_outchar:		; al - char
91
   pushf
92
   pushad
93
   mov	cl,al
94
   mov	eax,63
95
   mov	ebx,1
96
   int	0x40
97
   popad
98
   popf
99
ret
100
 
101
debug_outstr:
102
   mov	eax,63
103
   mov	ebx,1
104
 @@:
105
   mov	cl,[edx]
106
   test cl,cl
107
   jz	@f
108
   int	40h
109
   inc	edx
110
   jmp	@b
111
 @@:
112
   ret
113
 
114
_debug_crlf db 13, 10, 0
115
 
116
macro debug_newline
117
{
118
  pushf
119
  pushad
120
  mov edx, _debug_crlf
121
  call debug_outstr
122
  popad
123
  popf
124
}
125
 
126
macro debug_printP Pstr
127
{
128
  pushf
129
  pushad
130
  mov	edx,Pstr
131
  call debug_outstr
132
  popad
133
  popf
134
 
135
}
136
 
137
 
138
macro print message
139
{
140
  dps message
141
  dnl
142
}
143
 
144
macro pregs
145
{
146
  dps "EAX: "
147
  dpd eax
148
  dps "   EBX: "
149
  dpd ebx
150
  newline
151
  dps "ECX: "
152
  dpd ecx
153
  dps "   EDX: "
154
  dpd edx
155
  newline
156
}
157
 
158
macro debug_print_hex arg
159
{
160
    pushf
161
    pushad
162
    if ~arg eq eax
163
      mov eax, arg
164
    end if
165
    call debug_outhex
166
    popad
167
    popf
168
}
169
dph fix debug_print_hex
170
 
171
debug_outhex:
172
    ;  eax - number
173
    mov   edx, 8
174
  .new_char:
175
    rol   eax, 4
176
    movzx ecx, al
177
    and   cl,  0x0f
178
    mov   cl,  [__hexdigits + ecx]
179
    pushad
180
    mcall 63, 1
181
    popad
182
    dec   edx
183
    jnz   .new_char
184
ret
185
 
186
__hexdigits:
187
  db '0123456789ABCDEF'
188
 
189
 
190
 
191
;-------------------------------------------------------------------------------