Page 1 of 1
Write sector failure - where is my error?
Posted: Wed Aug 06, 2014 2:25 pm
by MuayThai
When I try to write a sector this code dont works:
Code: Select all
mov dx,BAR
add dx,6
mov ax,E0h
out dx,ax
sub dx,4
mov ax,1
out dx,ax
inc dx
mov ax,0
out dx,ax
inc dx
mov ax,0
out dx,ax
inc dx
xor ax,ax
out dx,ax
mov ax,30h
mov dx,BAR
add dx,7
out dx,ax
sub dx,7
mov cx,256
Start:
cmp cx,0
jz End
mov ax,0
out dx,ax
dec cx
jmp Start
End:
retn
This code above doNOT write any data in boot sector. Where is my error???
Re: write sector failure
Posted: Wed Aug 06, 2014 5:58 pm
by SpyderTL
What is BAR set to? Try replacing it with the actual port number to make sure the rest of the code is working properly.
Have you tried debugging this code with something like Bochs?
You are also supposed to check the status register and wait for the controller to tell you that the data is ready.
You need to step through this code, and you need to check your status registers to make sure the controller is ready to receive data.
Re: write sector failure
Posted: Wed Aug 06, 2014 11:13 pm
by MuayThai
SpyderTL wrote:What is BAR set to? Try replacing it with the actual port number to make sure the rest of the code is working properly.
Have you tried debugging this code with something like Bochs?
You are also supposed to check the status register and wait for the controller to tell you that the data is ready.
You need to step through this code, and you need to check your status registers to make sure the controller is ready to receive data.
The BAR is the Base Address Reguister from PCI.
I've debugged my code but cannot find any error.
When I check the status register and the BSY clear and DRQ is set then I can and receive data.
The weird thing is that the same code above works only to read sectors(20h) or identify(ECh) Why my code only read sectors but don't write sectors?