Code: Select all
org 0x1000
[BITS 16]
; ------ Disable protected mode; jump to real-mode segment.
main:
.2:
mov eax, cr0
and eax, 0xFE
mov cr0, eax
jmp word 0x00:.3
; ------ Load stack- and data-segment registers
; ------ with proper real-mode segment numbers.
.3: xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
; ------ Enable A20 line (and thus high memory).
; ------ [http://www.karig.net/0003.html]
mov al, 0xD1
out 0x64, al
mov al, 0x03
out 0x60, al
sti
testcode:
mov ax,4F02h ; Set VBE Mode
mov bx,0C100h ; Mode : 640x400, 256 colours, linear/flat, don't clear display
int 10h ; Do it!
; ------ Halt computer.
jmp $
Code: Select all
testrealmode:
cli
; ------ Ensure that code- and stack-segment limits are 64KB.
mov eax, ds16
mov ss, eax
jmp dword cs16:0x1000
retn
bochs debug:
Code: Select all
(0) [0x00001000] 0038:00001000 (unk. ctxt): mov eax, cr0 ; 0f20c0
(0) [0x00001003] 0038:00001003 (unk. ctxt): opsize and eax, 0xfe ; 6625fe00
0000
(0) [0x00001009] 0038:00001009 (unk. ctxt): mov cr0, eax ; 0f22c0
(0) [0x0000100c] 0038:100c (unk. ctxt): jmp 0000:1011 ; ea11100000
(0) [0x00001011] 0000:1011 (unk. ctxt): xor ax, ax ; 31c0
(0) [0x00001013] 0000:1013 (unk. ctxt): mov ds, ax ; 8ed8
(0) [0x00001015] 0000:1015 (unk. ctxt): mov es, ax ; 8ec0
(0) [0x00001017] 0000:1017 (unk. ctxt): mov fs, ax ; 8ee0
(0) [0x00001019] 0000:1019 (unk. ctxt): mov gs, ax ; 8ee8
(0) [0x0000101b] 0000:101b (unk. ctxt): mov ss, ax ; 8ed0
(0) [0x0000101d] 0000:101d (unk. ctxt): mov al, 0xd1 ; b0d1
(0) [0x0000101f] 0000:101f (unk. ctxt): out 0x64, al ; e664
(0) [0x00001021] 0000:1021 (unk. ctxt): mov al, 0x3 ; b003
(0) [0x00001023] 0000:1023 (unk. ctxt): out 0x60, al ; e660
(0) [0x00001025] 0000:1025 (unk. ctxt): sti ; fb
(0) [0x00001026] 0000:1026 (unk. ctxt): mov ax, 0x4f02 ; b8024f
(0) [0x00001029] 0000:1029 (unk. ctxt): mov bx, 0xc100 ; bb00c1
(0) [0x00000524] 0018:03a4 (unk. ctxt): add byte ptr ds:[bx+si], al ; 0000
(0) [0x00000526] 0018:03a6 (unk. ctxt): add byte ptr ds:[bx+si], al ; 0000
========================================================================
Bochs is exiting with the following message:
[CPU ] CPU shutting down due to lack of stack space, SP==1
========================================================================