Flow Control Instructions


These instructions may alter the flow of the program.

Table B-4: Flow Control Instructions

Instruction

Operands

Affected Flags

call

destination address

O/S/Z/A/C

This pushes what would be the next value for %eip onto the stack, and jumps to the destination address. Used for function calls. Alternatively, the destination address can be an asterisk followed by a register for an indirect function call. For example, call *%eax will call the function at the address in %eax.

int

I

O/S/Z/A/C

Causes an interrupt of the given number. This is usually used for system calls and other kernel interfaces.

Jcc

destination address

O/S/Z/A/C

Conditional branch. cc is the condition code. Jumps to the given address if the condition code is true (set from the previous instruction, probably a comparison). Otherwise, goes to the next instruction. The condition codes are:

  • [n] a [e] - above (unsigned greater than). An n can be added for "not" and an e can be added for "or equal to"

  • [n] b [e] - below (unsigned less than)

  • [n] e - equal to

  • [n]z - zero

  • [n] g [e] - greater than (signed comparison)

  • [n] l [e] - less than (signed comparison)

  • [n] c - carry flag set

  • [n] o - overflow flag set

  • [p] p - parity flag set

  • [n] s - sign flag set

  • ecxz - %ecx is zero

jmp

destination address

O/S/Z/A/C

An unconditional jump. This simply sets %eip to the destination address. Alternatively, the destination address can be an asterisk followed by a register for an indirect jump. For example, jmp *%eax will jump to the address in %eax.

ret

O/S/Z/A/C

Pops a value off of the stack and then sets %eip to that value. Used to return from function calls.




Programming from the Ground Up
Programming from the Ground Up
ISBN: 0975283847
EAN: 2147483647
Year: 2006
Pages: 137

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net