📄 bootwr.asm
字号:
;read input boot file into buf and write it into sector 0 of fd A
org 100h
jmp start
f1 dw ?
buf db 512 dup(' ')
fname_struct: ; struct for input file name
max_len db 20 ; maximum allowed length for a file name
act_len db 20 ; actual length entered
fname db 20 dup(?)
m1 db 'enter boot file name:', '$'
m2 db 0dh,0ah,'something wrong','$'
m3 db 0dh,0ah,'writing succeded','$'
start:
; set es
mov ax, cs
mov es, ax
; ask the file name
mov ah, 9
lea dx, m1
int 21h
; and get the file name
mov ah, 0ah
lea dx, fname_struct
int 21h
; it is in fname
; make it ascii zero
mov al, act_len
cbw
lea bx, fname
add bx, ax
mov byte ptr [bx], 0
; read from it
mov ah, 3dh
mov al, 0
lea dx, fname
int 21h
jc error
mov f1, ax
; now file handle is f1. read 512 byte from it
mov ah, 3fh
mov bx, f1
mov cx, 512
lea dx, buf
int 21h
jc error
; now input bin file is in buf. write it into sector 0 of fd A
; first, reset disk
mov ah, 0 ; reset disk
mov dl, 0 ; drive A
int 13h
jc error
; now write
mov ah, 03h ; write
mov al, 1 ; only 1 sector
lea bx, buf
mov ch, 0; track 0
mov cl, 1; sector 1
mov dh, 0; head 0
mov dl, 0; A drive
int 13h
jc error
; done
mov ah,9
lea dx, m3
int 21h
mov ah, 4ch
int 21h
error:
mov ah,9
lea dx, m2
int 21h
mov ah, 4ch
int 21h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -