OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Jan 27, 2021 8:42 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Intel syntax with GAS?
PostPosted: Tue Dec 15, 2020 7:38 pm 
Offline
Member
Member

Joined: Wed Apr 01, 2020 4:59 pm
Posts: 54
The wiki article on GAS recommends not using GAS's intel syntax. It gives two reasons:

  1. Even in intel mode, operands are reversed in some cases
  2. Assembly produced may be suboptimal

1 is certainly true, but only applicable to a small number of x87 instructions which should be avoided anyway. 2 seems to have been fixed; at least, I was unable to reproduce it:

Code:
$ cat testatt.s
.code16     ; NB. I get the same results in 64-bit mode
f1:
mov $5, %si
mov %di, %si
mov %ax, %si
movsx %al, %si
movsb (%si), (%di)
$ cat testintel.s
.intel_syntax noprefix
.code16
f1:
mov si, 5
mov si, di
mov si, ax
movsx si, al
movsb [di], [si]
$ as testatt.s -o testatt.o && as testintel.s -o testintel.o
$ diff test{att,intel}.o && echo same
same


Should the wiki page be updated? Are there any other reasons people know of for avoiding GAS's intel syntax? It's worked great for me, personally.


Top
 Profile  
 
 Post subject: Re: Intel syntax with GAS?
PostPosted: Mon Dec 21, 2020 5:42 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9289
Location: On the balcony, where I can actually keep 1½m distance
Your average bootloader example contains something like
Code:
jmp far 0x0008:0x00010000
On my system's binutils 2.33.1, that still gives
Code:
astest.s:4: Error: junk `0x0008:0x00010000' after expression

Have fun figuring out the correct syntax if you don't know it already. Hint: it's not in the intel or amd manuals :wink:

_________________
"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 ]


Top
 Profile  
 
 Post subject: Re: Intel syntax with GAS?
PostPosted: Mon Dec 21, 2020 7:01 am 
Online
Member
Member
User avatar

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 550
It may be hard enough to figure out GAS syntax to begin with! Luckily, I found a document on the net (forget where) that saved me a few weeks ago when I switched to GAS.

_________________
Currently working on the Nexware project, an attempt to make a less bloated version of GNU. All repos for it can be found at https://github.com/Nexware-Project.


Top
 Profile  
 
 Post subject: Re: Intel syntax with GAS?
PostPosted: Tue Jan 12, 2021 2:12 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 01, 2019 3:50 pm
Posts: 39
Location: France
Combuster wrote:
Your average bootloader example contains something like
Code:
jmp far 0x0008:0x00010000
On my system's binutils 2.33.1, that still gives
Code:
astest.s:4: Error: junk `0x0008:0x00010000' after expression

Have fun figuring out the correct syntax if you don't know it already. Hint: it's not in the intel or amd manuals :wink:

It is indeed tricky to find equivalents of the Intel syntax while using GAS, that's why I'm going to take the opportunity to give the equivalent of your given instruction here so that people don't have to figure out the hard way (as I did!) :P
Code:
ljmp $0x8, $0x10000


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 2 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