Tony Stark
Tony Stark

Reputation: 43

What does `addi a0, zero, 2` mean in pseudocode?

What does addi a0, zero, 2 mean in pseudocode? Is it a0=a0+2??

I am not sure because we do not have explicit register in this instruction to tell us where goes our result.

Upvotes: 0

Views: 950

Answers (1)

FabienM
FabienM

Reputation: 3741

There is not so much pseudo code in this risc-v assembly line :

addi a0, zero, 2
  • addi : mean add immediate. First argument is the register number for result, second is an argument and last is the immediate value (2 here).

But a0 and zero are ABI name of RISC-V register (see this pdf page 3).

  • a0: correspond to register x10. The addition result will be stored here.
  • zero: correspond to register x0. That is a special register «hardwired» to 0 (always 0 value)

Then the assembly line given will do this :

x10 = 0 + 2

Upvotes: 3

Related Questions