I am working on pmode switching and using the video memory buffer (since bios interrupts are not available) for printing some junk chars.
To this matter, I have found some code example which I am trying to play with.
The problem I have is that it seems nothing is happening when I am writing just after 0xB8000... However, If I put a loop around the mov call to the video buffer, my string is displayed correctly (but this is not how it is supposed to work!)
Is this code missing something?
Thanks.
The code is built & run like this:
as -o main.o main.S
ld -Ttext 0x7c00 --oformat binary -o main.img main.o
qemu -fda main.img
Code: Select all
.org 0x0
.code16
.globl _start
.set LOAD, 0x7c00 # BIOS loads and jumps here
.set MAGIC, 0xaa55 # Must be at the end of the 512-byte block
.set BLOCKSIZE, 512 # Boot block is BLOCKSIZE bytes long
_start:
cli
movw $0, %ax
movw %ax, %ds
movl $0x00000000, 0x800
movl $0x00000000, 0x804
movl $0x0000FFFF, 0x808 # Data segment descriptor
movl $0x00CF9200, 0x80C # read/write
movl $0x0000FFFF, 0x810 # Code segment descriptor
movl $0x00CF9800, 0x814 # execute/read
lgdt gdt_reg
movl %cr0, %eax
or $0x01, %al
movl %eax, %cr0
jmp $0x10, $start32
gdt_reg:
.word 0x0017
.long 0x00000800
.code32 # This part is compiled in 32 bits mode
start32:
movw $0x8, %ax # We set up %ds and %ss pointing on the Data segment
movw %ax, %ds
movw %ax, %ss
movb $0x5A, 0xB8A00
movb $0x57, 0xB8A01
movb $0x5A, 0xB8A02
movb $0x04, 0xB8A03
movb $0x5A, 0xB8A04
movb $0x0A, 0xB8A05
movb $0x5A, 0xB8A06
movb $0x62, 0xB8A07
movb $0x5A, 0xB8A08
movb $0x0E, 0xB8A09
//jmp start32 // Stupid, but reveals the string.
cli
hlt
.org BLOCKSIZE - 2, 0
.word MAGIC