Question

Just a short question. Anyone knows if there is any way that I can do this in assembly?

movl $4, %ebx
movl (%ebx)(%esp), %eax

what I'm trying to do is basically create a loop that extras the next argument(fixed size) from the stack.

example:

int foo( int x, int y, int z, int a){
    if(x == y){
         x = z;
       if(y == z){
            printf("%d", a);
      }
    }
}

instead of immediately loading x, y, z and a into the register, can I load a into the register only when I'm sure that the first 2 conditions are true.

p/s: wrote the code on the fly, doesn't really do anything useful.

Was it helpful?

Solution

You want this

movl $1, %ebx
movl (%esp,%ebx,$4), $eax

incrementing %ebx by one each time to get to the next argument.

OTHER TIPS

movl (%esp,%ebx),%eax

is accepted by my compiler.

The syntax is

mov'suffix' (offset,base[,scale]),target

with the scale in brackets because it is optional

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top