Floppy Driver keep halting on reset (Solved by BenLunt)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Sending 0 to Floppy Digital Output Register freezes Boch

Post 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?
mikegonta
Member
Member
Posts: 229
Joined: Thu May 19, 2011 5:13 am
Contact:

Re: Sending 0 to Floppy Digital Output Register freezes Boch

Post 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.
Mike Gonta
look and see - many look but few see

https://mikegonta.com
MDenham
Member
Member
Posts: 62
Joined: Sat Nov 10, 2012 1:16 pm

Re: Sending 0 to Floppy Digital Output Register freezes Boch

Post 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
User avatar
Ycep
Member
Member
Posts: 401
Joined: Mon Dec 28, 2015 11:11 am

Re: Sending 0 to Floppy Digital Output Register freezes Boch

Post 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.
Last edited by Ycep on Thu Jun 02, 2016 8:01 am, edited 2 times in total.
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

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

Post 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
Post Reply