What is offset instruction in AT&T syntax?

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
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

What is offset instruction in AT&T syntax?

Post by NeonLightions »

Hi,
Like the title, I want to know which instruction in AT&T syntax as same as "offset" instruction in Intel syntax?
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: What is offset instruction in AT&T syntax?

Post by kzinti »

I think you are looking for the $ prefix... "offset" is not an instruction but a statement that tells the assembler you want the address (really the segment offset) of the following expression.

For example:

Code: Select all

mov offset label, eax # Get the address of label into eax
Becomes:

Code: Select all

movl %eax, $label # Get the address of label into eax
I am not sure if this covers all the cases. But t might just do.
User avatar
BigBuda
Member
Member
Posts: 104
Joined: Fri Sep 03, 2021 5:20 pm

Re: What is offset instruction in AT&T syntax?

Post by BigBuda »

kzinti wrote:I think you are looking for the $ prefix... "offset" is not an instruction but a statement that tells the assembler you want the address (really the segment offset) of the following expression.

For example:

Code: Select all

mov offset label, eax # Get the address of label into eax
Becomes:

Code: Select all

movl %eax, $label # Get the address of label into eax
I am not sure if this covers all the cases. But t might just do.
Didn't you mistake the order? Isn't the exact opposite? Intel syntax is mov destination, source and AT&T is mov source, destination.
Writing a bootloader in under 15 minutes: https://www.youtube.com/watch?v=0E0FKjvTA0M
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

Re: What is offset instruction in AT&T syntax?

Post by NeonLightions »

Oh, so it just basically the "$" prefix? Thank you for the answer!
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: What is offset instruction in AT&T syntax?

Post by kzinti »

BigBuda wrote:Didn't you mistake the order? Isn't the exact opposite? Intel syntax is mov destination, source and AT&T is mov source, destination.
Yep, sure did. Just inverse the operands in both of my examples.
Post Reply