Anyone to help with protected mode programming,like help me create a a data descriptor pointing to 0b800h when i try to write to RAM it rebbots

Protected mode does not have access to real mode addresses. You have to switch back to real mode to access it. Yes its a pain in the butt. How to do it? I don't know, all I know is what I've read from documentation of dos extenders such as Phar Lap. Unfortunately when MS-DOS died so did many other companies such as Phar Lap.

heya why is it that wen i switch back to real mode i cant access real mode interrupts even when i never modified anythang like for instance this code
mov EAX,CR0
OR AL,0H
MOV CR0,EAX;THEN SWITCH BACK TO REAL MODE
MOV EAX,CR0
AND AL,10B
MOV CR0,EAX
;THEN INT 10H
MOV AX,3H
INT 10H
;THEN MY PROGRAM DOESNT RESPOND PLS HEL-P

Oh, No The
Or Al,1h ;not 0h Sorry

for the GDT , decide what selector to use, e.g. 00098h , whatever. then
create the descriptor in the GDT for that selector , as follows
dw limit1 0ffffh
dw base1 08000h
db base2 00bh
db type1 09ah
db limit2 000h
db base3 000h
now 0b800h is a segment value for text video and should be interpreted as 0b8000h as a 32-bit linear address and video is a data segment
try this and see how you go

Segmentation Unit-->Linear Address-->Paging Unit-->Physical Address

As long as the paging unit and MMU are off, Linear Addresses
should map to physical.

To turn a 16-bit segment address into a 32-bit linear address do:
mov bx, 0b800h
movzx eax, bx
shl eax, 4
; eax now contains linear address

The only difference when accessing physical addresses
in protected mode from real-mode,
is that in real mode a physical address is represented
by a segment:offset pair.
whereas in protected mode a single 32-bit value can be used.

How to switch back into realmode:
It think this should cover what must be done:
Before clearing the PE bit of the CR0 register, and
going back into Real-Mode.
(PE stands for Protected-Mode Enable Bit)
Clear the Interrupt-Enable flag, the 16-bit FLAGS
should be equivalent to the Real-Mode FLAGS.
And set up a IVT at physical address 00000.

A return to real-mode is done simply by clearing
the PE bit of the CR0 register.
On 80286 processors, a CPU reset is required.

heya why is it that wen i switch back to real mode i cant access real mode interrupts even when i never modified anythang like for instance this code
mov EAX,CR0
OR AL,0H
MOV CR0,EAX;THEN SWITCH BACK TO REAL MODE
MOV EAX,CR0
AND AL,10B
MOV CR0,EAX
;THEN INT 10H
MOV AX,3H
INT 10H
;THEN MY PROGRAM DOESNT RESPOND PLS HEL-P

Here is some code to do the actual switching of pmode but you
need the GDT and IDT set up prior. It also loads the Task register and LDT registers as well for use with TSS's - but just follow the flow of the code loading all the the segments to initialise them

EnterPmode1 PROC NEAR
PUSHFD
CLI
PUSHAD
; SAVE THE REALMODE GDT AND IDT
SGDT DS:[Pm1Data1].RMGDTR1
SIDT DS:[Pm1Data1].RMIDTR1
; SET THE PROTECTED MODE GDT AND IDT
LGDT DS:[Pm1Data1].PMGDTR1
LIDT DS:[Pm1Data1].PMIDTR1
; DO THE SWITCH TO PMODE
MOV EAX, CR0
AND EAX, 07FFFFFFFh
OR EAX, 000000001h
MOV CR0, EAX
; FAR JUMP TO LOAD CS SELECTOR VALUE AND FLUSH INSTRUCTIONS
DB 0EAh
DW OFFSET CS:LxJmp1
DW CURRENTCODESEGMENTSELECTOR
LxJmp1: MOV AX, CURRENTDATASEGMENTSELECTOR
MOV DS, AX
MOV ES, AX
MOV FS, AX
MOV AX, CURRENTSTACKSEGMENTSELECTOR
MOV SS, AX
MOVZX ESP, SP
MOV AX, FLAT32SELECTOR
MOV GS, AX
; LOAD TASK REGISTER - MAKE SURE NOT NULL OR SKIP
CMP DS:[Pm1Data1].PMTR1.WORD1, 00000h
JZ LxPmSkip1
MOV SI, DS:[Pm1Data1].PMTR1.WORD1
AND ESI, 00000FFF8h
ADD ESI, DS:[Pm1Data1].PMGDTR1.GDTR1BASE1
AND GS:[ESI].GDT1TYPE1, 0FDh
LTR DS:[Pm1Data1].PMTR1.WORD1
LxPmSkip1: LLDT DS:[Pm1Data1].PMLDT1.WORD1
POPAD
POPFD
RET
EnterPmode1 ENDP

LeavePmode1 PROC NEAR
PUSHFD
CLI
PUSHAD
; SAVE THE OLD STUFF - OPTIONAL
SLDT DS:[PmData1].PMLDT1
STR DS:[Pm1Data1].PMTR1
SGDT DS:[Pm1Data1].PMGDTR1
SIDT DS:[Pm1Data1].PMIDTR1
; RESET TO POINT TO REAL MODE VALUES
LGDT DS:[Pm1Data1].RMGDTR1
LIDT DS:[Pm1Data1].RMIDTR1
; CLEAR PAGING AND PMODE
MOV EAX, CR0
AND EAX, 07FFFFFFEh
MOV CR0, EAX
DB 0EAh ; FAR JUMP LOADING THE CS SEGMENT
DW OFFSET CS:LxJmp1
DW SEG CURRENTCODESEGMENT
LxJmp1: MOV AX, CURRENTDATASEGMENT
MOV DS, AX
MOV ES, AX
MOV FS, AX
MOV AX, CURRENTSTACKSEGMENT
MOV SS, AX
XOR AX, AX
MOV GS, AX
POPAD
POPFD
RET
LeavePmode1 ENDP

"Segmentation Unit-->Linear Address-->Paging Unit-->Physical Address

As long as the paging unit and MMU are off, Linear Addresses
should map to physical."
--> And also a flat-memory model is chosen.
When a flat memory model is chosen and the above
conditions are true, a single 32-bit offset can be used
to access any physical address.

A single segment descriptor can be used to map the
entire 4GB of linear address space.

The 80286 has 24 addressing pins and can address 16MB.
The 80386+ has 32 addressing pins and can address 4GB.

another thing also with pmode is that when switching back to real mode any 16 bit segments that are used should have their limits set to full 64k for the segment limit, i.e. 0FFFFh, otherwise the pc will hang or reboot
and also disable any interrupts during pmode switching , etc, hope this helps

Anyone to help with protected mode programming,like help me create a a data descriptor pointing to 0b800h when i try to write to RAM it rebbots

yes that is because you havent set up protected mode properly, it resets on triple fault. give me upto tomorrow ill give you a good working protected mode...

commented: No need to rush for tomorrow, the OP posted that over TWO YEARS AGO!!!! -4

Thanx all of you for this gr8 information!!!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.