Subversion Repositories Kolibri OS

Rev

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

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