Assembly syntax?

Discussion in 'Mac Programming' started by SAEinSDSU, Feb 23, 2010.

  1. SAEinSDSU macrumors newbie

    Feb 17, 2010
    In my assembly programming class and book all of the syntax for assembly has l or q or some other char after the commands such as movl, leaq ect...however when i look up the language and sample codes do not have these char's. Also % signs are used before the registers (e.g. %eax, %edp)...just wondering why this is and what they mean? Thanks!
  2. pilotError macrumors 68020


    Apr 12, 2006
    Long Island
    movl = Move Long word (I'm pretty sure). The others make sense when you learn the registers. dp being some sort of pointer.

    Sorry, it's been a while and the cobwebs are pretty thick!
  3. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    If memory serves that is one of the differences between Intel and AT&T syntax.

    You might be better off using an assembler like NASM. It has the nicest syntax of any assembler I have seen. While managing to avoid all the rubbish that assemblers like MASM make use of.
  4. Sander macrumors 6502

    Apr 24, 2008
    The suffix is not needed if the assembler can infer the data width from the register name.
  5. SAEinSDSU thread starter macrumors newbie

    Feb 17, 2010
    Okay thanks for the clarification on that that is clear here is another inquiry. I wrote this code in assembly using i386 architecture but i keep getting the same compile error.


    .globl _sumthem


    pushl %ebp
    movl %esp,%ebp
    movl 8(%ebp), %ecx
    xorl %esi,%esi
    xorl %eax,%eax
    addl %esi,%eax
    incl %esi
    cmpl %esi,%ecx //loop again:
    JGE again
    popl %ebp

    here is the error that xcode keeps giving me

    Undefined symbols:
    "_main", referenced from:
    start in crt1.10.6.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status

    im not sure what it is talking about when it refers to _main...please let me know
  6. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    It's telling you there isn't a symbol "_main".

    Unless I miss my guess, you've neglected to make _main external.

    I could easily be wrong, it's been ages since I did any *86 assembler.

    Another interpretation is that it's running the final link phase for a stand-alone program, as opposed to a static lib, dylib, or object-file. That's why it's looking for main: it expects you to have defined a main() in your C program (or equivalent). If you don't want an executable program, then you need to tell the linker what you want to produce.

    Since you haven't shown the command-line for compiling or assembling, those are just the two best guesses I have.

Share This Page