I am trying to load 2nd sector of floppy disk
I test this code with fasm 1.7 and windows 7, VMware.
to make floppy image file, I used dd
from Ubuntu 13.04
I also use dd
to write .bin
into .img
here's my code
org 0x7c00
;load 2nd sector to physical ram address 0xf00
;(load '7' to 0xf00)
mov ah, 02h
mov al, 1
mov ch, 0
mov cl, 2;1~63
mov dh, 0
mov dl, 0
mov bx, 0xf00
push 0
pop es
int 13h
;check whether it is loaded correctly
;by printing a ascii character in 0xf00
mov ah,0fh
int 10h
mov ah,0ah
mov al, [0xf00];
mov cx, 1
int 10h
;pause
jmp $
times 510-($-$$) db 0h
dw 0xaa55
second_sector:
db '7'
result = don't print '7' at all what's wrong with me? thanks
Frank Kotler is correct in his assessment that the issue is with the line:
In the absence of a segment being set, [0xf00] is implicitly [ds:0xf00]. In this StackOverflow answer I give some general bootloader development tips. Tip #1:
You do set ES to 0:
You have the option of explicitly setting the segment register on the memory operand like this:
Or setting DS to 0 at startup. Remove these:
And add this to the top of your code:
You should assume the location of SS:SP (stack) conflicts with the memory you read disk sectors to, thus it's good practice to set SS:SP to a location that won't be interfered with. Reading disk data on top of the active stack will lead to failures. See the link to my Stackoveflow answer mention earlier for an example.