411 REFERENCE · Wikibooks
SPARC Assembly/Control Flow
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Comparison
cmp
compares two numbers (Subtraction). Sets flags.
tst
tests two numbers (performs 'and' operation). Sets flags.
Jump Instructions
jmp
jumps to specified indirect address. stores return address in %o7.
jmpl
Performs an unconditional, register indirect jump. Target address is provided in the first operand, and the return address is then stored into the rd operand.
jmpl rs1, rd
If the return address is stored in %o7, this acts like a subroutine call. If the return address is stored in %g0, it acts like a subroutine return.
sethi
Sets the highest 22 bits of the target register, sets the lowest 10 bits to zero.
sethi const22, rd
const22 must be a constant value, cannot be a register.
Subroutine Instructions
call
calls a subroutine. Takes a single label as a new target address. Stores the return address in %o7. cannot jump to a register indirect address.
ret
return from a subroutine.
retl
return from a leaf subroutine.
rett
Return from a trap instruction, or from a register indirect control transfer.
save
saves the current register window and creates a new window. raises an exception if there is a register window overflow.
restore
restores a saved register window.
Branch Instructions
branches do not store the return address.
ba
Branch always. an unconditional jump to the target location. d
bn
Branch never.
be
bne
branches if the two operands are equal or not equal, respectively.
bl
branches on "less than"
ble
branches on "less than or equal"
bge
branches on "greater than or equal"
bg
branches on "greater than"
blu
bleu
Same as bl and ble, except uses unsigned numbers
bgeu
bgu
Same as bge and bg, except uses unsigned numbers
bpos
branches if the number is positive.
bneg
branches if the number is negative.
bcs
bcc
branches if the carry bit is set or clear, respectively.
bvs
bvc
branches if the signed overflow bit is set or clear, respectively.