Rev 474 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
314 | diamond | 1 | xmalloc: |
2 | ; in: eax=size |
||
3 | ; out: eax=pointer or NULL |
||
4 | call mf_alloc |
||
5 | .common: |
||
6 | test eax, eax |
||
7 | jnz @f |
||
8 | call SayNoMem |
||
9 | xor eax, eax |
||
10 | @@: |
||
11 | ret |
||
12 | |||
13 | xrealloc: |
||
14 | ; in: eax=pointer, ebx=new size |
||
15 | ; out: eax=pointer or NULL |
||
16 | call mf_realloc |
||
17 | jmp xmalloc.common |
||
18 | |||
19 | get_error_msg: |
||
20 | ; in: eax=error code |
||
21 | ; out: eax=pointer to message (in static buffer) |
||
22 | push esi edi |
||
23 | mov edi, error_msg |
||
24 | cmp eax, 11 |
||
25 | ja .no1 |
||
26 | mov esi, [errors1+eax*4] |
||
27 | jmp .copy |
||
28 | .no1: |
||
29 | cmp eax, 30 |
||
30 | jb .no2 |
||
31 | cmp eax, 32 |
||
32 | ja .no2 |
||
33 | mov esi, [errors2+(eax-30)*4] |
||
34 | .copy: |
||
35 | lodsb |
||
36 | stosb |
||
37 | test al, al |
||
38 | jnz .copy |
||
39 | .ret: |
||
40 | mov eax, error_msg |
||
41 | pop edi esi |
||
42 | ret |
||
43 | .no2: |
||
44 | mov esi, aUnknownError |
||
45 | push eax |
||
46 | @@: |
||
47 | lodsb |
||
48 | stosb |
||
49 | test al, al |
||
50 | jnz @b |
||
51 | pop eax |
||
52 | push edx ecx |
||
53 | test eax, eax |
||
54 | jns @f |
||
55 | mov byte [edi], '-' |
||
56 | inc edi |
||
57 | neg eax |
||
58 | @@: |
||
59 | xor edx, edx |
||
60 | mov ecx, 10 |
||
61 | div ecx |
||
62 | add edx, '0' |
||
63 | mov byte [edi], dl |
||
64 | inc edi |
||
65 | test eax, eax |
||
66 | jnz @b |
||
67 | pop ecx edx |
||
68 | stosb |
||
69 | jmp .ret |