Help with switching to protected mode GDT AT&T assembly!!!!
Hello people,
This is starting to drive me crazy. I'm not sure this is the appropriate forum but i'll give it a shot. I've been trying to create my own operating system and for that I need to be able to load the GDT and i'm having a little bit of a problem figuring things out using AT&T syntax. Could anybody help me out.
I don't think i'm do the far jump correctly. I know i'm switching the PE bit correctly. I'm not sure i'm loading the GDT correctly.
This is what i have so far:
.org 0x0000
.code16 # We compile the code in 16 bits mode
.globl _start
_start:
cli
movw $0x7C0, %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 0x0800
.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
jmp . # We stay right here
.fill 0x1FE - ( . - START ), 1, 0
.byte 0x55
.byte 0xAA
This lil bit of code is dd written to the first sector of a floppy disk so it's booted up in 0x07C00; I understand the 20 bits addressing and the 4 bit shift to the left to calculate Real addresses from a segment and an offset (segment*16+offset). I guess i'm having a little bit of trouble with AT&T and what the GAS compiler does and doesn't do. I've tried many things but nothing seems to work. I get a triple fault (automatic reboot) every time i boot up the computer with floppy. Help!!! Going nuts here!!!
Thanks in advance
aXoneX
|