OK. Thanks. I did something very similar to what you said. It is working partly, but the int 0x13 operation performed in the boot sector is returning an error code: 0Ch unsupported track or invalid media. I have never seen this before when I was using real hardware (flash drives).
My HD image is 17 sectors as follows:
sector 1: boot sector very similar to what I posted but with error reporting capability. See listing below.
sectors 2 thru 17: my operating system, jsec2.bin
Please note: I include the format=raw in command line: qemu-system-i386 -hda js1.bin format=raw
but it won't run unless I remove format=raw. Then it runs and reports the 0Ch error. Qemu says:
WRITE OPERATIONS ON BLOCK 0 WILL BE RESTRICTED - because format=raw was not specified.
I wonder if that is what is causing the 0Ch error.
Here is the revised boot sector:
Code:
bits 16
org 0x7c00
mov ax,0
mov ss,ax
mov sp,0x7aff
mov ds,ax
mov si,0x7b00 ;packet location
mov word[si],0x10 ;packet size
mov word[si+2],16 ;# of secs to transfer
mov word[si+4],0x0000 ;offset where to load
mov word[si+6],0x07e0 ;segment where to load
mov word[si+8],2 ;start sector# - mbr=0, this=1
mov word[si+10],0
mov word[si+12],0
mov word [si+14],0
mov ah,0x42 ;extended read
mov dl,0x80
int 0x13
jc berr
mov ax,0x0e31 ;CF=0=success, print 1
int 0x10
jmp 0:0x7e00 ;long jump
berr:
push ax ;save error code from int 13
mov ax,0x0e45 ;CF=1=failed, print E
int 0x10
pop ax
mov cx,2 ;print the 2 digits in ah
hexout:
rol ax,4 ;put hi hex digit on right
push ax ;save rol'd ax
and al,0x0f
add al,'0' ;0 thru 9
cmp al,'9'
jbe .prnhx
add al,0x7 ;A thru F
.prnhx:
mov ah,0xe
int 0x10 ;write
pop ax ;rol'd version of ax
dec cx
jnz hexout ;1 digit per loop
jmp $
times 510-($-$$) db 'k'
dw 0xAA55