However, this wasn't working, so I just tried writing one sector:
Code: Select all
xor ax, ax
mov ax, 0xF000
mov es, ax
xor di, di
WriteToDisk:
cmp di, 512
je Exit2
mov ax, [es:di]
mov [buffer+di], al
inc di
jmp WriteToDisk
ret
Exit2:
mov dh, 3 ;; Sector number
mov bx, buffer ;; Buuff
call writeSector
Code: Select all
writeSector:
push es
xor ax, ax
mov es, ax
;; BX already buffer
mov ah, 0x03 ;; Hey, we want to write!
mov al, 0x01 ;; Only one sector
mov cl, dh
mov dh, 0
;; DL already set by BIOS
;; ES:BX set above
int 0x13
jc .Failure
ret
pop es
ret
.Failure:
mov ah, 0x01
;; DL set
int 0x13
hcf
Code: Select all
%macro hcf 0
cli
hlt
jmp $
%endmacro
Code: Select all
buffer: times 512 db 0
Code: Select all
(qemu) x/1i $eax
0x00002000: 00 00