60 lines
743 B
NASM
60 lines
743 B
NASM
CPU 8086
|
||
ORG 0x3000
|
||
|
||
;Load a file and print it
|
||
|
||
;Set the stack
|
||
cli
|
||
mov sp, stack + 0x100
|
||
sti
|
||
|
||
;Check for an empty tail
|
||
;Check
|
||
cmp byte [si], 0x0
|
||
jne start
|
||
;Prin an error message and abort if the tail is empty
|
||
mov si, errormsg
|
||
mov ah, 0x2
|
||
int 0x21
|
||
je done
|
||
|
||
start:
|
||
|
||
;Find the end of the filename and add a null if needed
|
||
;Set DI at the tail
|
||
mov di, si
|
||
findend:
|
||
;Check for the string end
|
||
cmp byte [di], 0x0
|
||
je load
|
||
;Check for a space
|
||
cmp byte [di], 0x20
|
||
je addnull
|
||
inc di
|
||
jmp findend
|
||
addnull:
|
||
mov al, 0x0
|
||
stosb
|
||
|
||
;Load and print the file
|
||
load:
|
||
;Load
|
||
mov bx, stack + 0x100
|
||
mov ah, 0x0
|
||
int 0x22
|
||
;Check for errors
|
||
cmp al, 0x1
|
||
je done
|
||
;Print
|
||
mov si, stack + 0x100
|
||
mov ah, 0x0
|
||
int 0x21
|
||
|
||
done:
|
||
int 0x20
|
||
|
||
;Data
|
||
errormsg db "File not found", 0x0
|
||
|
||
stack:
|
||
|