0

From the Sparc architecture manual, page 110 for Add instruction:

"If i = 0, ADD and ADDcc compute “R[rs1] + R[rs2]”. If i = 1, they compute “R[rs1] + sign_ext(simm13)”. In either case, the sum is written to R[rd]."

When reading the assembly, how can I know whether i=0 or i=1 ? It doesn't look like there is any change in the mnemonic/opcode as it appears in the disassembled code.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Cherry Vanc
  • 781
  • 1
  • 4
  • 19

1 Answers1

1

The "i" indicates an "immediate" value in the instruction. An immediate is a constant. So you'll see something like this:

add %g1, 59, %g1

That means "add the constant 59 to g1 and put the result in g1".

When i=0, it means that the parameter is not an immediate. So it's a register! You will see this in the assembly or disassembly:

add %g1, %o3, %g1

And that means add registers g1 and o3 and put the result in o3.

Rob Gardner
  • 201
  • 1
  • 4