documentation of gnu assembler directives
Asked Answered
I

1

8

I'm trying to learn mips assembly at the moment. To that end, I wrote a very simple c program...

int main(){}

...and compiled it on a mips machine with the -S option to gcc to generate assembly code. Here is what the beginning of the main function looks like:

    .ent   main
main:
    .frame $fp,8,$31
    .mask  0x40000000,-8
    .fmask 0x00000000,0

I then tried to figure out what this all means by looking at the documentation for gas, but I couldn't find any of these directives there. So what do they mean? Where can I find more information?

Indigestion answered 8/4, 2009 at 15:42 Comment(3)
Perhaps your copy of gcc is configured to use some other assembler (not gas)? What does this say "gcc -c -Wa,-version -xc - < /dev/null" ?Deceleron
My copy of gcc is the one that comes with netbsd and it does use gas. I ran your command to confirm. I still think it is odd that gas doesn't document those and doesn't even link to some other place where they are documented.Indigestion
Voting to close as resource recommendation. Asking what .ent, .frame, etc. are in separate questions would be great though.Muffin
T
7

I know my answer is kind of late. Better late than never.

When you compile an assembly file, two kinds of directives may show up in the code.

  1. One kind is the directives supported by your assembler, in your situation, it isGNU as directives.

  2. The other kind depends on you assembly language, and because you are apparently using mips assembly here, the .ent is actually a mips assembly directive.

Here is the guide where you can find .ent .frame .fmask .mask directives: they are all mips assembly directives. Or you can just Google MIPS Assembly Language Programmer’s Guide. Navigate to chapter 8, Pseudo Op-Codes and you will get all you need.

You may wonder how GNU as can support mips directives? Type Info as, navigate to chapter Machine Dependent Features, then navigate to subchapter MIPS-Dependent. But still, you can't find .ent directive here, nor .frame .fmask .mask. That is because info as is not a mips assembly guide and can not be that much comprehensive.

By the way, nasm, the assembler which many programmer are familiar with, has its own directives and syntax (Intel style) which are different from those of GNU as (derived from ancient AT&T style). Similarly, different assembly language may have their own unique directives (but not syntax) supported by assemblers that can assemble them too. That's why two source of directives may show up in an assembly file. Now, the GNU as assembler can even support Intel syntax. And furthermore, there are tools to translate between AT&T and Intel syntax. However, you should remember that directives are different from syntax. Frankly speaking, I am confused about this too.

Taro answered 13/3, 2018 at 12:12 Comment(1)
appreciate the answerHeptarchy

© 2022 - 2024 — McMap. All rights reserved.