This is the working version of the code, but I have problems and questions about it
- BIOS returns the floppy drive = 231 not 0 as I read floppy should be = 0 so when replacing dlwith 0 inread:it fails to read the disk but when it replacingdlinreset:it resets successfully so which drive is reset while the floppy drive = 0
- When I put pushain print_string before the rest of the code andpopain print_done beforeretafter running the program it only printsbootmsg
- When replacing 0x0F00 with 0x1000 and 0xF000 with 0x10000 it doesn't print Hello World but it prints SI don't know why
- When replacing 0x0F00 with 0x1000 and 0xF000 with es:bx (while it must be equivalent to 0x10000) it doesn't Hello WorldnorS
Edit: I'm using qemu
program_intialization:
    org 0x7C00          ;load program at 0x7C00
    push dx             ;save drive number to stack appeared to be 231 not 0
    jmp program_start   ;go to program_start
print_string:
    cld                 ;clear direction flag to increase si after copying the value of the address pointed by it
    lodsb               ;copy [si] into al then increase si
    or al,al            ;check if al is null
    jz print_done       ;if null then go to print_done
    mov ah,0x0E         ;else copy 0x0E to ah which is the video output code
    int 0x10            ;then interrupt the program with 0x10 the video routine code which will print the character in al
    jmp print_string    ;and print the next character until null is found
    print_done:
        mov al,0x0A     ;copy the code of line feed into al
        mov ah,0x0E     ;copy 0x0E to ah which is the video output code
        int 0x10        ;interrupt the program with 0x10 the video routine code which will print the character in al (the line feed)
        mov al,0x0D     ;copy the code of carriage return into al
        mov ah,0x0E     ;copy 0x0E to ah which is the video output code
        int 0x10        ;interrupt the program with 0x10 the video routine code which will print the character in al (the carriage return)
        ret             ;return to the place the function is called from
program_start:
    xor ax,ax           ;intialize ax to 0
    mov ds,ax           ;intialize ds to 0
    mov es,ax           ;intialize es to 0
    mov si,bootmsg      ;copy bootmsg address to si
    call print_string   ;print bootmsg
    reset:
        mov si,rstmsg       ;copy reset adress to si
        call print_string   ;print reset
        mov ah,0            ;drive reset code
        pop dx              ;get drive number into dl
        push dx             ;save drive number again
        int 0x13            ;reset drive
        jc reset            ;if failed try again
        mov ax,0x0F00       ;copy 0x0F00 to ax
        mov es,ax           ;copy 0x0F00 to es
        xor bx,bx           ;make bx = 0x0000
        mov si,scs          ;if success
        call print_string   ;print scs
    read:
        mov si,rdmsg        ;copy reset adress to si
        call print_string   ;print reset
        pop dx              ;get the drive number into dl
        mov ah,0x02         ;copy disk read code to ah
        mov al,1            ;read 1 sector
        mov ch,0            ;on track 0
        mov cl,2            ;read sector number 2
        mov dh,0            ;head number 0
        int 0x13            ;read from disk to memory address es:bx (0xF000)
        jc read             ;if failed try again
        mov si,scs          ;if success
        call print_string   ;print scs           
end:
    mov si,0xF000           ;which is es:bx
    call print_string0      ;print Hello World read from memory 0xF000
    cli                     ;clear all interupts
    hlt                     ;halt the system
bootmsg db "Bootloader v0.1",0
rstmsg db "Trying to reset Floppy Disk",0
rdmsg db "Trying to read Floppy Disk",0
scs db "Operation Successful",0
times 510 - ($-$$) db 0     ;fill the rest of bootsector with 00
dw 0xAA55                   ;boot magic number
msg db "Hello World",0      ;add hello world to the next sector (512bytes) which will be read
 
     
    