Three SPARC Instruction Format
1. Arithmetic/Logical/Shift instructions
opcode reg1,reg2,reg3 !reg1 op reg2 -> reg3 opcode reg1,const13,reg3 !reg1 op const13 -> reg3
- All "action" instructions (add, sub, and, or, etc.) take three operands.
- The destination is always the third operand.
- The middle operand may be a 13-bit signed constant (-4096...+4095).
- Otherwise, all operands are registers.
- Examples:
add %L1,%L2,%L3 !%L1+%L2->%L3
2. Load/Store Instructions
opcode [reg1+reg2],reg3 opcode [reg1+const13],reg3
- Only load and store instructions can access memory.
- The contents of reg3 is read/written from/to the address in memory formed by adding reg1+reg2, or else reg1+const13 (a 13- bit signed constant as above).
- The operands are written in the reverse direction for store instructions, so that the destination is always last.
- One of reg1 or const13 can be omitted. The assembler will supply $g0 or 0. (This is a shorthand provided by the assembler. Both are always there in machine language.)
- Examples:
ld [%L1+%L2],%L3 !word at address [%L1+%L2]->%L3
3. Branch Instructions
opcode address
- Branch to (or otherwise use) the address given.
- There are actually 2 types of addresses but they look the same.
- Examples:
call printf be Loop
Above are three SPARC Instruction Format.
More Microprocessor and Interfacing Question and Answer: Click Here