OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:50 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Having trouble with this GDT code snippet from the wiki.
PostPosted: Tue Aug 13, 2019 12:05 pm 
Offline

Joined: Tue Aug 13, 2019 9:55 am
Posts: 1
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.


Top
 Profile  
 
 Post subject: Re: Having trouble with this GDT code snippet from the wiki.
PostPosted: Tue Aug 13, 2019 1:17 pm 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
Are you sure about your statement that you use AT&T-style assembly? The error messages might be onto something ...

_________________
managarm


Top
 Profile  
 
 Post subject: Re: Having trouble with this GDT code snippet from the wiki.
PostPosted: Tue Aug 13, 2019 3:54 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 55 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group