I'm in need for the knowledge and further clarification (either it's written in documentation that is hard for me to find just by typing on a Google search or with the GitHub repo) on going to desired sector (in my case it's sector 1), 'cause I still fail to make it fully functional due to lack of understanding the right order/code arrangement.
The code goes like this:
org 0x7c00
bits 16
mov ah, 0x02 ; reading
mov al, 0x1
mov ch, 0x0
mov cl, 0x1 ; sector 1
mov dh, 0x0
mov dl, 0x00 ; from floppy (.img)
int 13h
jc error ; error handling for the wrong/absent position
jmp 0x0200 ; trying to jump to the address
error:
mov bx, [errorline]
mov ah, 0x0e
printerr:
mov al, [bx]
cmp al, 0
je end
inc bx
jmp printerr
end:
cli
hlt
jmp $
errorline:
db "Couldn't go and execute from sector 1", 0
times 510-($-$$) db 0
dw 0x55AA
;outside the boot sector
jmp target
target:
mov bx, [targetline]
mov ah, 0x0e
printtarg:
mov al, [bx]
cmp al, 0
je end
int 0x10
inc bx
jmp printtarg
end:
cli
hlt
jmp $
targetline:
db "Success.", 0
;end of the sector 1 code
times 0x400-($-$$) db 0
I'm struggling with that problem from couple of days now (Defining sector 1 in order to go and print something.), and still seeking for the constructive explanation and direct solution from people who are more experienced. Preferably with the full code, I'll be grateful for your help
A number of problems in this NASM code
int 10hto actually perform the BIOS.Teletype functionmov dl, 0x00instead of trusting the DL value that BIOS will have passed to the bootloader at 0x7C00The improved code
The above full code should resolve the issues. Pay attention to the tail comments I added in the program.