Question

On the 32-bit SPARC architecture, both the load and store instructions (ld, ldub, ldsb, lduh, st, stb, etc.) all require square brackets around the memory address. For example,

st %l0, [%fp - 4]
ld [%i0], %l0

Why is this? Since the load and store instructions are the only ones that can access memory, why are the square brackets needed?

Is this just for readability or does another usage for load and store operations exist which do not use square brackets?

Was it helpful?

Solution

This is a common convention across many (if not most) assembly languages: when something is being dereferenced as a memory address, it is enclosed in brackets.

Even though SPARC doesn't allow alternative usages of ld, st, etc, the convention is still adhered to in order to avoid any ambiguity.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top