Hi.The following program shows switching from RM to PM and back.At the end it has to print "Hello".The problem is it doesn't show the message.
Can anybody help me.Thank you.
P.S. For compilation use these commands:
tasm /m name.asm
tlink /x /3 name.asm

Here is my code

data segment 'data' use16
message db 'H',7,'e',7,'l',7,'l',7,'o',7
GDT label byte
db 8 dup(0)
GDT_flatCS db 0FFh,0FFh,0,0,0,10011010b,11001111b,0
GDT_flatDS db 0FFh,0FFh,0,0,0,10010010b,11001111b,0
GDT_16bitCS db 0FFh,0FFh,0,0,0,10011010b,0,0
GDT_16bitDS db 0FFh,0FFh,0,0,0,10010010b,0,0
gdtr dw GDT_1-1
dd ?
data ends

RM_seg segment para public 'code' use16
assume CS:RM_seg,SS:RM_stack,ds:data
mov ax,data
mov ds,ax
in al,92h
or al,2
out 92h,al
xor eax,eax
mov ax,PM_seg
shl eax,4
add eax,offset PM_entry
mov dword ptr cs:pm_entry_off,eax
xor eax,eax
mov ax,ds
shl eax,4
push eax
mov word ptr GDT_16bitDS+2,ax
shr eax,16
mov byte ptr GDT_16bitDS+4,al
xor eax,eax

mov ax,cs
shl eax,4
mov word ptr GDT_16bitCS+2,ax
shr eax,16
mov byte ptr GDT_16bitCS+4,al
pop eax
add eax,offset GDT
mov dword ptr gdtr+2,eax
lgdt fword ptr gdtr
in al,70h
or al,80h
out 70h,al
mov eax,cr0
or al,1
mov cr0,eax
db 66h
db 0EAh
pm_entry_off dd ?
dw SEL_flatCS
mov eax,cr0
and al,0FEh
mov cr0,eax
db 0EAh
dw $+4
dw RM_seg
in al,70h
and al,07FH
out 70h,al
mov ah,0
int 16h
mov ah,4Ch
int 21h
SEL_flatCS equ 00001000b
SEL_flatDS equ 00010000b
SEL_16bitCS equ 00011000b
SEL_16bitDS equ 00100000b
RM_seg ends

PM_seg segment public 'CODE' use32
assume cs:PM_seg
mov ax,SEL_16bitDS
mov ds,ax
mov ax,SEL_flatDS
mov es,ax
mov edi,0B8000h
mov ecx,rest_scr
mov ax,720h
rep stosw
mov esi,offset message
mov edi,0B8500h
mov ecx,message_1
rep movsb
db 0EAh
dd offset RM_return
dw SEL_16bitCS
PM_seg ends

RM_stack segment stack 'STACK' use16
db 100h dup(?)
RM_stack ends
end start

I don't know what is wrong with your code,
I didn't take a long look at it, I am used to staring at 16-bit code.
I noticed you are using the linear address of the color video
ram 000B8000, I do not know why your message wouldn't
be being displayed.
But I have some questions myself about your code as I am
interested in switching to and from protected mode as well.
I noticed your code is refering to 32-bit registers before setting
bit 1 (PE bit) of the CR0 register, how is that being done?
And where did you get a good description of the GDT descriptor
format can you point me to some good documentation???
Thanks in advance and good luck!

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.