2021-06-26 15:55:47 +00:00
|
|
|
|
CPU 8086
|
2021-06-28 21:09:38 +00:00
|
|
|
|
ORG 0x3000
|
2021-06-26 15:55:47 +00:00
|
|
|
|
|
|
|
|
|
;Load a file and print it
|
|
|
|
|
|
|
|
|
|
;Set the stack
|
|
|
|
|
cli
|
|
|
|
|
mov sp, stack + 0x100
|
|
|
|
|
sti
|
|
|
|
|
|
|
|
|
|
;Check for an empty tail
|
2021-06-28 17:00:22 +00:00
|
|
|
|
;Check
|
2021-06-26 15:55:47 +00:00
|
|
|
|
cmp byte [si], 0x0
|
2021-06-28 17:00:22 +00:00
|
|
|
|
jne start
|
|
|
|
|
;Prin an error message and abort if the tail is empty
|
|
|
|
|
mov si, errormsg
|
|
|
|
|
mov ah, 0x2
|
|
|
|
|
int 0x21
|
|
|
|
|
je done
|
|
|
|
|
|
|
|
|
|
start:
|
2021-06-26 15:55:47 +00:00
|
|
|
|
|
|
|
|
|
;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
|
2021-06-28 17:00:22 +00:00
|
|
|
|
je done
|
2021-06-26 15:55:47 +00:00
|
|
|
|
;Print
|
|
|
|
|
mov si, stack + 0x100
|
|
|
|
|
mov ah, 0x0
|
|
|
|
|
int 0x21
|
|
|
|
|
|
2021-06-28 17:00:22 +00:00
|
|
|
|
done:
|
2021-06-26 15:55:47 +00:00
|
|
|
|
int 0x20
|
|
|
|
|
|
|
|
|
|
;Data
|
|
|
|
|
errormsg db "File not found", 0x0
|
|
|
|
|
|
|
|
|
|
stack:
|
|
|
|
|
|