PM to RM to PM to RM
-
jason7007
PM to RM to PM to RM
Hi,
Is Unreal mode supported in AMD processors? Would it be possible
to switch to Protected Mode then back to Real Mode then switch again to Protected Mode in many times as neccessary?
Thanks in advance.
Is Unreal mode supported in AMD processors? Would it be possible
to switch to Protected Mode then back to Real Mode then switch again to Protected Mode in many times as neccessary?
Thanks in advance.
Re:PM to RM to PM to RM
Yes, that's possible on any system that supports protected mode.
On old systems you have to perform a soft reboot, on new systems you can just switch back & forth.
On old systems you have to perform a soft reboot, on new systems you can just switch back & forth.
Re:PM to RM to PM to RM
Hi,
While you can switch back & forth between protected mode and real mode, there's big problems with IRQs - when you're in real mode the protected mode IRQ handlers don't get the IRQs, and if you're using BIOS routines in real mode there's no way to reliably disable the IRQs. There are ways around that though - e.g. make sure you don't need to reprogram the PIC chips during a mode switch and have dummy real mode IRQ handlers that set flags that are checked when you switch back to protected mode (IRQ latency is the problem then).
In general, virtual 8086 mode is a better way to do it (if real mode code has to be used at all, but that's another question entirely).
Cheers,
Brendan
Yes - for 80286 there was no way to get out of protected mode, so you had to reset the CPU using the chipset/BIOS...Candy wrote:Yes, that's possible on any system that supports protected mode.
On old systems you have to perform a soft reboot, on new systems you can just switch back & forth.
While you can switch back & forth between protected mode and real mode, there's big problems with IRQs - when you're in real mode the protected mode IRQ handlers don't get the IRQs, and if you're using BIOS routines in real mode there's no way to reliably disable the IRQs. There are ways around that though - e.g. make sure you don't need to reprogram the PIC chips during a mode switch and have dummy real mode IRQ handlers that set flags that are checked when you switch back to protected mode (IRQ latency is the problem then).
In general, virtual 8086 mode is a better way to do it (if real mode code has to be used at all, but that's another question entirely).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
-
chasetec
Re:PM to RM to PM to RM
Here is some RMode->PMode->RMode->PMode->RMode code. It's a DOS Com binary executable in NASM syntax that I wrote for a completely different subject but it should be easy enough to understand. http://www.osdev.org/howtos/1/loader.asm.jason7007 wrote: Hi,
Is Unreal mode supported in AMD processors? Would it be possible
to switch to Protected Mode then back to Real Mode then switch again to Protected Mode in many times as neccessary?
-
jason7007
Re:PM to RM to PM to RM
Hi,
Thank you so much for the information.
Anyone had tried switching to Unreal mode using AMD processor?
Did it work?, I cannot test my Unreal mode code, because my computer is Intel based. I will abandon Unreal mode coding if it does not work on AMD chips.
Thank you again
Thank you so much for the information.
Anyone had tried switching to Unreal mode using AMD processor?
Did it work?, I cannot test my Unreal mode code, because my computer is Intel based. I will abandon Unreal mode coding if it does not work on AMD chips.
Thank you again
Re:PM to RM to PM to RM
AFAIK, unreal mode is a quirk that is fully required by the specs, required to boot up properly even. So, unless I'm mistaking, you can use it on both Intel, AMD, Cyrix, Rise and any other processor vendor that is x86 compatible.
[note] of course not Intel Arm, AMD Geode etc. processors, but the x86 procs from those vendors [/note]
[note] of course not Intel Arm, AMD Geode etc. processors, but the x86 procs from those vendors [/note]
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:PM to RM to PM to RM
There were games of Tran/Renaissance and even commercial games like "Ultima Underworld" that were known to run in unreal mode. They ran seamlessly on my AMD K6-II.
Maybe you want to tell us why you doubt so much unreal could work with AMD processors ?
Maybe you want to tell us why you doubt so much unreal could work with AMD processors ?
-
jason7007
Re:PM to RM to PM to RM
Hi,
Thank you so much.
But I almost perfected the Real Mode to Pmode to Real Mode to Pmode procedures. Also I will try to use V86 mode.
No more unreal mode which is limited to 64kb, right?
Thank you so much.
But I almost perfected the Real Mode to Pmode to Real Mode to Pmode procedures. Also I will try to use V86 mode.
No more unreal mode which is limited to 64kb, right?
Re:PM to RM to PM to RM
no, real mode has segment limits of 64kb. unreal mode can access all 4gb for data, but you can not run code above 1mb in unreal mode becasue of the cs:ip limit.
-
Ryu
Re:PM to RM to PM to RM
Actually technically you can. Segment registers may be limited at the fact they are 16bit registers but you can still have a valid cs:ip over 1MB. An exception may be generated in real mode I don't know, but I've tested on Bochs concerning a previous thread about exceptions being generated if IP goes beyong 0FFFFh and have successfully ran code beyond 1MB in unreal mode. As for the test if anyone was interested, the results was IP does not wrap around, it still ran my code without any exceptions being generated. But I'm not really sure on real hardware, or even on the 8086 if either exceptions or wrap around occurs.bubach wrote:but you can not run code above 1mb in unreal mode becasue of the cs:ip limit.
This is the Bochs output that shows EIP in 16bit mode did not wrap around (this means you can run code beyond 1MB):
Code: Select all
00032254400i[CPU0 ] real mode
00032254400i[CPU0 ] CS.d_b = 16 bit
00032254400i[CPU0 ] SS.d_b = 16 bit
00032254400i[CPU0 ] | EAX=00000010 EBX=00000000 ECX=00000014 EDX=00004150
00032254400i[CPU0 ] | ESP=00000f4c EBP=00000000 ESI=00009000 EDI=00001140
00032254400i[CPU0 ] | IOPL=0 ID vip vif ac vm rf nt of df if tf sf zf af pf cf
00032254400i[CPU0 ] | SEG selector base limit G D
00032254400i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00032254400i[CPU0 ] | CS:f014( 0002| 0| 0) 000f0140 000fffff 1 0
00032254400i[CPU0 ] | DS:0018( 0003| 0| 0) 00000000 000fffff 1 0
00032254400i[CPU0 ] | SS:0018( 0003| 0| 0) 00000000 000fffff 1 0
00032254400i[CPU0 ] | ES:0018( 0003| 0| 0) 00000000 000fffff 1 0
00032254400i[CPU0 ] | FS:0018( 0003| 0| 0) 00000000 000fffff 1 0
00032254400i[CPU0 ] | GS:0018( 0003| 0| 0) 00000000 000fffff 1 0
00032254400i[CPU0 ] | EIP=00010000 (00010000)
00032254400i[CPU0 ] | CR0=0x00000010 CR1=0 CR2=0x00000000
00032254400i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00032254400i[CPU0 ] >> 90
00032254400i[CPU0 ] >> : nop -
blip
Re:PM to RM to PM to RM
I did a test on an Intel Celeron P2 and it generated a GPF in real mode whenever any attempt was made to access code over the 64KB limit. I placed code at the end of the segment and the beginning of it and the next as well as setting up a GPF handler. It was the GPF handler that was invoked every time. The 8086 would not generate any exception since it only had divide error, trace, NMI, breakpoint, and overflow. Instead I think it would simply wrap around to the beginning of the segment.
Now you can execute code in the HMA but you must be sure that A20 stays enabled at all times.
Now you can execute code in the HMA but you must be sure that A20 stays enabled at all times.
Re:PM to RM to PM to RM
Actually, you'd need to trace one instruction further. This indicates that you can execute up to the 10000h line without gpf'ing, but we expected that. Also, you're doing this in bochs, which is usually but not always an accurate simulation of a real processor. It might even depend on steppings in processor subtypes, which makes generally using it not practical.Ryu wrote: This is the Bochs output that shows EIP in 16bit mode did not wrap around (this means you can run code beyond 1MB):Code: Select all
00032254400i[CPU0 ] real mode 00032254400i[CPU0 ] CS.d_b = 16 bit 00032254400i[CPU0 ] SS.d_b = 16 bit 00032254400i[CPU0 ] | EAX=00000010 EBX=00000000 ECX=00000014 EDX=00004150 00032254400i[CPU0 ] | ESP=00000f4c EBP=00000000 ESI=00009000 EDI=00001140 00032254400i[CPU0 ] | IOPL=0 ID vip vif ac vm rf nt of df if tf sf zf af pf cf 00032254400i[CPU0 ] | SEG selector base limit G D 00032254400i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D 00032254400i[CPU0 ] | CS:f014( 0002| 0| 0) 000f0140 000fffff 1 0 00032254400i[CPU0 ] | DS:0018( 0003| 0| 0) 00000000 000fffff 1 0 00032254400i[CPU0 ] | SS:0018( 0003| 0| 0) 00000000 000fffff 1 0 00032254400i[CPU0 ] | ES:0018( 0003| 0| 0) 00000000 000fffff 1 0 00032254400i[CPU0 ] | FS:0018( 0003| 0| 0) 00000000 000fffff 1 0 00032254400i[CPU0 ] | GS:0018( 0003| 0| 0) 00000000 000fffff 1 0 00032254400i[CPU0 ] | EIP=00010000 (00010000) 00032254400i[CPU0 ] | CR0=0x00000010 CR1=0 CR2=0x00000000 00032254400i[CPU0 ] | CR3=0x00000000 CR4=0x00000000 00032254400i[CPU0 ] >> 90 00032254400i[CPU0 ] >> : nop
As Blip has tested, it doesn't work on a P2 celeron (is that a mendocino or a spitfire?).
The 8086 would wrap around, but only because its registers and adders wouldn't be able to detect such an overflow (since they really only had 16 bits - and the processor in whole was implemented with pretty few transistors itself, so it's assumably true).
-
blip
Re:PM to RM to PM to RM
Candy: It's Mendocino, to be honest though I didn't know such designations existed until you asked and I pulled up a system info program.
And as Candy said, you need to try continuing execution at offset 10000h to see if Bochs throws an exception. Something similar happens on the test CPU when you make ESP > 65535 and try to use the stack when SS.limit is 64KB.
And as Candy said, you need to try continuing execution at offset 10000h to see if Bochs throws an exception. Something similar happens on the test CPU when you make ESP > 65535 and try to use the stack when SS.limit is 64KB.
-
Ryu
Re:PM to RM to PM to RM
Yes I would of expected the GPF on that case, however Bochs has a default limit of 0FFFFFh for CS, this is where I am confused. In my previous post, I was unsure if on real hardware and real mode would a valid CS:IP addressed over 1MB generate an exception.blip wrote: I did a test on an Intel Celeron P2 and it generated a GPF in real mode whenever any attempt was made to access code over the 64KB limit.
Ah okay, I still had my setup test from last night and added some nops which ran without exceptions(EIP=00010007). My test modifies code after a hlt instruction (where the Bochs outputs are) to a nop (i've also modified it with other opcodes to be sure). Which Bochs outputs the next instruction correctly so I was thinking that was enough. The main point it showed that it ran fine specifically in Bochs, unreal mode with a valid CS:IP and over 1MB.Candy wrote: Actually, you'd need to trace one instruction further. This indicates that you can execute up to the 10000h line without gpf'ing, but we expected that. Also, you're doing this in bochs, which is usually but not always an accurate simulation of a real processor. It might even depend on steppings in processor subtypes, which makes generally using it not practical.
To run code after wrap around/non wrapped around would be probably potentially unsafe anyways because of registers being loaded with 16bit values. This would probably rise another problem from my Bochs results, if the higher 16bit of EIP need to be zero'ed somehow to effectively address properly when you enter back under 1MB. Nevertheless I suppose you shouldn't run code over nonwrapped around cases but having to know if it generates an exception is more of the issue.
Hmm I don't think the 8086 can go into unreal mode in the first place because it doesn't know what is protected mode. I think I was meaning more on the 80286 which I believe have a 16bit limit in the descriptor rather then 32 bits. Oops.Candy wrote: The 8086 would wrap around, but only because its registers and adders wouldn't be able to detect such an overflow (since they really only had 16 bits - and the processor in whole was implemented with pretty few transistors itself, so it's assumably true).
-
JAAman
Re:PM to RM to PM to RM
yes, UMode is commonly refered to as a 'bug' in 386 CPUs that intel 'had to support' because of popularity (a lot of older games used it) but this isnt trueCandy wrote: AFAIK, unreal mode is a quirk that is fully required by the specs, required to boot up properly even. So, unless I'm mistaking, you can use it on both Intel, AMD, Cyrix, Rise and any other processor vendor that is x86 compatible.
[note] of course not Intel Arm, AMD Geode etc. processors, but the x86 procs from those vendors [/note]
UMode is in fact an intentional side effect of RMode simulation, and all CPUs (begining with the 386) begin execution in UMode (the BIOS then switches to PMode for its work, then into RMode to load the OS)
you cannot reliably use a non-RMode CS, because any interupt or call would crash the computer (as it would return to an invalid segment) -- even if you complied with all of the RMode requirements, after the first int (hard or soft), the CPU would iret, loading the segment selector, and looking up the hidden portion in the internal table -- causing it to load as a RMode segment, and returning to the wrong address