AIX as (assembler) tutorial? - Aix

This is a discussion on AIX as (assembler) tutorial? - Aix ; Could someone point me towards a tutorial for the AIX assembler. Some simple examples would be helpful. Thanks! James T. Sprinkle (The Grue) http://www.myspace.com/jamestsprinkle...

+ Reply to Thread
Results 1 to 7 of 7

Thread: AIX as (assembler) tutorial?

  1. AIX as (assembler) tutorial?

    Could someone point me towards a tutorial for the AIX assembler. Some
    simple examples would be helpful. Thanks!

    James T. Sprinkle (The Grue)
    http://www.myspace.com/jamestsprinkle


  2. Re: AIX as (assembler) tutorial?

    The-Grue@hotmail.com wrote:
    > Could someone point me towards a tutorial for the AIX assembler. Some
    > simple examples would be helpful. Thanks!
    >
    > James T. Sprinkle (The Grue)
    > http://www.myspace.com/jamestsprinkle
    >


    You didn't say what you have looked at until now and what
    AIX facilities you have available to you to play with.

    I don't know of any specific tutorial but you can start here:
    http://publib.boulder.ibm.com/infoce...v5r3/index.jsp
    and search the AIX HTML library or the PDFS.

    An assembler language reference is here:
    http://publib.boulder.ibm.com/infoce...f/alangref.pdf
    It some some example uses throughout the book.

    You can also try http://www.redbooks.ibm.com/.

    AIX programming in assembler is discouraged since IBM changes the
    available machine language instructions when coming out with newer
    cpu models.

    If you compile some C programs, there are options to let you see
    some output as assembly code.

    cheers
    sol

  3. Re: AIX as (assembler) tutorial?

    The-Grue@hotmail.com schrieb:
    > Could someone point me towards a tutorial for the AIX assembler. Some
    > simple examples would be helpful. Thanks!
    >
    > James T. Sprinkle (The Grue)
    > http://www.myspace.com/jamestsprinkle
    >


    First you should get
    http://publib.boulder.ibm.com/infoce...f/alangref.pdf
    Now, there are not that many examples (or only fragments)
    in this reference. However, there is Developerworks and here
    http://www.ibm.com/developerworks/li...l-powasm1.html
    you will find some examples. The link is to part 1. On this
    page you'll find links to parts 2, 3 and 4. Have fun....

  4. Re: AIX as (assembler) tutorial?

    On Oct 10, 11:43 am, sol gongola wrote:
    > The-G...@hotmail.com wrote:
    > > Could someone point me towards a tutorial for the AIX assembler. Some
    > > simple examples would be helpful. Thanks!

    >
    > > James T. Sprinkle (The Grue)
    > >http://www.myspace.com/jamestsprinkle

    >
    > You didn't say what you have looked at until now and what
    > AIX facilities you have available to you to play with.
    >
    > I don't know of any specific tutorial but you can start here:http://publib.boulder.ibm.com/infoce...v5r3/index.jsp
    > and search the AIX HTML library or the PDFS.
    >
    > An assembler language reference is here:http://publib.boulder.ibm.com/infoce...opic/com.ibm.a...
    > It some some example uses throughout the book.
    >
    > You can also tryhttp://www.redbooks.ibm.com/.
    >
    > AIX programming in assembler is discouraged since IBM changes the
    > available machine language instructions when coming out with newer
    > cpu models.
    >
    > If you compile some C programs, there are options to let you see
    > some output as assembly code.
    >
    > cheers
    > sol


    Hi! I guess some more information would be helpful, huh? I work as
    an AIX System Administrator / System Programmer and am taking a
    Computer Architecture class as part of my Master's program in Computer
    Science. I decided I would like to learn more about the Power
    Architecture since I work with AIX. I have systems available from AIX
    4.3.3, 5.1, 5.2, 5.2 and the Beta 6.0 to play with and P4-P6
    hardware. I have looked at the "PowerPC assembly" document on IBM
    DeveloperWorks and contacted the author who told me the examples were
    in gas format. I have downloaded the Instruction Set Architecture for
    Power as well as some additional documents like "The Programming
    Environments for 32-Bit Microprocessors" and have yet to begin wading
    through them. (Although I did happen to see the eieio operand flash
    by on the printer, that was amusing!) I have looked into the Assembly
    Language Reference, but the examples I have found in there build ok
    but core when I try to run them. (Illegal instruction(coredump)) I
    wanted to try to use as since it comes standard on AIX, but it looks
    like the only tutorials I can find will require gas. Hope that sheds
    a little more light on what I am trying to accomplish.

    James T. Sprinkle (The Grue)
    http://www.myspace.com/jamestsprinkle


  5. Re: AIX as (assembler) tutorial?

    This reference is excellent. Since Apple used the PowerPC for the
    powerBooks,
    that development community is particularly helpful towards the PPC
    architecture.

    I find the "PowerPC Compiler Writer's Guide" to be extraordinarly
    useful.
    http://www-01.ibm.com/chips/techlib/...256996007558C6

    "This book describes, mainly by coding examples, the code patterns
    that perform well on PowerPC™ processors."

    1. I use the C compiler to generate assembly code, and then optimize
    the result.
    xlc -qsource -qlist test.c

    2. You can inline assembly code in the vac compilers using #pragma
    mc_func
    See the AIX header files for examples:
    grep mc_func /usr/include/sys/*

    Using the IBM compiler (not gcc syntax), the mc_func code is called
    like a C function, but is inline.

    Here's a sample atomic increment that is very fast:

    #if defined(_LP64) // --------------------_LP64
    #pragma mc_func Increment { \
    "7c641b78" /* mr r4,r3 */ \
    "7c6020a8" /* ldarx r3,0,r4 cca:*/ \
    "38630001" /* addi r3,0,1 */ \
    "7c6021ad" /* stdcx. r3,0,r4 */ \
    "4082fff4" /* bne cca */ \
    }
    #pragma reg_killed_by Increment gr3-gr4, cr0

    #pragma mc_func Decrement { \
    "7c641b78" /* mr r4,r3 */ \
    "7c6020a8" /* ldarx r3,0,r4 ccs:*/ \
    "3863ffff" /* addi r3,0,-1 */ \
    "7c6021ad" /* stdcx. r3,0,r4 */ \
    "4082fff4" /* bne ccs */ \
    }
    #pragma reg_killed_by Decrement gr3-gr4, cr0

    #else // ------------------------ _LP32
    #pragma mc_func Increment { \
    "7c641b78" /* mr r4,r3 */ \
    "7c602028" /* lwarx r3,0,r4 cca:*/ \
    "38630001" /* addi r3,0,1 */ \
    "7c60212d" /* stwcx. r3,0,r4 */ \
    "4082fff4" /* bne cca */ \
    }
    #pragma reg_killed_by Increment gr3-gr4, cr0

    #pragma mc_func Decrement { \
    "7c641b78" /* mr r4,r3 */ \
    "7c602028" /* lwarx r3,0,r4 ccs:*/ \
    "3863ffff" /* addi r3,0,-1 */ \
    "7c60212d" /* stwcx. r3,0,r4 */ \
    "4082fff4" /* bne ccs */ \
    }
    #pragma reg_killed_by Decrement gr3-gr4, cr0
    #endif // _LP32 | _LP64

    Sample invocation on long, which works in 32 and 64-bit mode.

    long Ref=1;
    Increment(Ref);
    Decrement(Ref);



  6. Re: AIX as (assembler) tutorial?

    > wanted to try to use as since it comes standard on AIX,

    Just this morning I opened PMR 33272,756 against AIX "as" (assembler)
    command because it was generating incorrect instructions in the
    listing
    that I never tripped on before. The generated instruction was
    correct,
    which I established by disassembling the .o (/usr/vac/exe/dis).

    ---- atomic.s ----
    ..machine "ppc64"; .set r3,3;.set r4,4;
    mr r4,r3
    cca:
    ldarx r3,0,r4
    addi r3,0,1
    stdcx. r3,0,r4
    bne cca

    ---- atomic.lst ----
    0 4 | PPC64 0000000000000000 7c641b78 mr
    r4,r3
    0 6 | PPC64 0000000000000004 7c6020a8 ldarx
    r3,0,r4
    0 8 | PPC64 0000000000000008 38600001 addi
    r3,0,1
    0 9 | PPC64 000000000000000c 7c6021ad stdcx.
    r3,0,r4
    0 10 | PPC64 0000000000000010 4082fff4 bne
    cca

    The binary instruction for "addi" is incorrect (38600001)
    38600001 is "li" (Load Immediate 1)
    38630001 is "addi" (Add Immediate 1)

    The result is that the 64-bit atomic increment will always set the
    target
    to "1", and never increment it.

    --- Makefile ---
    s:
    as -a64 -oa_s.o -latomic.lst atomic.s
    /usr/vac/exe/dis a_s.o
    egrep 'cal|addi' atomic.lst a_s.s


  7. Re: AIX as (assembler) tutorial?

    > illegal instructions

    Very likely, this is due to machine architectures.

    POWER: The first RS6000 by IBM
    PPC: An open architecture by AIM (Apple-Motorola-IBM)

    The only hybrid machine produced was the "601", which contained
    a combination of Power and PPC instructions.

    >From the Motorola site, you can download architecture PDF's:

    MPC604UMU-01 PowerPC 604 User Manual

    This book is quite good:
    "Optimizing PowerPC Code" (in Assembly)
    Gary Kacmarcik, Addison Wesley, ISBN 0-201-40839-2


+ Reply to Thread