Page 2 of 2

Re: Sending 0 to Floppy Digital Output Register freezes Boch

Posted: Sat May 28, 2016 6:01 am
by Octocontrabass
lukaandjelkovic wrote:Since it's char i should move stack pointer by 1.
Wrong. On a 32-bit stack, push and pop always move the stack pointer by 4. Where did you hear that it could move by 1?

Re: Sending 0 to Floppy Digital Output Register freezes Boch

Posted: Sat May 28, 2016 6:02 am
by mikegonta
lukaandjelkovic wrote:
mikegonta wrote:Next time push 24 so that you can move the stack pointer by the required 4.
Nope. That isn't working. Anyways, it seem you wrongly understood my eoimsg function, this is how it looks:

Code: Select all

eoimsg (unsigned char intno)
Since it's char i should move stack pointer by 1.
It seems that you wrongly understood x86 assembly language. There is no such thing a push a byte onto the stack, byte values are
zero extended to either 16 or 32 bits depending on the mode. Here I'm assuming that the code is PM32 in which case the stack has
to be adjusted by 4.
Take care (and be careful). Around here such trivia is consider required knowledge.

Re: Sending 0 to Floppy Digital Output Register freezes Boch

Posted: Sat May 28, 2016 1:33 pm
by MDenham
lukaandjelkovic wrote:
MDenham wrote: Since the following instruction is popad, if the procedure you're calling doesn't pop the parameter already (protip: it should) you can clean that up with just "pop eax" (or any other register since it'll just get overwritten with the correct contents on the next instruction).
Thanks :) , so, this is how it should look then:

Code: Select all

pushad
setz[IRQFire]
	push 6
	call eoimsg
add esp, 1
popad
pop eax
iretd
Note that IRQFire is boolean.
Not quite.

Code: Select all

pushad
setz[IRQFire]
	push 6
	call eoimsg
pop eax ; but see below
popad
iretd
This is correct (EAX will get overwritten with the correct value because of the following popad), but only if eoimsg doesn't use a pop instruction to move the parameter into a register. If it does, then you don't need to pop it off because it's already off the stack!

EDIT: Also, what's the calling convention you're using in your C code? For functions like this, where it's just one small parameter being used (or anything up to two dword parameters, actually - ECX gets the first parameter, EDX gets the second), fastcall is probably the correct choice and it turns your code into this:

Code: Select all

pushad
setz [IRQFire]
mov ecx, 6
call eoimsg
popad
iretf

Re: Sending 0 to Floppy Digital Output Register freezes Boch

Posted: Mon May 30, 2016 10:56 am
by Ycep
BenLunt wrote:Hi,

My guess is that it is the next line that is causing the problem.

> outb(DigitalOutReg, EnableIRQDMA|Reset);

Here you have told the FDC to allow interrupts.

Have you set up a valid IRQ yet?
BEN, U SAVED MY LIFE!
I PUT IRQ TO 6! IT NEEDED TO BE 38!
HOW COULD I DO SUCH A THING!? I NEEDED 10 DAYS TO FIND THIS!!!
I'll put you on my friends list. :D :P :mrgreen:
Also thanks everyone who tried to help me.

Re: Floppy Driver keep halting on reset (Solved by BenLunt)

Posted: Mon May 30, 2016 11:36 am
by BenLunt
I am glad to help.

I am guessing you remapped the PIC from 6 to 38.

Continue on, do your best, then when you get stuck, let us know.

Ben