i have a kernel in protected mode and want to set up a gdt, so i read the gdt tutorial and tried to put the code pieces i was given there together. Until now, it didn't work. Since i only know at&t syntax assembly language, and the examples of the tutorial are in intel, i had to convert them first.
I think the reason for my gdt-load to not work lies in the conversion part of the code, but i don't know where.
These are the assembly pieces i converted:
This
Code: Select all
gdtr DW 0 ; For limit storage
DD 0 ; For base storage
setGdt:
MOV EAX, [esp + 4]
MOV [gdtr + 2], EAX
MOV AX, [ESP + 8]
MOV [gdtr], AX
LGDT [gdtr]
RET
Code: Select all
gdtr:
limit: .word 0 # For limit storage
base: .long 0 # For base storage
.globl setGdt
setGdt:
movl 4(%esp), %eax
movl %eax, base
movw 8(%esp), %ax
movw %ax, gdtr
lgdt gdtr
ret
Code: Select all
reloadSegments:
; Reload CS register containing code selector:
JMP 0x08:reload_CS ; 0x08 points at the new code selector
.reload_CS:
; Reload data segment registers:
MOV AX, 0x10 ; 0x10 points at the new data selector
MOV DS, AX
MOV ES, AX
MOV FS, AX
MOV GS, AX
MOV SS, AX
RET
Code: Select all
.globl reloadSegments
reloadSegments:
# Reload CS register containing code selector:
ljmp $0x08, $reload_CS # 0x08 points at the new code selector
reload_CS:
# Reload data segment registers:
movw $0x10, %ax # 0x10 points at the new data selector
movw %ax, %ds
movw %ax, %es
movw %ax, %fs
movw %ax, %gs
movw %ax, %ss
ret
Thanks in advance, mittwoch