Rev 6058 | Rev 6684 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6058 | Rev 6152 | ||
---|---|---|---|
1 | #ifndef INCLUDE_DEBUG_H |
1 | #ifndef INCLUDE_DEBUG_H |
2 | #define INCLUDE_DEBUG_H |
2 | #define INCLUDE_DEBUG_H |
3 | #print "[include |
3 | #print "[include |
4 | 4 | ||
5 | #ifndef INCLUDE_STRING_H |
5 | #ifndef INCLUDE_STRING_H |
6 | #include "../lib/strings.h" |
6 | #include "../lib/strings.h" |
7 | #endif |
7 | #endif |
8 | 8 | ||
9 | inline fastcall void debugch( ECX) |
9 | inline fastcall void debugch( ECX) |
10 | { |
10 | { |
11 | $push eax |
11 | $push eax |
12 | $push ebx |
12 | $push ebx |
13 | $mov eax,63 |
13 | $mov eax,63 |
14 | $mov ebx,1 |
14 | $mov ebx,1 |
15 | $int 0x40 |
15 | $int 0x40 |
16 | $pop ebx |
16 | $pop ebx |
17 | $pop eax |
17 | $pop eax |
18 | } |
18 | } |
19 | 19 | ||
20 | inline fastcall void debug( EDX) |
20 | inline fastcall void debug( EDX) |
21 | { |
21 | { |
22 | $push eax |
22 | $push eax |
23 | $push ebx |
23 | $push ebx |
24 | $push ecx |
24 | $push ecx |
25 | $mov eax, 63 |
25 | $mov eax, 63 |
26 | $mov ebx, 1 |
26 | $mov ebx, 1 |
27 | NEXT_CHAR: |
27 | NEXT_CHAR: |
28 | $mov ecx, DSDWORD[edx] |
28 | $mov ecx, DSDWORD[edx] |
29 | $or cl, cl |
29 | $or cl, cl |
30 | $jz DONE |
30 | $jz DONE |
31 | $int 0x40 |
31 | $int 0x40 |
32 | $inc edx |
32 | $inc edx |
33 | $jmp NEXT_CHAR |
33 | $jmp NEXT_CHAR |
34 | DONE: |
34 | DONE: |
35 | $pop ecx |
35 | $pop ecx |
36 | $pop ebx |
36 | $pop ebx |
37 | $pop eax |
37 | $pop eax |
38 | } |
38 | } |
39 | 39 | ||
40 | inline fastcall void debugln( EDX) |
40 | inline fastcall void debugln( EDX) |
41 | { |
41 | { |
42 | debug( EDX); |
42 | debug( EDX); |
- | 43 | debugch(10); |
|
43 | debugch('\n'); |
44 | debugch(13); |
44 | } |
45 | } |
45 | 46 | ||
46 | inline void debugi(dword d_int) |
47 | inline void debugi(dword d_int) |
47 | { |
48 | { |
48 | char tmpch[12]; |
49 | char tmpch[12]; |
49 | itoa_(#tmpch, d_int); |
50 | itoa_(#tmpch, d_int); |
50 | debugln(#tmpch); |
51 | debugln(#tmpch); |
51 | } |
52 | } |
52 | 53 | ||
53 | :void assert(dword _type, _actual, _expected) |
54 | :void assert(dword _type, _actual, _expected) |
54 | { |
55 | { |
55 | char r[4096]; |
56 | char r[4096]; |
56 | if (_type=='s') { |
57 | if (_type=='s') { |
57 | if (streq(_actual, _expected)) return; |
58 | if (streq(_actual, _expected)) return; |
58 | sprintf(#r, "==========nok{\nactual: %s\nexpected: %s", _actual, _expected); |
59 | sprintf(#r, "==========nok{\nactual: %s\nexpected: %s", _actual, _expected); |
59 | debugln(#r); |
60 | debugln(#r); |
60 | } |
61 | } |
61 | if (_type=='i') { |
62 | if (_type=='i') { |
62 | if (_actual == _expected)) return; |
63 | if (_actual == _expected)) return; |
63 | sprintf(#r, "==========nok{\nactual: %i\nexpected: %i", _actual, _expected); |
64 | sprintf(#r, "==========nok{\nactual: %i\nexpected: %i", _actual, _expected); |
64 | debugln(#r); |
65 | debugln(#r); |
65 | } |
66 | } |
66 | } |
67 | } |
67 | 68 | ||
68 | #endif |
69 | #endif |