OSDev.org
https://forum.osdev.org/

Having trouble with this GDT code snippet from the wiki.
https://forum.osdev.org/viewtopic.php?f=1&t=33826
Page 1 of 1

Author:  GreenJames [ Tue Aug 13, 2019 12:05 pm ]
Post subject:  Having trouble with this GDT code snippet from the wiki.

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:

Code:
  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



However when I use this code I get assembler errors:

Code:
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



What am I doing wrong? I am using the GCC cross assembler and ATT syntax assembly.

Author:  no92 [ Tue Aug 13, 2019 1:17 pm ]
Post subject:  Re: Having trouble with this GDT code snippet from the wiki.

Are you sure about your statement that you use AT&T-style assembly? The error messages might be onto something ...

Author:  MichaelPetch [ Tue Aug 13, 2019 3:54 pm ]
Post subject:  Re: Having trouble with this GDT code snippet from the wiki.

You are trying to assemble this code with GCC/GAS (Gnu assembler), but the code is for NASM. `gcc` nor `as` will assemble that code.

Meaty Skeleton's assembly code use GNU assembler AT&T syntax, the interrupt tutorial you are using uses NASM syntax.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/