Why is it returning me "random" values?
Code: Select all
_readsector:
mov ebx, ecx
mov eax, [ebp+12] ;second parameter
cmp eax, 0
je _readsector_fail
push eax ;sector number
mov dx, 0x1f2
mov al, cl
out dx, al
inc dx ;dx = 0x1f3
pop eax
out dx, al
inc dx ;dx = 0x1f4
shr eax, 8
out dx, al
inc dx ;dx = 0x1f5
shr eax, 8
out dx, al
inc dx ;dx = 0x1f6
shr eax, 8
and al, 00001111b
or al, 01000000b
out dx, al
inc dx ;dx = 0x1f7
mov al, 0x20
out dx, al
mov ecx, 4
_readsector_wait:
in al, dx
test al, 0x80 ; BSY
jne _readsector_retry
test al, 0x08 ; DRQ
jne _readsector_ready
_readsector_retry:
dec ecx
jg _readsector_wait
_readsector_nextsector:
in al, dx
test al, 0x80
jne _readsector_nextsector
test al, 0x21
jne _readsector_fail
_readsector_ready:
sub dx, 7 ;0x1f0
mov ecx, 256
mov edi, buffer
rep insw
(...)
push eax
mov eax, [ebp+16]
_readdisk_eax:
mov [eax], long word buffer
pop eax
(...)
buffer: times 512 db ('V')