📄 wrfpy.asm
字号:
sseg segment STACK
db 128 dup (0)
sseg ends
dseg segment 'data'
filename db 'floppy.bin','0'
binbuf db 512 dup (0)
suc db 'boot block patched successful!','$'
dseg ends
cseg segment 'code'
assume cs:cseg;ds:dseg;es:dseg
extrn panic:near,printf:near
start:
; write floppy.bin into sector 0 of floppy diskette
; open floppy.bin
mov ax,dseg
mov ds,ax
mov es,ax
push bp
mov bp,sp
sub sp,2
mov dx,offset filename
mov ax,3d00h
int 21h
jnc wnext1
push ax
call panic
wnext1:
; move fp to skip DOS exe header
mov bx,ax
xor cx,cx
mov dx,512
mov al,0
mov ah,42h
int 21h
jnc wnext2
push ax
call panic
wnext2:
mov dx,offset binbuf
mov ah,3fh
mov cx,512
int 21h
jnc wnext3
push ax
call panic
wnext3:
;close it
mov ah,3eh
int 21h
mov word ptr [bp-2],5 ; init retry times
wretry:
mov bx,offset binbuf
mov ax,301h
mov dl,0
mov dh,0
mov ch,0
mov cl,1
int 13h
mov ah,1 ; check the error code
int 13h
cmp ah,0
je wnext4
cmp word ptr [bp-2],0
jne wnext5
mov al,ah
xor ah,ah
add ax,6
push ax
call panic
wnext5:
dec word ptr [bp-2]
; reset controller
mov ah,0
int 13h
jmp wretry
wnext4:
mov ax,offset suc
push ax
call printf
pop cx
mov ah,4ch
int 21h
cseg ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -