Subversion Repositories Kolibri OS

Rev

Rev 992 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 992 Rev 1443
1
; flat assembler
1
; flat assembler
2
; Copyright (c) 1999-2007, Tomasz Grysztar
2
; Copyright (c) 1999-2007, Tomasz Grysztar
3
; All rights reserved.
3
; All rights reserved.
4
 
4
 
5
struc FILEIO
5
struc FILEIO
6
{   .cmd            dd ?
6
{   .cmd            dd ?
7
    .offset         dd ?
7
    .offset         dd ?
8
                    dd ?
8
                    dd ?
9
    .count          dd ?
9
    .count          dd ?
10
    .buff           dd ?
10
    .buff           dd ?
11
                    db ?
11
                    db ?
12
    .name           dd ?
12
    .name           dd ?
13
};
13
};
14
 
14
 
15
struc FILEINFO
15
struc FILEINFO
16
{   .attr           dd ?
16
{   .attr           dd ?
17
    .flags          dd ?
17
    .flags          dd ?
18
    .cr_time        dd ?
18
    .cr_time        dd ?
19
    .cr_date        dd ?
19
    .cr_date        dd ?
20
    .acc_time       dd ?
20
    .acc_time       dd ?
21
    .acc_date       dd ?
21
    .acc_date       dd ?
22
    .mod_time       dd ?
22
    .mod_time       dd ?
23
    .mod_date       dd ?
23
    .mod_date       dd ?
24
    .size           dd ?
24
    .size           dd ?
25
}
25
}
26
 
26
 
27
 
27
 
28
 
28
 
29
;file_info_open:  dd 0,0,0xffffff,0x20000,0xf0000
29
;file_info_open:  dd 0,0,0xffffff,0x20000,0xf0000
30
fullpath_open:  ;  db '/RD/1/EXAMPLE.ASM'
30
fullpath_open:  ;  db '/RD/1/EXAMPLE.ASM'
31
		    times MAX_PATH db 0
31
		    times MAX_PATH db 0
32
 
32
 
33
 
33
 
34
;file_info_write: dd 1,0,0,0,0xf0000
34
;file_info_write: dd 1,0,0,0,0xf0000
35
fullpath_write:; db '/RD/1/EXAMPLE'
35
fullpath_write:; db '/RD/1/EXAMPLE'
36
		    times MAX_PATH db 0
36
		    times MAX_PATH db 0
37
 
37
 
38
file_info_start:
38
file_info_start:
39
    dd 7
39
    dd 7
40
    dd 0
40
    dd 0
41
    dd 0
41
    dd 0
42
    dd 0
42
    dd 0
43
    dd 0
43
    dd 0
44
fullpath_start:  ; db '/RD/1/EXAMPLE'
44
fullpath_start:  ; db '/RD/1/EXAMPLE'
45
		    times MAX_PATH db 0
45
		    times MAX_PATH db 0
46
 
46
 
47
file_info_debug:
47
file_info_debug:
48
	dd	7
48
	dd	7
49
	dd	0
49
	dd	0
50
	dd	fullpath_start
50
	dd	fullpath_start
51
	dd	0, 0
51
	dd	0, 0
52
	db	'/SYS/DEVELOP/MTDBG',0
52
	db	'/SYS/DEVELOP/MTDBG',0
53
 
53
 
54
_ramdisk	 db '/RD/1/'
54
_ramdisk	 db '/RD/1/'
55
filepos 	 dd 0x0
55
filepos 	 dd 0x0
56
 
56
 
57
 
57
 
58
init_memory:
58
init_memory:
59
 
59
 
60
        mov ecx, 16*1024*1024
60
;        mov ecx, 16*1024*1024
61
 
61
;
-
 
62
; allocate_memory:
-
 
63
	mcall	18, 16
-
 
64
	cmp	eax, 0x38000000 shr 9
-
 
65
	jbe	@f
-
 
66
	mov	eax, 0x38000000 shr 9
-
 
67
@@:
-
 
68
	shl	eax, 9
62
 allocate_memory:
69
	xchg	eax, ecx
63
	mov	[memory_setting],ecx
70
	mov	[memory_setting],ecx
64
	mcall	68, 12
71
	mcall	68, 12
65
	or	eax,eax
72
	or	eax,eax
66
	jz	out_of_memory
73
	jz	out_of_memory
-
 
74
	mov	[memblock], eax
67
	mov	[additional_memory],eax
75
	mov	[additional_memory],eax
68
	add	eax,[memory_setting]
76
	add	eax,[memory_setting]
69
	mov	[memory_end],eax
77
	mov	[memory_end],eax
70
	mov	eax,[memory_setting]
78
	mov	eax,[memory_setting]
71
	shr	eax,2
79
	shr	eax,2
72
	add	eax,[additional_memory]
80
	add	eax,[additional_memory]
73
	mov	[additional_memory_end],eax
81
	mov	[additional_memory_end],eax
74
	mov	[memory_start],eax
82
	mov	[memory_start],eax
75
	ret
83
	ret
76
 
84
 
77
exit_program:
85
exit_program:
78
	cmp	[_mode],NORMAL_MODE
86
	cmp	[_mode],NORMAL_MODE
79
	jne	@f
87
	jne	@f
80
	mcall	68, 13, [memblock]
88
	mcall	68, 13, [memblock]
81
	jmp	still
89
	jmp	still
82
@@:
90
@@:
83
	or	eax,-1
91
	or	eax,-1
84
	mcall
92
	mcall
85
 
93
 
86
make_timestamp:
94
make_timestamp:
87
	push	ebx
95
	push	ebx
88
	mcall	26,9
96
	mcall	26,9
89
	imul	eax,10
97
	imul	eax,10
90
	pop	ebx
98
	pop	ebx
91
	ret
99
	ret
92
 
100
 
93
get_environment_variable:
101
get_environment_variable:
94
	mov	ecx,[memory_end]
102
	mov	ecx,[memory_end]
95
	sub	ecx,edi
103
	sub	ecx,edi
96
	cmp	ecx,7
104
	cmp	ecx,7
97
	jb	out_of_memory
105
	jb	out_of_memory
98
	cmp	dword[esi],'INCL'
106
	cmp	dword[esi],'INCL'
99
	jne	.finish
107
	jne	.finish
100
	mov	esi,_ramdisk
108
	mov	esi,_ramdisk
101
	mov	ecx,6
109
	mov	ecx,6
102
	cld
110
	cld
103
	rep	movsb
111
	rep	movsb
104
  .finish:
112
  .finish:
105
;       stc
113
;       stc
106
	ret
114
	ret
107
 
115
 
108
alloc_handle:
116
alloc_handle:
109
        call    make_fullpaths
117
        call    make_fullpaths
110
        mov     ebx, fileinfos+4
118
        mov     ebx, fileinfos+4
111
@@:
119
@@:
112
        cmp     dword [ebx], -1
120
        cmp     dword [ebx], -1
113
        jz      .found
121
        jz      .found
114
        add     ebx, 4+20+MAX_PATH
122
        add     ebx, 4+20+MAX_PATH
115
        cmp     ebx, fileinfos_end
123
        cmp     ebx, fileinfos_end
116
        jb      @b
124
        jb      @b
117
        stc
125
        stc
118
        ret
126
        ret
119
.found:
127
.found:
120
        and     dword [ebx+4], 0
128
        and     dword [ebx+4], 0
121
        and     dword [ebx+8], 0
129
        and     dword [ebx+8], 0
122
        push    esi edi ecx
130
        push    esi edi ecx
123
        mov     esi, fullpath_open
131
        mov     esi, fullpath_open
124
        lea     edi, [ebx+20]
132
        lea     edi, [ebx+20]
125
        mov     ecx, MAX_PATH
133
        mov     ecx, MAX_PATH
126
        rep     movsb
134
        rep     movsb
127
        pop     ecx edi esi
135
        pop     ecx edi esi
128
        ret	; CF=0
136
        ret	; CF=0
129
 
137
 
130
create:
138
create:
131
        call    alloc_handle
139
        call    alloc_handle
132
        jc      .ret
140
        jc      .ret
133
        and     dword [ebx-4], 0
141
        and     dword [ebx-4], 0
134
        mov     dword [ebx], 2
142
        mov     dword [ebx], 2
135
.ret:
143
.ret:
136
        ret
144
        ret
137
 
145
 
138
 
146
 
139
open:
147
open:
140
;        call    make_fullpaths
148
;        call    make_fullpaths
141
 
149
 
142
;;       mov     eax,fullpath_open
150
;;       mov     eax,fullpath_open
143
;;       DEBUGF  '"%s"\n',eax
151
;;       DEBUGF  '"%s"\n',eax
144
 
152
 
145
;        mov     dword[file_info_open+8],-1
153
;        mov     dword[file_info_open+8],-1
146
;        mcall   58,file_info_open
154
;        mcall   58,file_info_open
147
;        or      eax,eax                 ; found
155
;        or      eax,eax                 ; found
148
;        jz      @f
156
;        jz      @f
149
;        cmp     eax,6
157
;        cmp     eax,6
150
;        jne     file_error
158
;        jne     file_error
151
;@@: mov [filesize],ebx
159
;@@: mov [filesize],ebx
152
;        clc
160
;        clc
153
;        ret
161
;        ret
154
;file_error:
162
;file_error:
155
;        stc
163
;        stc
156
;        ret
164
;        ret
157
 
165
 
158
        call    alloc_handle
166
        call    alloc_handle
159
        jc      .ret
167
        jc      .ret
160
        mov     dword [ebx], 5
168
        mov     dword [ebx], 5
161
        and     dword [ebx+12], 0
169
        and     dword [ebx+12], 0
162
        mov     dword [ebx+16], fileinfo
170
        mov     dword [ebx+16], fileinfo
163
        mov     eax, 70
171
        mov     eax, 70
164
        push    ebx
172
        push    ebx
165
        mcall
173
        mcall
166
        pop     ebx
174
        pop     ebx
167
        test    eax, eax
175
        test    eax, eax
168
        jnz     .fail
176
        jnz     .fail
169
        mov     eax, [fileinfo.size]
177
        mov     eax, [fileinfo.size]
170
        mov     [ebx-4], eax
178
        mov     [ebx-4], eax
171
        and     dword [ebx], 0
179
        and     dword [ebx], 0
172
.ret:
180
.ret:
173
        ret
181
        ret
174
.fail:
182
.fail:
175
	or	dword [ebx], -1	; close handle
183
	or	dword [ebx], -1	; close handle
176
        stc
184
        stc
177
        ret
185
        ret
178
 
186
 
179
read:
187
read:
180
;          pusha
188
;          pusha
181
;          mov     edi,edx
189
;          mov     edi,edx
182
;          mov     esi,[filepos]
190
;          mov     esi,[filepos]
183
;          add     esi,0x20000
191
;          add     esi,0x20000
184
;          cld
192
;          cld
185
;          rep     movsb
193
;          rep     movsb
186
;          popa
194
;          popa
187
;;         ret
195
;;         ret
188
 
196
 
189
        mov     [ebx+12], ecx
197
        mov     [ebx+12], ecx
190
        mov     [ebx+16], edx
198
        mov     [ebx+16], edx
191
        push    ebx
199
        push    ebx
192
        mov     eax, 70
200
        mov     eax, 70
193
        mcall
201
        mcall
194
        xchg    eax, [esp]
202
        xchg    eax, [esp]
195
        add     [eax+4], ebx
203
        add     [eax+4], ebx
196
        adc     [eax+8], dword 0
204
        adc     [eax+8], dword 0
197
        mov     ebx, eax
205
        mov     ebx, eax
198
        pop     eax
206
        pop     eax
199
        test    eax, eax
207
        test    eax, eax
200
        jz      .ok
208
        jz      .ok
201
        cmp     eax, 6
209
        cmp     eax, 6
202
        jz      .ok
210
        jz      .ok
203
        stc
211
        stc
204
.ok:
212
.ok:
205
        ret
213
        ret
206
 
214
 
207
close:
215
close:
208
        or      dword [ebx], -1
216
        or      dword [ebx], -1
209
        ret
217
        ret
210
 
218
 
211
 
219
 
212
; ebx file handle
220
; ebx file handle
213
; ecx count of bytes to write
221
; ecx count of bytes to write
214
; edx pointer to buffer
222
; edx pointer to buffer
215
write:
223
write:
216
;        pusha
224
;        pusha
217
;        mov     [file_info_write+8],ecx
225
;        mov     [file_info_write+8],ecx
218
;        mov     [file_info_write+12],edx
226
;        mov     [file_info_write+12],edx
219
;        mov     [filesize],edx
227
;        mov     [filesize],edx
220
;        mov     eax,58
228
;        mov     eax,58
221
;        mov     ebx,file_info_write
229
;        mov     ebx,file_info_write
222
;        mcall
230
;        mcall
223
;        popa
231
;        popa
224
;        ret
232
;        ret
225
 
233
 
226
        mov     [ebx+12], ecx
234
        mov     [ebx+12], ecx
227
        mov     [ebx+16], edx
235
        mov     [ebx+16], edx
228
        push    ebx
236
        push    ebx
229
        mov     eax, 70
237
        mov     eax, 70
230
        mcall
238
        mcall
231
        xchg    eax, [esp]
239
        xchg    eax, [esp]
232
        add     [eax+4], ebx
240
        add     [eax+4], ebx
233
        adc     [eax+8], dword 0
241
        adc     [eax+8], dword 0
234
        mov     ebx, eax
242
        mov     ebx, eax
235
        pop     eax
243
        pop     eax
236
        mov     byte [ebx], 3
244
        mov     byte [ebx], 3
237
        cmp     eax, 1
245
        cmp     eax, 1
238
        cmc
246
        cmc
239
        ret
247
        ret
240
 
248
 
241
make_fullpaths:
249
make_fullpaths:
242
	pusha
250
	pusha
243
	push	edx
251
	push	edx
244
 
252
 
245
	mov	esi,path	      ; open
253
	mov	esi,path	      ; open
246
;       DEBUGF  "   '%s'",esi
254
;       DEBUGF  "   '%s'",esi
247
	mov	edi,fullpath_open
255
	mov	edi,fullpath_open
248
	cld
256
	cld
249
      newc1:
257
      newc1:
250
	movsb
258
	movsb
251
	cmp	byte[esi],0;' '
259
	cmp	byte[esi],0;' '
252
	jne	newc1
260
	jne	newc1
253
	mov	esi,[esp]
261
	mov	esi,[esp]
254
 
262
 
255
	cmp	byte[esi],'/'
263
	cmp	byte[esi],'/'
256
	jne	@f
264
	jne	@f
257
	mov	edi,fullpath_open
265
	mov	edi,fullpath_open
258
 
266
 
259
    @@:
267
    @@:
260
	lodsb
268
	lodsb
261
	stosb
269
	stosb
262
	cmp	al,0
270
	cmp	al,0
263
	jne	@b
271
	jne	@b
264
;       mov     ecx,12
272
;       mov     ecx,12
265
;       cld
273
;       cld
266
;       rep     movsb
274
;       rep     movsb
267
;       mov     byte[edi],0
275
;       mov     byte[edi],0
268
 
276
 
269
	mov	esi,path	      ; write
277
	mov	esi,path	      ; write
270
	mov	edi,fullpath_write
278
	mov	edi,fullpath_write
271
	cld
279
	cld
272
      newc2:
280
      newc2:
273
	movsb
281
	movsb
274
	cmp	byte[esi],0;' '
282
	cmp	byte[esi],0;' '
275
	jne	newc2
283
	jne	newc2
276
	mov	esi,[esp]
284
	mov	esi,[esp]
277
 
285
 
278
	cmp	byte[esi],'/'
286
	cmp	byte[esi],'/'
279
	jne	@f
287
	jne	@f
280
	mov	edi,fullpath_write
288
	mov	edi,fullpath_write
281
 
289
 
282
    @@:
290
    @@:
283
	lodsb
291
	lodsb
284
	stosb
292
	stosb
285
	cmp	al,0
293
	cmp	al,0
286
	jne	@b
294
	jne	@b
287
;        mov     ecx,12
295
;        mov     ecx,12
288
;        cld
296
;        cld
289
;        rep     movsb
297
;        rep     movsb
290
;        mov     byte[edi],0
298
;        mov     byte[edi],0
291
 
299
 
292
	mov	esi,path	      ; start
300
	mov	esi,path	      ; start
293
	mov	edi,fullpath_start
301
	mov	edi,fullpath_start
294
	cld
302
	cld
295
      newc3:
303
      newc3:
296
	movsb
304
	movsb
297
	cmp  byte[esi],0;' '
305
	cmp  byte[esi],0;' '
298
	jne  newc3
306
	jne  newc3
299
;        mov  esi,[esp]
307
;        mov  esi,[esp]
300
	pop	esi
308
	pop	esi
301
 
309
 
302
	cmp	byte[esi],'/'
310
	cmp	byte[esi],'/'
303
	jne	@f
311
	jne	@f
304
	mov	edi,fullpath_start
312
	mov	edi,fullpath_start
305
 
313
 
306
    @@:
314
    @@:
307
	lodsb
315
	lodsb
308
	stosb
316
	stosb
309
	cmp	al,0
317
	cmp	al,0
310
	jne	@b
318
	jne	@b
311
;        mov  ecx,12
319
;        mov  ecx,12
312
;        cld
320
;        cld
313
;        rep  movsb
321
;        rep  movsb
314
;        mov  byte[edi],0
322
;        mov  byte[edi],0
315
 
323
 
316
;        add  esp,4
324
;        add  esp,4
317
	popa
325
	popa
318
	ret
326
	ret
319
 
327
 
320
 
328
 
321
 
329
 
322
lseek:
330
lseek:
323
	cmp	al,0
331
	cmp	al,0
324
	jnz	@f
332
	jnz	@f
325
	and	dword [ebx+4], 0
333
	and	dword [ebx+4], 0
326
	and     dword [ebx+8], 0
334
	and     dword [ebx+8], 0
327
    @@: cmp	al,2
335
    @@: cmp	al,2
328
	jnz	@f
336
	jnz	@f
329
	mov	eax, [ebx-4]
337
	mov	eax, [ebx-4]
330
	mov	[ebx+4], eax
338
	mov	[ebx+4], eax
331
	and     dword [ebx+8], 0
339
	and     dword [ebx+8], 0
332
    @@: add	dword [ebx+4], edx
340
    @@: add	dword [ebx+4], edx
333
        adc     dword [ebx+8], 0
341
        adc     dword [ebx+8], 0
334
	ret
342
	ret
335
 
343
 
336
display_character:
344
display_character:
337
	pusha
345
	pusha
338
	cmp	[_mode],NORMAL_MODE
346
	cmp	[_mode],NORMAL_MODE
339
	jne	@f
347
	jne	@f
340
	cmp	dl,13
348
	cmp	dl,13
341
	jz	dc2
349
	jz	dc2
342
	cmp	dl,0xa
350
	cmp	dl,0xa
343
	jnz	dc1
351
	jnz	dc1
344
	and	[textxy],0x0000FFFF
352
	and	[textxy],0x0000FFFF
345
	add	[textxy], 7 shl 16 +53 and 0xFFFF0000 + 10
353
	add	[textxy], 7 shl 16 +53 and 0xFFFF0000 + 10
346
dc2:
354
dc2:
347
  popa
355
  popa
348
	ret
356
	ret
349
dc1:
357
dc1:
350
  mov eax,[textxy]
358
  mov eax,[textxy]
351
	cmp	ax,word[bottom_right]
359
	cmp	ax,word[bottom_right]
352
	ja	dc2
360
	ja	dc2
353
	shr	eax,16
361
	shr	eax,16
354
	cmp	ax,word[bottom_right+2]
362
	cmp	ax,word[bottom_right+2]
355
	ja	dc2
363
	ja	dc2
356
	mov	[dc],dl
364
	mov	[dc],dl
357
	mcall	4,[textxy],[sc.work_text],dc,1
365
	mcall	4,[textxy],[sc.work_text],dc,1
358
	add	[textxy],0x00060000
366
	add	[textxy],0x00060000
359
	popa
367
	popa
360
	ret
368
	ret
361
@@:
369
@@:
362
  mov	eax,63
370
  mov	eax,63
363
	mov	ebx,1
371
	mov	ebx,1
364
	mov	cl,dl
372
	mov	cl,dl
365
	mcall
373
	mcall
366
	popa
374
	popa
367
	ret
375
	ret
368
 
376
 
369
 
377
 
370
display_string:
378
display_string:
371
	pusha
379
	pusha
372
@@:
380
@@:
373
  cmp	byte[esi],0
381
  cmp	byte[esi],0
374
	je	@f
382
	je	@f
375
	mov	dl,[esi]
383
	mov	dl,[esi]
376
	call	display_character
384
	call	display_character
377
	add	esi,1
385
	add	esi,1
378
	jmp	@b
386
	jmp	@b
379
@@:
387
@@:
380
  popa
388
  popa
381
	ret
389
	ret
382
 
390
 
383
display_number:
391
display_number:
384
	push	ebx
392
	push	ebx
385
	mov	ecx,1000000000
393
	mov	ecx,1000000000
386
	xor	edx,edx
394
	xor	edx,edx
387
	xor	bl,bl
395
	xor	bl,bl
388
display_loop:
396
display_loop:
389
	div	ecx
397
	div	ecx
390
	push	edx
398
	push	edx
391
	cmp	ecx,1
399
	cmp	ecx,1
392
	je	display_digit
400
	je	display_digit
393
	or	bl,bl
401
	or	bl,bl
394
	jnz	display_digit
402
	jnz	display_digit
395
	or	al,al
403
	or	al,al
396
	jz	digit_ok
404
	jz	digit_ok
397
	not	bl
405
	not	bl
398
display_digit:
406
display_digit:
399
	mov	dl,al
407
	mov	dl,al
400
	add	dl,30h
408
	add	dl,30h
401
	push	ebx ecx
409
	push	ebx ecx
402
	call	display_character
410
	call	display_character
403
	pop	ecx ebx
411
	pop	ecx ebx
404
digit_ok:
412
digit_ok:
405
	mov	eax,ecx
413
	mov	eax,ecx
406
	xor	edx,edx
414
	xor	edx,edx
407
	mov	ecx,10
415
	mov	ecx,10
408
	div	ecx
416
	div	ecx
409
	mov	ecx,eax
417
	mov	ecx,eax
410
	pop	eax
418
	pop	eax
411
	or	ecx,ecx
419
	or	ecx,ecx
412
	jnz	display_loop
420
	jnz	display_loop
413
	pop	ebx
421
	pop	ebx
414
	ret
422
	ret
415
 
423
 
416
display_user_messages:
424
display_user_messages:
417
;    push   [skinh]
425
;    push   [skinh]
418
;    pop    [textxy]
426
;    pop    [textxy]
419
;    add    [textxy], 7 shl 16 +53
427
;    add    [textxy], 7 shl 16 +53
420
	mov	[displayed_count],0
428
	mov	[displayed_count],0
421
	call	show_display_buffer
429
	call	show_display_buffer
422
	cmp	[displayed_count],1
430
	cmp	[displayed_count],1
423
	jb	line_break_ok
431
	jb	line_break_ok
424
	je	make_line_break
432
	je	make_line_break
425
	mov	ax,word[last_displayed]
433
	mov	ax,word[last_displayed]
426
	cmp	ax,0A0Dh
434
	cmp	ax,0A0Dh
427
	je	line_break_ok
435
	je	line_break_ok
428
	cmp	ax,0D0Ah
436
	cmp	ax,0D0Ah
429
	je	line_break_ok
437
	je	line_break_ok
430
make_line_break:
438
make_line_break:
431
	mov	esi,lf
439
	mov	esi,lf
432
	call	display_string
440
	call	display_string
433
line_break_ok:
441
line_break_ok:
434
	ret
442
	ret
435
 
443
 
436
display_block:
444
display_block:
437
	pusha
445
	pusha
438
@@: mov dl,[esi]
446
@@: mov dl,[esi]
439
	call	display_character
447
	call	display_character
440
	inc	esi
448
	inc	esi
441
	loop	@b
449
	loop	@b
442
	popa
450
	popa
443
	ret
451
	ret
444
 
452
 
445
fatal_error:
453
fatal_error:
446
	mov	esi,error_prefix
454
	mov	esi,error_prefix
447
	call	display_string
455
	call	display_string
448
	pop	esi
456
	pop	esi
449
	call	display_string
457
	call	display_string
450
	mov	esi,error_suffix
458
	mov	esi,error_suffix
451
	call	display_string
459
	call	display_string
452
	mov	esi,lf
460
	mov	esi,lf
453
	call	display_string
461
	call	display_string
454
	mov	al,0FFh
462
	mov	al,0FFh
455
	jmp	exit_program
463
	jmp	exit_program
456
 
464
 
457
assembler_error:
465
assembler_error:
458
	call	display_user_messages
466
	call	display_user_messages
459
	push	dword 0
467
	push	dword 0
460
	mov	ebx,[current_line]
468
	mov	ebx,[current_line]
461
get_error_lines:
469
get_error_lines:
462
	push	ebx
470
	push	ebx
463
	test	byte [ebx+7],80h
471
	test	byte [ebx+7],80h
464
	jz	display_error_line
472
	jz	display_error_line
465
	mov	edx,ebx
473
	mov	edx,ebx
466
find_definition_origin:
474
find_definition_origin:
467
	mov	edx,[edx+12]
475
	mov	edx,[edx+12]
468
	test	byte [edx+7],80h
476
	test	byte [edx+7],80h
469
	jnz	find_definition_origin
477
	jnz	find_definition_origin
470
	push	edx
478
	push	edx
471
	mov	ebx,[ebx+8]
479
	mov	ebx,[ebx+8]
472
	jmp	get_error_lines
480
	jmp	get_error_lines
473
display_error_line:
481
display_error_line:
474
	mov	esi,[ebx]
482
	mov	esi,[ebx]
475
	call	display_string
483
	call	display_string
476
	mov	esi,line_number_start
484
	mov	esi,line_number_start
477
	call	display_string
485
	call	display_string
478
	mov	eax,[ebx+4]
486
	mov	eax,[ebx+4]
479
	and	eax,7FFFFFFFh
487
	and	eax,7FFFFFFFh
480
	call	display_number
488
	call	display_number
481
	mov	dl,']'
489
	mov	dl,']'
482
	call	display_character
490
	call	display_character
483
	pop	esi
491
	pop	esi
484
	cmp	ebx,esi
492
	cmp	ebx,esi
485
	je	line_number_ok
493
	je	line_number_ok
486
	mov	dl,20h
494
	mov	dl,20h
487
	call	display_character
495
	call	display_character
488
	push	esi
496
	push	esi
489
	mov	esi,[esi]
497
	mov	esi,[esi]
490
	movzx	ecx,byte [esi]
498
	movzx	ecx,byte [esi]
491
	inc	esi
499
	inc	esi
492
	call	display_block
500
	call	display_block
493
	mov	esi,line_number_start
501
	mov	esi,line_number_start
494
	call	display_string
502
	call	display_string
495
	pop	esi
503
	pop	esi
496
	mov	eax,[esi+4]
504
	mov	eax,[esi+4]
497
	and	eax,7FFFFFFFh
505
	and	eax,7FFFFFFFh
498
	call	display_number
506
	call	display_number
499
	mov	dl,']'
507
	mov	dl,']'
500
	call	display_character
508
	call	display_character
501
line_number_ok:
509
line_number_ok:
502
	mov	esi,line_data_start
510
	mov	esi,line_data_start
503
	call	display_string
511
	call	display_string
504
	mov	esi,ebx
512
	mov	esi,ebx
505
	mov	edx,[esi]
513
	mov	edx,[esi]
506
	call	open
514
	call	open
507
	mov	al,2
515
	mov	al,2
508
	xor	edx,edx
516
	xor	edx,edx
509
	call	lseek
517
	call	lseek
510
	mov	edx,[esi+8]
518
	mov	edx,[esi+8]
511
	sub	eax,edx
519
	sub	eax,edx
512
	push	eax
520
	push	eax
513
	xor	al,al
521
	xor	al,al
514
	call	lseek
522
	call	lseek
515
	mov	ecx,[esp]
523
	mov	ecx,[esp]
516
	mov	edx,[additional_memory]
524
	mov	edx,[additional_memory]
517
	lea	eax,[edx+ecx]
525
	lea	eax,[edx+ecx]
518
	cmp	eax,[additional_memory_end]
526
	cmp	eax,[additional_memory_end]
519
	ja	out_of_memory
527
	ja	out_of_memory
520
	call	read
528
	call	read
521
	call	close
529
	call	close
522
	pop	ecx
530
	pop	ecx
523
	mov	esi,[additional_memory]
531
	mov	esi,[additional_memory]
524
get_line_data:
532
get_line_data:
525
	mov	al,[esi]
533
	mov	al,[esi]
526
	cmp	al,0Ah
534
	cmp	al,0Ah
527
	je	display_line_data
535
	je	display_line_data
528
	cmp	al,0Dh
536
	cmp	al,0Dh
529
	je	display_line_data
537
	je	display_line_data
530
	cmp	al,1Ah
538
	cmp	al,1Ah
531
	je	display_line_data
539
	je	display_line_data
532
	or	al,al
540
	or	al,al
533
	jz	display_line_data
541
	jz	display_line_data
534
	inc	esi
542
	inc	esi
535
	loop	get_line_data
543
	loop	get_line_data
536
display_line_data:
544
display_line_data:
537
	mov	ecx,esi
545
	mov	ecx,esi
538
	mov	esi,[additional_memory]
546
	mov	esi,[additional_memory]
539
	sub	ecx,esi
547
	sub	ecx,esi
540
	call	display_block
548
	call	display_block
541
	mov	esi,cr_lf
549
	mov	esi,cr_lf
542
	call	display_string
550
	call	display_string
543
	pop	ebx
551
	pop	ebx
544
	or	ebx,ebx
552
	or	ebx,ebx
545
	jnz	display_error_line
553
	jnz	display_error_line
546
	mov	esi,error_prefix
554
	mov	esi,error_prefix
547
	call	display_string
555
	call	display_string
548
	pop	esi
556
	pop	esi
549
	call	display_string
557
	call	display_string
550
	mov	esi,error_suffix
558
	mov	esi,error_suffix
551
	call	display_string
559
	call	display_string
552
	jmp	exit_program
560
	jmp	exit_program
553
 
561
 
554
align 4
562
align 4
555
fileinfo FILEINFO
563
fileinfo FILEINFO
556
 
564
 
557
character   db ?,0
565
character   db ?,0
558
bytes_count dd ?
566
bytes_count dd ?
559
 
567
 
560
textxy	 dd 0x000500A0
568
textxy	 dd 0x000500A0
561
dc	 db 0x0
569
dc	 db 0x0
562
filesize dd 0x0
570
filesize dd 0x0
563
 
571
 
564
displayed_count dd ?
572
displayed_count dd ?
565
last_displayed	rb 2
573
last_displayed	rb 2
566
 
574
 
567
error_prefix	  db 'error: ',0
575
error_prefix	  db 'error: ',0
568
error_suffix	  db '.',0
576
error_suffix	  db '.',0
569
line_data_start   db ':'
577
line_data_start   db ':'
570
cr_lf		  db 0Dh,0Ah,0
578
cr_lf		  db 0Dh,0Ah,0
571
line_number_start db ' [',0
579
line_number_start db ' [',0
572
 
580
 
573
macro dm string { db string,0 }
581
macro dm string { db string,0 }