Unreal Mode: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Syntax higlighting
Played with comments
Line 23: Line 23:
; partcopy boot.bin 0 200 -f0
; partcopy boot.bin 0 200 -f0


[ORG 0x7c00] ; add to offsets
[ORG 0x7c00] ; add to offsets


start: xor ax, ax ; make it zero
start: xor ax, ax ; make it zero
mov ds, ax ; DS=0
mov ds, ax ; DS=0
mov ss, ax ; stack starts at 0
mov ss, ax ; stack starts at seg 0
mov sp, 0x9c00 ; 200h past code start
mov sp, 0x9c00 ; 200h past code start


cli ; no interrupt
cli ; no interrupts
push ds ; save real mode
push ds ; save real mode


lgdt [gdtinfo] ; load gdt register
lgdt [gdtinfo] ; load gdt register


mov eax, cr0 ; switch to pmode by
mov eax, cr0 ; switch to pmode by
or al,1 ; set pmode bit
or al,1 ; set pmode bit
mov cr0, eax
mov cr0, eax


mov bx, 0x08 ; select descriptor 1
mov bx, 0x08 ; select descriptor 1
mov ds, bx ; 8h = 1000b
mov ds, bx ; 8h = 1000b


and al,0xFE ; back to realmode
and al,0xFE ; back to realmode
mov cr0, eax ; by toggling bit again
mov cr0, eax ; by toggling bit again


pop ds ; get back old segment
pop ds ; get back old segment
sti
sti


mov bx, 0x0f01 ; attrib/char of smiley
mov bx, 0x0f01 ; attrib/char of smiley
mov eax, 0x0b8000 ; note 32 bit offset
mov eax, 0x0b8000 ; note 32 bit offset
mov word [ds:eax], bx
mov word [ds:eax], bx


jmp $ ; loop forever
jmp $ ; loop forever


gdtinfo:
gdtinfo:
Line 58: Line 58:
dd gdt ;start of table
dd gdt ;start of table


gdt dd 0,0 ; entry 0 is always unused
gdt dd 0,0 ; entry 0 is always unused
flatdesc db 0xff, 0xff, 0, 0, 0, 10010010b, 11001111b, 0
flatdesc db 0xff, 0xff, 0, 0, 0, 10010010b, 11001111b, 0
gdt_end:
gdt_end:


times 510-($-$$) db 0 ; fill sector w/ 0's
times 510-($-$$) db 0 ; fill sector w/ 0's
db 0x55 ; req'd by some BIOSes
db 0x55 ; req'd by some BIOSes
db 0xAA
db 0xAA
</source>
</source>