xing Zì
xing Zì

Reputation: 411

What is the point of '@R0', ..., '@R15', instead of '@0', ..., '@15'?

What is the point of this mnenomic? '@R0', ..., '@R15', instead of '@0', ..., '@15'?

They likely have have mentioned it in the course, but I forgot, and it quite difficult to get an answer without having to go through several pages of text.

Upvotes: 0

Views: 169

Answers (1)

Trebor the MadOverlord
Trebor the MadOverlord

Reputation: 1289

They are mnemonics to remind you that the first 16 memory locations are typically used as scratchpad values, and to make your code a little easier to read. Also, they mark the locations that are not automatically allocated when you use the @Variable_Name construct; those start at 16.

Note that R0-R4 can also be referred to as SP,LCL,ARG,THIS and THAT respectively. These names refer to locations used in standard Hack assembly code when doing function calls.

Upvotes: 1

Related Questions