flat assembler
Message board for the users of flat assembler.
Index
> DOS > problem with unREAL mode fasm Goto page Previous 1, 2, 3, 4, 5 Next |
Author |
|
revolution 08 Feb 2008, 16:14
I thought the topic is about unREAL mode, how is it related to XP?
|
|||
08 Feb 2008, 16:14 |
|
DJ Mauretto 08 Feb 2008, 16:38
Marijuana you smoke seems good, I want also
|
|||
08 Feb 2008, 16:38 |
|
bitRAKE 08 Feb 2008, 16:40
It is fastinating to me that System Management Mode is like unreal mode. Makes me wonder if that is the native state of the CPU and protected mode is the abstraction (ie slower)?
|
|||
08 Feb 2008, 16:40 |
|
System86 09 Feb 2008, 02:30
Unreal has the advantage over protected mode that you can directly call DOS/BIOS interrupts from it (without switching back to RM or VM86 mode for every call).
|
|||
09 Feb 2008, 02:30 |
|
revolution 09 Feb 2008, 03:36
System86 wrote: Unreal has the advantage over protected mode that you can directly call DOS/BIOS interrupts from it (without switching back to RM or VM86 mode for every call). |
|||
09 Feb 2008, 03:36 |
|
System86 09 Feb 2008, 18:54
Quote:
Ok, maybe not the 32-bit unreal mode that fasm uses, but plain FRM (16-bit code, with 4 GB segment limits) is compatible with DOS/BIOS, I made a FRM program and it did not need to thunk back to true real mode for every DOS call. |
|||
09 Feb 2008, 18:54 |
|
bitRAKE 09 Feb 2008, 22:45
http://en.wikipedia.org/wiki/System_Management_Mode
http://www.rcollins.org/ddj/Jan97/Jan97.html Quote: After the microprocessor state has been stored to memory, the special SMM handler begins to execute. The processor is in real mode, all segments have 4-GB limits, and all segments are read/writable. |
|||
09 Feb 2008, 22:45 |
|
edfed 10 Feb 2008, 00:57
yes, at boot time, the hidden descriptors are set to limit = 64k
when switching to prtected mode, we can change the limits and return to real mode, limits are then the ones sets by pm. |
|||
10 Feb 2008, 00:57 |
|
Polygon 10 Feb 2008, 11:26
That is exactly what I want to do. I've generated the "flatmode" sub from many examples here and around the Internet, but I'm missing something, as it's not setting the address space to 4gig. Can anyone see what's wrong with the code?
Code: use16 pushfd ; Push Flags Register onto the Stack (use 32) push eax push ebx push edx call flatmode ; first, set up FS to access all 4G mov eax,080000048h ; (G)MCH Base Address Register mov dx,0CF8h ; set port address out dx,eax ; send address through the port mov dx,0CFCh ; set port data in eax,dx ; fetch data mov ebx,eax ; save the old value or eax,1 ; increase data by new setting out dx,eax ; send data through port data and ebx,0FFFFC000h ; mask off bits 31:14 inclusive add ebx,250h ; point to the relevant part mov ax,[fs:ebx] ; fetch data at 250h address and ax,07FFh ; set Tras data bit to zero or ax,9000h ; copy data for Tras 18T mov [fs:ebx],ax ; send data with 18T change pop edx pop ebx pop eax popfd ; Pop Stack into Eflags Register retf ; Return Far from Procedure ;---------------------------------------------------------------------- flatmode: ; first, calculate the linear address of GDT xor edx,edx ; clear edx xor eax,eax ; clear edx mov dx,ds ; get the data segment shl edx,4 ; shift it over a bit cli ; turn off interrupts add [cs:dword GDT+2],edx ; store as GDT linear base addr ; now load the GDT into the GDTR lgdt fword ptr cs:GDT ; load GDT base (286-style 24-bit load) mov bx,8 ;1 * size DESC386 ; point to first descriptor mov eax,cr0 ; prepare to enter protected mode or al,1 ; flip the PE bit mov cr0,eax ; we're now in protected mode mov fs,bx ; load the FS segment register mov ds,bx ; mov es,bx ; mov gs,bx ; mov ss,bx ; load the SS segment register and al,0FEh ; clear the PE bit again mov cr0,eax ; back to real mode sti ; resume handling interrupts ret ; ;---------------------------------------------------------------------- GDT: dw 000fh ; limit low dw GDT ; base lo db 0 ; base mid db 0 ; dpltype db 0 ; lim hi db 0 ; base hi ; this is the setup for the 4G segment dw 0ffffh ; limit low dw 0 ; base lo db 0 ; base mid db 092h ; dpltype db 0cfh ; lim hi db 0 ; base hi GDT_END: |
|||
10 Feb 2008, 11:26 |
|
revolution 10 Feb 2008, 11:30
After this:
Code: mov cr0,eax ; we're now in protected mode TFM wrote: Immediately following the MOV CR0 instruction, execute a far JMP or far CALL |
|||
10 Feb 2008, 11:30 |
|
Polygon 10 Feb 2008, 12:12
Thanks! I'm a little new to assembly, could you give me a little example please. Can it be a jump to just a return in the same code?
|
|||
10 Feb 2008, 12:12 |
|
revolution 10 Feb 2008, 12:34
The answer is written above: (This operation is typically a far jump or call to the next instruction in the instruction stream.)
|
|||
10 Feb 2008, 12:34 |
|
Polygon 10 Feb 2008, 12:48
Thanks, but being new to assembly, I don't know how to do a far jump to the next instruction. This won't compile:
Code: mov cr0,eax ; back to real mode jmp far next next: sti ; resume handling interrupts ret |
|||
10 Feb 2008, 12:48 |
|
revolution 10 Feb 2008, 12:53
jmp seg:offset
eg. jmp 8:next |
|||
10 Feb 2008, 12:53 |
|
Polygon 10 Feb 2008, 12:56
This does compile. Thanks!:
Code: mov cr0,eax ; back to real mode jmp dword next next: sti ; resume handling interrupts ret |
|||
10 Feb 2008, 12:56 |
|
Polygon 10 Feb 2008, 12:59
As does this. Thanks again:
Code: jmp 8:next next: sti ; resume handling interrupts ret |
|||
10 Feb 2008, 12:59 |
|
revolution 10 Feb 2008, 13:00
jmp dword next won't work, it is a near jump.
|
|||
10 Feb 2008, 13:00 |
|
Polygon 10 Feb 2008, 13:08
Yes, I see that now. I compiled both and then disassembled both, and I see the problem. Thanks, my friend
|
|||
10 Feb 2008, 13:08 |
|
bitRAKE 10 Feb 2008, 16:38
Code: 2E 0F 01 16 0A 35 lgdt fword [cs:350Ah] 0F 20 C0 mov eax, cr0 0C 01 or al, 1 0F 22 C0 mov cr0, eax EB 00 jmp short $+2 B8 10 00 mov ax, 10h 8E D0 mov ss, ax 0F 20 C0 mov eax, cr0 24 FE and al, 0FEh 0F 22 C0 mov cr0, eax EA 1F 10 86 E8 jmp far [0E886h:101Fh] Of course, this limits code execution to previously cached CS descriptor limits, usually the first meg of memory. I'm just showing it as a further example (and to say "Hi" to Polygon ). |
|||
10 Feb 2008, 16:38 |
|
Goto page Previous 1, 2, 3, 4, 5 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.