; read floppy disk data into memory 0x0820:0000 mov ax,0x0820 mov es,ax mov bx,0
; select sector to read mov ch,0 ; cylinder 0 mov cl,2 ; sector 2 mov dh,0 ; head 0 mov dl,0 ; driver A mov al,1 ; read only 1 sector
; invoke bios to read mov ah,2 int 0x13
; check error jc error
Add retry section
BIOS : reset disk system
Parameter
Register
Value
AH
0x00
DL
Driver number
Result
Register
Value
CF
Set on Error
AH
return code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
retry: ; try to read mov ah,0x02 mov al,1 mov bx,0 mov dl,0x00 int 0x13 jnc fin ;if success halt the machine add si, 1 ; fail time += 1 cmp si,5 ; maximum fail time is 5 jc error ; the author make a mistake here, this should be jc rather than jae mov ah,0x00 ; reset floppy disk mov dl,0x00 int 0x13 jmp retry
next: mov ax,es add ax,0x20 mov es,ax add cl,1 cmp cl,18 jbe readloop ; if finish reading one surface(18 sector), read the other mov cl,1 add dh,1 cmp dh,2 jb readloop ; next cylinder mov dh,0 add ch, 1 ; cylinder number += 1 cmp ch,CYLS ; const CYLS = 10 jb readloop
Start Develop our OS
when saving files into a floppy disk
file name is saved at 0x002600
file content is saved at 0x004200
BIOS int 0x10
Function
Function code
Parameters
Return
Set video mode
AH=0x00
AL=video mode
AL=video mode flag
1 2 3 4 5 6 7 8 9 10 11 12
; source of haribote.sys
;code should start at memory 0x8000 + 0x4200 = 0xc200 org 0xc200 ; originate from 0xc200
mov al,0x13 ; use vga video card, 320x200x8 bit color mov ah,0x00 int 0x10
fin: hlt jmp fin
1 2 3 4
; source of ipt.nas ; add two line after `next` section mov [0x0ff0],ch ;save number of cylinder read to memory jmp 0xc200 ;execute code of haribote.sys