Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

asm is lisp

Name: Anonymous 2011-12-02 13:09

When i look at my gcc -S anus.c produced asm code i see that each method has a ret at the end, even the main.

How does it know to ret to the _main method rather than exit the program?

Name: Anonymous 2011-12-02 13:10

Call stack.

Name: Anonymous 2011-12-02 13:12

>>2
Aww so everytime it does 'call LABEL' and then a ret it knows that it's only returning back to where it was called from? neat, thanks.

People always made asm out to be some horrible alien but if that's how it works it seems a lot easier than people make it seem to be.

Name: Anonymous 2011-12-02 13:13

ASM is a bit like Lisp in that regard, it makes no sense until suddenly you understand it.

Name: Anonymous 2011-12-02 13:26

>>4
At least ASM has usable syntax.

Name: Anonymous 2011-12-02 13:50

>>3
the only difference between jmp and call is that call pushes the return address on the stack before jumping your mother.

Name: Anonymous 2011-12-02 20:42

I've always wondered, how do you initialize variables in ASM or make structs?

clearly it's not as simple as `int ...' or `struct ...{}'

Name: Anonymous 2011-12-02 20:47

>>7
You just allocate space for them in a section, or on the stack at run-time.

For a struct you need to allocate the fields in the correct order.

Name: Anonymous 2011-12-02 20:48

>>8
and account for aligning/packing issues if you want to export functions or wtv to other languages

Name: Anonymous 2011-12-03 2:50

>>7
Depends on the architecture's memory model, the smartness of the assembler (the usable ones at least have macros to define offsets), the variables' scope, the operating system's memory allocation model and the weather.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List