LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-15-2004, 09:36 PM   #1
aXoneX
LQ Newbie
 
Registered: Jun 2004
Distribution: Slackware, SuSE
Posts: 23

Rep: Reputation: 15
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing to screen using AT&T assembly syntax doron_bl Programming 2 08-30-2005 01:00 AM
Help!! loading up GDT (switching to protected mode) assembly AT&T syntax aXoneX Programming 14 07-17-2004 03:55 PM
C & Assembly question eantoranz Programming 3 04-23-2004 01:18 PM
Switching to text mode on boot traef06 Linux - Newbie 2 09-12-2003 06:57 AM
Switching from gnome > Text mode XxAndyxX Linux - Software 1 03-23-2003 07:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration