Added DGEN to ISO and create file associatons.
[kolibrios.git] / programs / debug.inc
blob41cef9773f5323366b5797055842f0ac29b1f2d7
1 macro debug_print str\r
2 {\r
3    local ..string, ..label\r
4 \r
5    jmp ..label\r
6    ..string db str,0\r
7   ..label:\r
8 \r
9    pushf\r
10    pushad\r
11    mov  edx,..string\r
12    call debug_outstr\r
13    popad\r
14    popf\r
15 }\r
17 dps fix debug_print\r
19 macro debug_print_dec arg\r
20 {\r
21    pushf\r
22    pushad\r
23    if ~arg eq eax\r
24      mov  eax,arg\r
25    end if\r
26    call debug_outdec\r
27    popad\r
28    popf\r
29 }\r
31 dpd fix debug_print_dec\r
33 ;---------------------------------\r
34 debug_outdec:           ;(eax - num, edi-str)\r
35         push 10         ;2\r
36         pop ecx         ;1\r
37         push -'0'       ;2\r
38     .l0:\r
39         xor edx,edx     ;2\r
40         div ecx         ;2\r
41         push edx        ;1\r
42         test eax,eax    ;2\r
43         jnz .l0         ;2\r
44     .l1:\r
45         pop eax         ;1\r
46         add al,'0'      ;2\r
47         call debug_outchar ; stosb\r
48         jnz .l1         ;2\r
49         ret             ;1\r
50 ;---------------------------------\r
52 debug_outchar:          ; al - char\r
53    pushf\r
54    pushad\r
55    mov  cl,al\r
56    mov  eax,63\r
57    mov  ebx,1\r
58    int  0x40\r
59    popad\r
60    popf\r
61 ret\r
63 debug_outstr:\r
64    mov  eax,63\r
65    mov  ebx,1\r
66  @@:\r
67    mov  cl,[edx]\r
68    test cl,cl\r
69    jz   @f\r
70    int  40h\r
71    inc  edx\r
72    jmp  @b\r
73  @@:\r
74    ret\r
77 macro newline\r
78 {\r
79   dps <13,10>\r
80 }\r
82 macro print message\r
83 {\r
84   dps message\r
85   newline\r
86 }\r
88 macro pregs\r
89 {\r
90   dps "EAX: "\r
91   dpd eax\r
92   dps "   EBX: "\r
93   dpd ebx\r
94   newline\r
95   dps "ECX: "\r
96   dpd ecx\r
97   dps "   EDX: "\r
98   dpd edx\r
99   newline\r
102 macro debug_print_hex arg\r
104     pushf\r
105     pushad\r
106     if ~arg eq eax\r
107       mov eax, arg\r
108     end if\r
109     call debug_outhex\r
110     popad\r
111     popf\r
113 dph fix debug_print_hex\r
115 debug_outhex:\r
116     ;  eax - number\r
117     mov   edx, 8\r
118   .new_char:\r
119     rol   eax, 4\r
120     movzx ecx, al\r
121     and   cl,  0x0f\r
122     mov   cl,  [__hexdigits + ecx]\r
123     pushad\r
124     mov eax, 63\r
125         mov ebx, 1\r
126         int 0x40\r
127     popad\r
128     dec   edx\r
129     jnz   .new_char\r
130 ret\r
132 __hexdigits:\r
133   db '0123456789ABCDEF'