📄 wrto.asm
字号:
sseg segment STACK
db 128 dup (0)
sseg ends
dseg segment 'data'
filename db 'test.bin','0'
dseg ends
cseg segment 'code'
assume cs:cseg;ds:dseg
start:
;read MBR into 87C00 to find our partion,assume our partition ID is 23h
mov ax,8000h
mov es,ax
mov bx,7c00h
mov ax,201h
mov dl,80h
mov dh,0
mov ch,0
mov cl,1
int 13h
;find out our own partion table entry
mov si,7dbeh ;point to the partition table
xor cx,cx
mov cx,4
mov ax,8000h
mov ds,ax
searchloop:
cmp byte ptr [si+4],23h
je continue ;got it!
dec cx
die: je die ;can't find
add si,16 ;address next entry
jmp searchloop
continue:
;we should save the int 13 register parameters reading from Partition table
mov ax,[si+1]
push ax ;save dh(low 8bit)
mov ax,[si+2]
push ax ;save cl(low 8bit)
mov ax,[si+3]
push ax ;save ch(low 8bit)
;now we call dos file system service to read file into 87a00
;200h before our binary file is the head information,skimp it!
;open the binary file
mov ax,dseg
mov ds,ax
mov dx,offset filename
mov ax,3d00h
int 21h
mov bx,ax ;file handler passed
mov ah,3fh
mov cx,1000h
mov dx,8000h
mov ds,dx
mov dx,7a00h ;instruction should start at 87c00
int 21h
mov ah,3eh ;close the file we just opened
int 21h
;55aa signature should be added at 87dfe
mov si,7dfeh
mov [si],0aa55h
mov bx,8000h
mov es,bx
mov bx,7c00h ;set location to be placed
pop ax ;pop up ch
mov ch,al
pop ax ;pop up cl
mov cl,al
pop ax ;pop up dh
mov dh,al
mov dl,80h
mov ax,301h
int 13h
mov ah,4ch ;abort mission
int 21h
cseg ends
end start
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -