Intel to ATT Syntax: jmp

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
rhollencamp
Posts: 3
Joined: Tue Sep 23, 2008 9:38 pm

Intel to ATT Syntax: jmp

Post by rhollencamp »

I'm trying to convert the following code into a format that GNU as can understand. Here is the source:

Code: Select all

[GLOBAL gdt_flush]    ; Allows the C code to call gdt_flush().

gdt_flush:
   mov eax, [esp+4]  ; Get the pointer to the GDT, passed as a parameter.
   lgdt [eax]        ; Load the new GDT pointer

   mov ax, 0x10      ; 0x10 is the offset in the GDT to our data segment
   mov ds, ax        ; Load all data segment selectors
   mov es, ax
   mov fs, ax
   mov gs, ax
   mov ss, ax
   jmp 0x08:.flush   ; 0x08 is the offset to our code segment: Far jump!
.flush:
   ret
and here is my code:

Code: Select all

.global gdt_write

gdt_write:
	movl 4(%esp), %eax
	lgdt (%eax)

	mov 0x10, %ax
	mov %ax, %ds
	mov %ax, %es
	mov %ax, %fs
	mov %ax, %gs
	mov %ax, %ss
	jmp 0x08:flush
flush:
	ret
for the life of me, I can't figure out the jmp statement. It gives me a variety of errors depending on what I try, what is shown above gives the error ' Error: junk `:flush' after expression'.

Robert Hollencamp
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Intel to ATT Syntax: jmp

Post by Combuster »

<insert propaganda against AT&T syntax>

the opcode is ljmp
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
fieldofcows
Posts: 4
Joined: Tue Dec 09, 2008 5:34 pm

Re: Intel to ATT Syntax: jmp

Post by fieldofcows »

I think what you want is:

Code: Select all

jmp $0x08, $flush
Also, you're missing a dollar symbol on the following line:

Code: Select all

mov 0x10, %ax
should be:

Code: Select all

mov $0x10, %ax
Roy
Post Reply