Bootloader reading from disk fails

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
cheche
Posts: 1
Joined: Wed Sep 29, 2010 10:43 am

Bootloader reading from disk fails

Post by cheche »

what i want to do is load the string at `disk` from hdd and print it but it doesn't work, can anybody help? thanks...
edit: it shows 'welcome' but than stops..
edit: problem solved.. CHS is the sector number not the byte position
pls delete

Code: Select all

ORG 0

jmp 0x07C0:start    ;ensure cs:ip is 0x07C0:start
start:

mov si,welcome        ;print welcome
call print        ;

mov ah,0               ;reset disk state
int     0x13        ;

mov    ax,0x07C0    ;read to 0x07C0:disk
mov    es,ax
mov    bx, disk
mov    ah, 0x02    ;mode=read
mov     al, 0x01    ;read 1 sector
mov     ch, 0x00    ;1. cylinder
mov     dh, 0x07        ;8. head
mov     cl, 0x08    ;9. sector
            ;dl was set by bios
            ;ata0-master: type=disk, path="/home/check3r/math/loader.o", mode=flat, cylinders=2, heads=16, spt=63
int     0x13        ;0*16*63 + 8*63 + 9 - 1 = 512

mov si,disk        ;print result
call print
jmp $

print:
    mov ax, 0x07C0
    mov ds,ax 
    ;mov si,%1
    mov ah,0x0E
    ch_loop:
        lodsb
        or al, al 
        jz endString
        int 0x10
    jmp ch_loop
    endString:
ret
;end code

welcome   db 'Welcome', 13, 10, 0
times 510-($-$$) db 0
db 0x55
db 0xAA
; end 512 bytes

disk db 'String on disk',13,10,0
times 1032192-($-$$) db 0
Post Reply