Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SAEinSDSU

macrumors newbie
Original poster
Feb 17, 2010
12
0
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!
 
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!
 
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!

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.
 
The suffix is not needed if the assembler can infer the data width from the register name.
 
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
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.