Skip to content

Latest commit

 

History

History
90 lines (70 loc) · 2.58 KB

File metadata and controls

90 lines (70 loc) · 2.58 KB

Code: Part of Bootloader that has preprocessor for handling 2.88 floppy disk

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:

Explanation

What does code do?

  1. This code is READDATA part of 5-3.md with one change: preprocessor. If FLOPPY is 288, it read 36 sectors per a track, or if FLOPPY is 144 it reads 18 sectors per a track

Assembly

  1. nasm also has a preprocessor. If you want to define macro from command, use -D option

    %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 Characteristics

  1. MINT64OS is developed in QEMU environment. Because default floppy size of QEMU is 2.88MB which has 36 sectors per tack, you should execute FLOPPY=288 make all in root directory. If you want to make image, then FLOPPY=144 make all in root directory

  2. If you FLOPPY=144 make all and 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

  3. 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 env from command line