57 lines
677 B
NASM
57 lines
677 B
NASM
|
CPU 8086
|
|||
|
ORG 0x2000
|
|||
|
|
|||
|
;Load a file and print it
|
|||
|
|
|||
|
;Set the stack
|
|||
|
cli
|
|||
|
mov sp, stack + 0x100
|
|||
|
sti
|
|||
|
|
|||
|
;Check for an empty tail
|
|||
|
cmp byte [si], 0x0
|
|||
|
je error
|
|||
|
|
|||
|
;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 error
|
|||
|
;Print
|
|||
|
mov si, stack + 0x100
|
|||
|
mov ah, 0x0
|
|||
|
int 0x21
|
|||
|
|
|||
|
int 0x20
|
|||
|
|
|||
|
error:
|
|||
|
mov si, errormsg
|
|||
|
mov ah, 0x2
|
|||
|
int 0x21
|
|||
|
int 0x20
|
|||
|
|
|||
|
;Data
|
|||
|
errormsg db "File not found", 0x0
|
|||
|
|
|||
|
stack:
|
|||
|
|