88 lines
1.2 KiB
NASM
88 lines
1.2 KiB
NASM
fcb1 equ 0x5C
|
|
|
|
org 0x100
|
|
jmp main
|
|
|
|
%include "scan.inc"
|
|
%include "print.inc"
|
|
|
|
main mov di, 0x81
|
|
mov al, 0x20
|
|
mov ch, 0
|
|
mov cl, [0x80]
|
|
repe scasb
|
|
repne scasb
|
|
mov si, di
|
|
call lodnum
|
|
mov dx, ax
|
|
test dx, ~0x83
|
|
jnz drverr
|
|
test dl, 0x80
|
|
jz floppy
|
|
call drverr
|
|
|
|
drverr call putsh
|
|
db "Failed to access drive", 0x0A, 0x0D, 0
|
|
int 0x20
|
|
|
|
floppy mov ax, 0x0201
|
|
mov cx, 0x0001
|
|
mov dh, 0
|
|
mov bx, bs
|
|
int 0x13
|
|
jc drverr
|
|
mov ax, [bs+0x18]
|
|
call debug
|
|
ret
|
|
|
|
mov dx, fcb1
|
|
mov ah, 0xF
|
|
int 0x21
|
|
test al, al
|
|
jz .fok
|
|
.ferr call putsh
|
|
db "Failed to read input file", 0x0A, 0x0D, 0
|
|
ret
|
|
.fok mov si, prog
|
|
; apply our target address
|
|
.rloop mov dx, si
|
|
mov ah, 0x1A
|
|
int 0x21
|
|
; increment address for next iteration
|
|
add si, 0x80
|
|
; do a read
|
|
mov dx, fcb1
|
|
mov ah, 0x14
|
|
int 0x21
|
|
; success: continue
|
|
cmp al, 0
|
|
jz .rloop
|
|
; eof: break
|
|
cmp al, 1
|
|
jz .cok
|
|
; segment wrap: fail
|
|
cmp al, 2
|
|
jz .ferr
|
|
; we assume al=3: eof
|
|
.cok nop
|
|
mov ax, si
|
|
sub ax, args
|
|
call debug
|
|
call putsh
|
|
db "yay", 0x0A,0x0D,0
|
|
|
|
ret
|
|
; mov ax, 0x0201
|
|
; mov cx, 0x0001
|
|
; mov dh, 0
|
|
; mov bx, bs
|
|
; int 0x13
|
|
; mov ax, [bs+0x18]
|
|
;.ret ret
|
|
|
|
align 2
|
|
bs equ $
|
|
psp equ bs + 0x200
|
|
args equ psp + 0x80
|
|
prog equ psp + 0x100
|