SPARC Assembly/Arithmetic Instructions
From Wikibooks, the open-content textbooks collection
Contents |
[edit] Arithmetic Instructions
These are the basic operations used for addition, subtraction, and multiplication. Note that any of these arithmetic instructions may take a register or an immediate value as the op2 parameter. All other parameters (rd and rs1 must be registers).
|
Instruction:
|
|
Adds rs1 and op2, and stores result in rd.
|
Instruction:
|
|
Same as above, except that it sets the condition codes.
|
Instruction:
|
|
subtracts op2 from rs1, and stores the difference in rd
|
Instruction:
|
|
same as above, except that it sets the condition codes.
|
Instruction:
|
|
Performs a single step in the multiplication operation. Stores partial results in register Y. Complete multiplication algorithms are discussed in more detail later.
[edit] Extended Precision
These instructions account for the carry bit setting, so that large numbers (larger then the machine word) can be virtually manipulated as a single entity.
|
Instruction:
|
|
Performs extended addition (adds two operands and carry bit), and stores result in rd.
|
Instruction:
|
|
Same as above, but sets the condition codes.
|
Instruction:
|
|
Performs extended subtractions (subtracts op2 and C from rs1) and stores result in rd.
|
Instruction:
|
|
same as above, but sets the condition codes.
[edit] Tagged Instructions
|
Instruction:
|
|
|
Instruction:
|
|
|
Instruction:
|
|
|
Instruction:
|
|
[edit] Y Register
These operations affect the Y register.
|
Instruction:
|
|
reads the contents of the Y register in to the rd destination register
|
Instruction:
|
|
exclusively ORs the rs1 and op2 values, and stores that result in the Y register.
[edit] Logic Instructions
|
Instruction:
|
|
performs the bitwise AND of rs1 and op2, and stores the result in rd.
|
Instruction:
|
|
same as above, sets the condition codes.
|
Instruction:
|
|
performs the bitwise OR of rs1 and op2, and stores the result in rd.
|
Instruction:
|
|
same as above, sets the condition codes.
|
Instruction:
|
|
performs the bitwise XOR, between rs1 and op2. stores the result in rd.
|
Instruction:
|
|
same as above, sets the condition codes.
|
Instruction:
|
|
performs the bitwise XNOR between rs1 and op2. puts result in rd.
|
Instruction:
|
|
same as above, sets condition codes.
[edit] Inverted Logic Operations
|
Instruction:
|
|
ANDs rs1 and the bitwise inverse of op2. stores result in rd.
|
Instruction:
|
|
same as above, sets condition codes.
|
Instruction:
|
|
ORs rs1 and the bitwise inverse of op2. stores the result in rd.
|
Instruction:
|
|
same as above, sets the condition codes.
[edit] Shift Instructions
|
Instruction:
|
|
performs the logical left-shift of rs1. Shift amount is according to value of op2. result is stored in rd.
|
Instruction:
|
|
performs the logical right-shift of rs1. Shift amount is the value of op2. stores the result into rd.
|
Instruction:
|
|
performs the arithmetic right-shft of rs1. shift amount is the value of op2. stores the result in rd.