Page 1 of 1

Unreal mode howto?

Posted: Sat Jul 02, 2005 4:32 pm
by Jubbens
The process of getting into unreal mode is confusing. Here's what I've done so far.

- Disabled interrupts
- Enabled A20 line
- Loaded GDT with segment values for real and protected mode
- Jumped to protected mode

Where do I go from here? I can't find a good guide and I'm kinda stuck.

Another thing, FASM doesn't seem to like to include files. I use
include 'myfile.asm' and it compiles fine. But when I go to use functions defined in myfile.asm, it hangs. What am I doing wrong here?

Thanks.

Re:Unreal mode howto?

Posted: Sat Jul 02, 2005 7:16 pm
by AR
  • Enable A20
  • Disable interrupts
  • Set the protected mode bit in CR0
  • Load a data segment register with a GDT Selector
You will then be able to access the whole address space from a 16bit realmode code segment.

Re:Unreal mode howto?

Posted: Sat Jul 02, 2005 7:40 pm
by Jubbens
...so that's basicly my list of what I've done in a different order. Does that mean I'm done? I thought you have to do something in pmode then jump back to real mode?

Any insight on the second question?

Thanks.

Re:Unreal mode howto?

Posted: Sat Jul 02, 2005 11:11 pm
by RetainSoftware
You have to do the jump back to real mode.

ljmp $0000:unreal
unreal:

Greets,

Rene

Re:Unreal mode howto?

Posted: Sun Jul 03, 2005 1:10 am
by AR
Long jumping after having enabled the protected mode bit will attempt to load the descriptor from the GDT, which in that case is the NULL Descriptor which will cause a GPF.

Does FASM itself jam, or just the program when it's run? If it's the program that jams then you've most likely got a bug in the functions that prevent one of them from returning.

Re:Unreal mode howto?

Posted: Sun Jul 03, 2005 5:30 am
by Dex4u
Fasm include file work fine, it must be your function that is wrong, also were you put the include file is very important.

Re:Unreal mode howto?

Posted: Sun Jul 03, 2005 6:58 am
by Pype.Clicker
we have also a BabyStep about unreal mode ...

Re:Unreal mode howto?

Posted: Sun Jul 03, 2005 10:56 am
by Jubbens
Thanks everyone for the unreal mode help. I'll see if it works once I get my include files working!

It's when the code runs that is producing the crash. I know that the code in the include files is fine, because it works when it is compiled directly into kernel.asm. The include files are in the same directory as fasm.exe and kernel.asm. I know that the code from the include files is in the compiled binary, because it is the same size as the kernel compiled with the include file's code directly in it.

Re:Unreal mode howto?

Posted: Sun Jul 03, 2005 11:43 am
by Dex4u
Note: when i said the the place the include file is in was important, I meant its important were it is in the code.
if it for pmode you do not want it under "use16" etc.
Try puting it in the code were you want to run it and jmp over it, just to test if it in the wrong place, something like this:

Code: Select all

jmp     OverInclude
include 'MyInclude.inc'
OverInclude:
call   MyFunction

Re:Unreal mode howto?

Posted: Sun Jul 03, 2005 12:25 pm
by Jubbens
Thanks for the suggestion. But no change. :-\

Do I have to do anything to the include files to include them? This theoreticly should be working.

Re:Unreal mode howto?

Posted: Mon Jul 04, 2005 7:05 am
by Dex4u
No, my include files are just filled with normal functions, eg:

Code: Select all

NameOfFunction1:
 ;some code here, including using var1 and var2
ret

NameOfFunction2:
 ;some code here
ret

NameOfFunction3:
 ;some code here
ret
;Data
var1   db  0
var2   dd  0

Re:Unreal mode howto?

Posted: Tue Jul 05, 2005 2:21 am
by Pype.Clicker
i don't know what FASM is exactly able of, but with other assemblers i've experienced, you have a "listing output" mode that allows you to see what exactly is assembled (e.g. after inclusion, macro processing and the like).

That listing mode could help you to spot something you might miss (like a USE [...], ORG [...] BITS [...] SEGMENT [...] directive or whatever).