OSDev.org
https://forum.osdev.org/

BIOS fnc. interrupts corrupted in real mode after a far jump
https://forum.osdev.org/viewtopic.php?f=1&t=32954
Page 1 of 1

Author:  Lukand [ Tue May 22, 2018 6:55 am ]
Post subject:  BIOS fnc. interrupts corrupted in real mode after a far jump

Hello,
as I have mentioned in another post somewhere here on this forum I have started again, actually this time.

Back on the problem I have debugged the OS using bochsdbg just before INT 0x10 execution,
all conditions are just like they are supposed to,
but interrupt never executes, it gets stuck in some SLDT loop, which I assume it's some memory corruption.
It works perfectly fine in 0:0x7C00 (bootloader) but not in 0:0x8000, after a far jump to that address.
It's either aforementioned memory corruption or some segment mis-setup, I don't know...
What do you think? Anyone?
I have added a zipped attachment containing this code.

Attachments:
death.zip [6.94 KiB]
Downloaded 6 times

Author:  Octocontrabass [ Tue May 22, 2018 10:13 am ]
Post subject:  Re: BIOS fnc. interrupts corrupted in real mode after a far

Why all the segment register manipulation? Set all of the segments to 0 and use proper org statements: "org 0x7c00" for stage one and "org 0x8000" for stage two.

Why RETF instead of JMPF? You're wasting space if the destination address is a constant.

Your ReadSectors routine would be easier to understand if you made proper use of BP-relative addressing to access parameters on the stack. Use "RET 4" to clean up the 4 bytes of parameters you pass to the function, instead of manipulating the stack directly. (You may also find the ENTER and LEAVE instructions useful, although it's usually better to use "PUSH BP; MOV BP, SP" instead of ENTER to save a byte.)

What is the address of the last instruction that executes correctly? What is the address of the first instruction that executes incorrectly? Knowing exactly where things go wrong might help us narrow down the problem.

Author:  Lukand [ Wed May 23, 2018 4:19 am ]
Post subject:  Re: BIOS fnc. interrupts corrupted in real mode after a far

Damn, removing all these segment related stuff cleaned my code that much that it does not even look like I wrote it :)
And not only that, it fixed the problem! Probably I made a mistake somewhere dealing with segments, but, as it's really not in existance anymore, neither it does matter. Thanks anyway...
I plan to make ReadSectors more readable by generally doing what you said in thy post.
=======================
=Problem solved.
=======================

Author:  MichaelFarthing [ Wed May 23, 2018 6:04 am ]
Post subject:  Re: BIOS fnc. interrupts corrupted in real mode after a far

Lukand wrote:
I plan to make ReadSectors more readable by generally doing what you said in thy post.


Ooh! A little bug there: "doing what thou said in thy post". The abandoment of thou and thy is a great loss to the English language. I'm all for them!

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/