Page 1 of 2

Division by zero at BT instruction

Posted: Wed Jan 18, 2006 10:01 am
by xsix
Hey ya. I've one big problem, really big, maybe not so big. I've 2 computers, if you're interested in that, they're: Intel Celeron 1.3GHz 128RAM, ant another is Cyrix instead 233MHz 68RAM. THe problem is that my OS runs fine on cyrix, but on my celeron computer it get a division by zero fault, which shows into address, with BT instruction, as far as i know, division by zero fault can be only excepted then DIV or IDIV instruction tries to divide by zero, or the result is too big. So i'll be happy if someone will help me ;) .

Re:Division by zero at BT instruction

Posted: Wed Jan 18, 2006 10:10 am
by kataklinger
Maybe it's some other exception happend (maybe invalid opcode?) but your IDT entery for that exception points to divide by zero exception handler.

Re:Division by zero at BT instruction

Posted: Wed Jan 18, 2006 11:03 am
by CopperMan
Try to replace BT with TEST instruction, then try again.

Re:Division by zero at BT instruction

Posted: Thu Jan 19, 2006 9:31 am
by xsix
Now i've changed BT with AND, then with TEST, the only effect what can i see is that fault comes again and again at address 00100BD3. My ORG is 1024*1024+1024. Here is a disassembly cut of that code:
00100BCE EB82 jmp short 0xb52
00100BD0 FB sti
00100BD1 E464 in al,0x64
00100BD3 2401 and al,0x1
00100BD5 0F8477FF jz near 0xb50
00100BD9 FF db 0xFF
00100BDA FF75F3 push word [di-0xd]
There is the 4th line where the fault comes. I don't understand, on another PC it works, on mine doesn't =\ .

Re:Division by zero at BT instruction

Posted: Thu Jan 19, 2006 9:35 am
by Pype.Clicker
That sounds like a badly-remapped PIC to me ... a division by zero that is repeatedly thrown at non-div opcodes ...

Code: Select all

00100BD5  0F8477FF          jz near 0xb50
00100BD9  FF                db 0xFF
00100BDA  FF75F3            push word [di-0xd]
your disassembler doesn't seems accurate either: it looks like it tries to disassemble 32bit code in 16-bit mode ...

Re:Division by zero at BT instruction

Posted: Fri Jan 20, 2006 6:35 am
by kataklinger
Hmm... What happens when you remove this line?

Code: Select all

00100BD0  FB                sti
It looks like you have bad PIC or IDT setup code.

Re:Division by zero at BT instruction

Posted: Fri Jan 20, 2006 9:23 am
by xsix
Emm... IDT is working fine, PIC remapped fine too. On another computer it works. Disassembly is in 32bit form, maybe i'll try to test it on some other computers :-\ ...

Re:Division by zero at BT instruction

Posted: Fri Jan 20, 2006 10:26 am
by kataklinger

Code: Select all

and al,0x1
This _cannot_ produce any exception (maybe broken CPU, but I don't think so)!

It happens just after you have enabled interrupts, so there is something wrong with hardware interrupts, I guess.

Code: Select all

jz near 0xb50
db 0xFF
push word [di-0xd]
This code looks really strange! What this suppose to do?

Re:Division by zero at BT instruction

Posted: Fri Jan 20, 2006 10:31 am
by Phugoid
xsix wrote: 00100BD5 0F8477FF jz near 0xb50
00100BD9 FF db 0xFF
00100BDA FF75F3 push word [di-0xd]
That is not 32-bit disassembly. There is a 16-bit offset supplied with that near jump instruction. Clearly, the next two bytes also belong to it. Also, there is a 16-bit register used in an address calculation without an address size override prefix.

Re:Division by zero at BT instruction

Posted: Fri Jan 20, 2006 11:41 am
by kataklinger
Send real code instead of disassembly. Or tell your compiler to produce asm output and compare the resaults. ;)

Re:Division by zero at BT instruction

Posted: Fri Jan 20, 2006 11:59 am
by xsix
I use NASM. Disassembly done with ndisasm with parameter -b 32... CPU isn't broken, i hope ;D. Ok, whatever, thank you all for your answers, i'll find that error, my code, my problems. ;)

Re:Division by zero at BT instruction

Posted: Fri Jan 20, 2006 1:10 pm
by Kemp
So if you are coding in assembly in the first place why are you providing output that has been run through two seperate processes rather than just showing us the original?

Re:Division by zero at BT instruction

Posted: Fri Jan 20, 2006 1:50 pm
by xsix
I'm not good in english... But disassembly is the same as asm code. Doesn't matter,i just want to know why so simple thing faults on one computer, but not on another.

Re:Division by zero at BT instruction

Posted: Fri Jan 20, 2006 2:19 pm
by Solar
xsix wrote: I'm not good in english... But disassembly is the same as asm code.
No it isn't. Source is usually better formatted and commented. It does also rule out any wrongful settings to the disassembler.

Re:Division by zero at BT instruction

Posted: Fri Jan 20, 2006 3:54 pm
by Kemp
It's also one less step to copy-paste than disassemble-copy-paste.