Code: Select all
%macro inlinePM 0
cli
; /* disable NMIs as well */
in al, 0x70
or al, 0x80
out 0x70, al
call setup_GDT
call setup_IDT
mov ax, cx
mov [old_CS], ax
mov ax, ds
mov [old_DS], ax
mov ax, ss
mov [old_SS], ax
; mov ax, sp
; mov [old_SP], ax
; /* WOW!!! This switches us to PMode just setting up CR0.PM bit to 1 */
invk read_cr0 ; ; return dx:ax
or ax, 1
invk write_cr0, eax
; /* loading segment registers with PMode selectors */
invk update_cs, 0x8
mov ax, 0x10
mov ds, ax
mov es, ax
mov ax, 0x18
mov ss, ax
%endmacro
OFFSETHERE MOV SS AX...
mov ss,ax
Code: Select all
%macro OFFSETHERE 1
%%__here__
%assign _here_3455342 %%__here__ -$$
%error [_here_3455342] %1
%endmacro
I have in my code some like (compact form I guess):
Code: Select all
jmp start2
......
......
%macro inlinePM 0
.......
%endmacro
setup_pmode:
inlinePM
ret
.......
start2:
cli ; please no interupts
mov ax,cs
mov ds,ax
mov es,ax ; es same as ds
mov ax,09000h ; segment for stack
OFFSETHERE MOV SS AX...
mov ss,ax
OFFSETHERE MOV SP 0XF800...
mov sp,0F800h ; offset for stack
sti ; enable ints again
push bp
mov bp, sp
inlinePM ;this work OK but if
call setup_pmode ; I replace the anterior with this, dosent work.
.....
I think above values will be of use for the next???t1.asm:402: warning: (OFFSETHERE:3) [1535] MOV SS AX...
t1.asm:404: warning: (OFFSETHERE:3) [1537] MOV SP 0XF800...
This is the error by bochs when I use the call setup_pmode:
Code: Select all
00000648900p[CPU ] >>PANIC<< load_seg_reg: GDT: SS: index(1200*8+7) > limit(000027)
00000648900i[SYS ] Last time is 1116777734
00000648900i[CPU ] protected mode
00000648900i[CPU ] CS.d_b = 16 bit
00000648900i[CPU ] SS.d_b = 16 bit
00000648900i[CPU ] | EAX=60009000 EBX=00000001 ECX=000b0001 EDX=00000000
00000648900i[CPU ] | ESP=0000f7fe EBP=0000f7fe ESI=00000596 EDI=000000a0
00000648900i[CPU ] | IOPL=0 NV UP DI PL NZ NA PE NC
00000648900i[CPU ] | SEG selector base limit G D
00000648900i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00000648900i[CPU ] | DS:0008( 0001| 0| 0) 00010000 0000ffff 0 0
00000648900i[CPU ] | ES:0008( 0001| 0| 0) 00010000 0000ffff 0 0
00000648900i[CPU ] | FS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00000648900i[CPU ] | GS:b800( 0000| 0| 0) 000b8000 0000ffff 0 0
00000648900i[CPU ] | SS:0018( 0003| 0| 0) 00010000 0000ffff 0 0
00000648900i[CPU ] | CS:0008( 0001| 0| 0) 00010000 0000ffff 0 0
00000648900i[CPU ] | EIP=00000601 (000005ff)
00000648900i[CPU ] | CR0=0x60000011 CR1=0x00000000 CR2=0x00000000
00000648900i[CPU ] | CR3=0x00000000 CR4=0x00000000
00000648900i[ ] restoring default signal behavior
00000648900i[CTRL ] quit_sim called with exit code 1
Code: Select all
call setup_pmode
mov ss, ax
Only a last question, in bochs... what mean
00000648900i[CPU ] | EIP=00000601 (000005ff)