- loading db 'Starting BOS'\r
- filename db 'KERNEL SYS'\r
- failure db 'Read error!'\r
-\r
-\r
- ;-----------------------------------------------;\r
- ; read a number of sectors (one at a time) ;\r
- ;-----------------------------------------------;\r
- ; in: ;\r
- ; di = segment to save at ;\r
- ; ax = sector to read ;\r
- ; cx = number of sectors ;\r
- ; out: ;\r
- ; di = updated (added for next read) ;\r
- ; ax = updated (added for next read) ;\r
- ;-----------------------------------------------;\r
- read_sectors:\r
- pusha\r
- mov bl, byte [bpbTrackSect] ; bl = number of sectors per track\r
- div bl ; al = ax / bl\r
- mov cl, ah ; cl = real sector number\r
- add cl, 1\r
-\r
- xor ah, ah ; del the rest of the div before\r
- mov bl, byte [bpbHeads] ; bl = number of heads\r
- div bl ; ah = rest of ( ax / bx ), al = ax / bx\r
- mov ch, al ; ch = number of track\r
- mov dh, ah ; dh = the head number\r
-\r
- mov ax, cx ; save cx in ax\r
- mov cx, 6 ; try it 6 times\r
- .next_try:\r
- push es\r
- push cx\r
- mov cx, ax ; restore cx\r
- push cx\r
-\r
- xor ax, ax\r
- mov dl, [bpbDriveNo] ; reset drive\r
- push dx\r
- int 0x13\r
- jc .failed\r
-\r
- pop dx\r
- pop cx\r
- xor bx, bx\r
- mov es, di\r
- mov ax, 0x0201 ; function 2, 1 sector\r
- int 0x13\r
- jnc .ok ; if it was ok, check next..\r
-\r
- .failed:\r
- pop dx\r
- pop ax\r
-\r
- pop cx\r
- pop es\r
- loop .next_try ; else try once again if there is an error\r
- jmp error ; if cx = 0 and the read operation failed, halt\r
- .ok:\r
- pop cx ; from the next_try loop\r
- pop es\r
- popa\r
- add di, 32 ; add 32 (512/16) to segment\r
- inc ax ; add sector counter\r
- loop read_sectors\r
- ret\r
-\r
-\r
- ;----------------------------------------------------;\r
- ; show a message and wait for a key before reboot ;\r
- ;----------------------------------------------------;\r
- error:\r
- mov bp, failure\r
- mov ax, 0x1301\r
- mov bx, 4\r
- mov cx, 11\r
- mov dx, 0x0401\r
- int 0x10\r
-\r
- mov ah, 0\r
- int 0x16\r
- int 0x19\r
+ loading db 'Starting BOS'\r
+ filename db 'KERNEL SYS'\r
+ failure db 'Read error!'\r
+\r
+\r
+;-----------------------------------------------;\r
+; read a number of sectors (one at a time) ;\r
+;-----------------------------------------------;\r
+; in: ;\r
+; di = segment to save at ;\r
+; ax = sector to read ;\r
+; cx = number of sectors ;\r
+; out: ;\r
+; di = updated (added for next read) ;\r
+; ax = updated (added for next read) ;\r
+;-----------------------------------------------;\r
+read_sectors:\r
+ pusha\r
+ mov bl, byte [bpbTrackSect] ; bl = number of sectors per track\r
+ div bl ; al = ax / bl\r
+ mov cl, ah ; cl = real sector number\r
+ add cl, 1\r
+\r
+ xor ah, ah ; del the rest of the div before\r
+ mov bl, byte [bpbHeads] ; bl = number of heads\r
+ div bl ; ah = rest of ( ax / bx ), al = ax / bx\r
+ mov ch, al ; ch = number of track\r
+ mov dh, ah ; dh = the head number\r
+\r
+ mov ax, cx ; save cx in ax\r
+ mov cx, 6 ; try it 6 times\r
+ .next_try:\r
+ push es\r
+ push cx\r
+ mov cx, ax ; restore cx\r
+ push cx\r
+\r
+ xor ax, ax\r
+ mov dl, [bpbDriveNo] ; reset drive\r
+ push dx\r
+ int 0x13\r
+ jc .failed\r
+\r
+ pop dx\r
+ pop cx\r
+ xor bx, bx\r
+ mov es, di\r
+ mov ax, 0x0201 ; function 2, 1 sector\r
+ int 0x13\r
+ jnc .ok ; if it was ok, check next..\r
+\r
+ .failed:\r
+ pop dx\r
+ pop ax\r
+\r
+ pop cx\r
+ pop es\r
+ loop .next_try ; else try once again if there is an error\r
+ jmp error ; if cx = 0 and the read operation failed, halt\r
+ .ok:\r
+ pop cx ; from the next_try loop\r
+ pop es\r
+ popa\r
+ add di, 32 ; add 32 (512/16) to segment\r
+ inc ax ; add sector counter\r
+ loop read_sectors\r
+ ret\r
+\r
+\r
+;----------------------------------------------------;\r
+; show a message and wait for a key before reboot ;\r
+;----------------------------------------------------;\r
+error:\r
+ mov bp, failure\r
+ mov ax, 0x1301\r
+ mov bx, 4\r
+ mov cx, 11\r
+ mov dx, 0x0401\r
+ int 0x10\r
+\r
+ mov ah, 0\r
+ int 0x16\r
+ int 0x19\r