Having trouble with this GDT code snippet from the wiki.
Posted: Tue Aug 13, 2019 12:05 pm
I'm very new to OS development, I have just started my first real project about a week ago. I'm following the meaty skeleton guide, and so far I've gotten terminal scrolling, new lines, GRUB, etc. figured out. However, the past few days I've been losing my marbles over getting the IDT and interrupts set up. As of right now, I think I've gotten the IDT set up for the most part, however I haven't gotten a chance to test out interrupts yet. Part of the interrupts tutorial has this code snippet for GRUB users:
However when I use this code I get assembler errors:
What am I doing wrong? I am using the GCC cross assembler and ATT syntax assembly.
Code: Select all
jmp load_gdt
;global descriptor table
gdt:
gdt_null:
dq 0
gdt_code:
dw 0FFFFh
dw 0
db 0
db 10011010b
db 11001111b
db 0
gdt_data:
dw 0FFFFh
dw 0
db 0
db 10010010b
db 11001111b
db 0
gdt_end:
gdt_desc:
dw gdt_end - gdt - 1
dd gdt
;load gdt
load_gdt:
cli ;disable interrupts
lgdt [gdt_desc] ;load GDT
sti ;enable interrupts
Code: Select all
arch/i386/gdt.s: Assembler messages:
arch/i386/gdt.s:3: Error: no such instruction: `global descriptor table'
arch/i386/gdt.s:7: Error: no such instruction: `dq 0'
arch/i386/gdt.s:10: Error: no such instruction: `dw 0FFFFh'
arch/i386/gdt.s:11: Error: no such instruction: `dw 0'
arch/i386/gdt.s:13: Error: no such instruction: `db 0'
arch/i386/gdt.s:14: Error: no such instruction: `db 10011010b'
arch/i386/gdt.s:15: Error: no such instruction: `db 11001111b'
arch/i386/gdt.s:16: Error: no such instruction: `db 0'
arch/i386/gdt.s:19: Error: no such instruction: `dw 0FFFFh'
arch/i386/gdt.s:20: Error: no such instruction: `dw 0'
arch/i386/gdt.s:22: Error: no such instruction: `db 0'
arch/i386/gdt.s:23: Error: no such instruction: `db 10010010b'
arch/i386/gdt.s:24: Error: no such instruction: `db 11001111b'
arch/i386/gdt.s:25: Error: no such instruction: `db 0'
arch/i386/gdt.s:30: Error: no such instruction: `dw gdt_end - gdt - 1'
arch/i386/gdt.s:31: Error: no such instruction: `dd gdt'
arch/i386/gdt.s:33: Error: no such instruction: `load gdt'
arch/i386/gdt.s:35: Error: no such instruction: `disable interrupts'
arch/i386/gdt.s:36: Error: invalid char '[' beginning operand 1 `[gdt_desc]'
arch/i386/gdt.s:36: Error: no such instruction: `load GDT'
arch/i386/gdt.s:37: Error: no such instruction: `enable interrupts'
<builtin>: recipe for target 'arch/i386/gdt.o' failed
make: *** [arch/i386/gdt.o] Error 1