Code: Select all
;this code switches to flat real mode or "unreal" mode
;only affects fs and gs for compatibiltiy purposes
;this code was modified for use with tasm
Hmmm, you could have mentioned this earlier, I actually thought we were talking about normal flat mode which is pmode with zero based descriptors..
Code: Select all
gdt
DESC386 <GDT_END - gdt - 1, gdt, 0, 0, 0, 0>
DESC386 <0ffffh, 0, 0, 091h, 0ffh, 0>
GDT_END:
I'd change the last 0xff in your data descriptor to 0xcf as one of the bits according to the intel reference manual has to be zero, otherwise problems with older CPUs might occure.
Table in the intel manual
I tried code nearly exactly like that but it didnt work, it just put a weird character in a random spot in video memory(i was trying to write a character to 0b8000h)
Hard to say what went wrong without knowing the parameters you passed to the poke procedure. It should actually work if 'linear' is 0xB800, but I'm really wondering what's the advantage over normal real-mode then. I've adapted your procedure to use a zero based segment and a 32bit address in esi to access the memory:
Code: Select all
void pokeb32(dword linear, byte dat)
{
asm push eax
asm push esi
asm mov esi, linear
asm mov al, dat
asm mov [gs:esi], al
asm pop esi
asm pop eax
}
Note that you'd have to enable the a20 line-gate first before accessing anything above 1MB though..
well isnt the bit being 1 mean 4kb and the bit being 0 byte
Yep, I just got you wrong, thought "1(kb)" would mean "one kilo-byte grnualrity" and not the state of the bit.
hmmm ok i thought it meant you could have like 32 bits in segment register but offset stayed 16bit
The advantage of unreal-mode over normal real-mode is that it allows offsets of up to 4gb and therefore enables you to span the whole address-space. The segments therefore get somewhat useless which is why you'd normally just set their base to zero (flat real-mode) and do addressing with offsets only.
What remains 16bits are the instructions which might lead to some problems unless you use overrite prefixes.
osdfaq article for unreal-mode
brief tutorial
chis giese's tutorial (pm1.asm)
Note that I'll be away from tomorrow on so that I can't answer to any further questions..
regads,
gaf