Subversion Repositories Kolibri OS

Rev

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

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