READDATA:
; check if there is no more sectors to read
cmp di, 0
je READEND
sub di, 0x01
; call BIOS I/O service
mov ah, 0x02 ; service number (read sector)
mov al, 0x01 ; number of sectors to read
mov ch, byte [TRACKNUMBER]
mov cl, byte [SECTORNUMBER]
mov dh, byte [HEADNUMBER]
mov dl, 0x00 ; drive to read (0=Floppy)
int 0x13 ; interrupt to execute service
jc HANDLEDISKERROR
; set next dest_addr: after 512 byte from prev dest
add si, 0x0020
mov es, si
; set sector, head, track numbers to next src_addr
; floppy sector range: 1~18 in 1.44MB and 1~36 in 2.88MB
; floppy head range: 0~1
; floppy track(cylinder) range: 0~79
mov al, byte [SECTORNUMBER]
add al, 0x01
mov byte [SECTORNUMBER], al
%if FLOPPY == 144
cmp al, 19 ; for 1.44MB
%elif FLOPPY == 288
cmp al, 37 ; for 2.88MB floppy which is default of QEMU
%else
%error "FLOPPY should be 144 or 288"
%endif
xor byte [HEADNUMBER], 0x01
mov byte [SECTORNUMBER], 0x01
cmp byte [HEADNUMBER], 0x00
jne READDATA
add byte [TRACKNUMBER], 0x01
jmp READDATA
READEND:- This code is READDATA part of 5-3.md with one change: preprocessor. If
FLOPPY is
288, it read36sectors per a track, or if FLOPPY is144it reads18sectors per a track
-
nasm also has a preprocessor. If you want to define macro from command, use
-Doption%if FLOPPY == 144 cmp al, 19 ; for 1.44MB %elif FLOPPY == 288 cmp al, 37 ; for 2.88MB floppy which is default of QEMU %else %error "FLOPPY should be 144 or 288" %endif ; in shell ; nasm -D FLOPPY=144 -o BootLoader.bin BootLoader.asm
-
MINT64OS is developed in QEMU environment. Because default floppy size of QEMU is
2.88MBwhich has36 sectorsper tack, you should executeFLOPPY=288 make allin root directory. If you want to make image, thenFLOPPY=144 make allin root directory -
If you
FLOPPY=144 make alland run the image in QEMU, you will find that Virtual OS in 5-4.md does not work as intended because bootloader just loads 18 sectors out of 36 sectors in a track -
Because the final code in this chapter has preprocessor, Makefile in 00.BootLoader and Makefine in root directory is also modified so that it can take
FLOPPY envfrom command line