Assembly syntax?

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

  1. SAEinSDSU macrumors newbie

    Joined:
    Feb 17, 2010
    #1
    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

    pilotError

    Joined:
    Apr 12, 2006
    Location:
    Long Island
    #2
    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

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #3
    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

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

    Joined:
    Feb 17, 2010
    #5
    Okay thanks for the clarification on that...now 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.

    _main:

    .globl _sumthem

    _sumthem:

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


    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

    Joined:
    Aug 9, 2009
    #6
    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