user19470144
user19470144

Reputation:

How to read/pronounce a MIPS load-byte instruction in English?

In MIPS instruction set, we have instructions like "LB R1, 0(R2)", which means "load one byte from the memory address whose base address is stored in R2 register and plus an offset of 0, load this byte to register R1". I am not an English native speaker and would like to learn the English way to pronounce this instruction. Is it correct to pronounce it as "load byte R one zero R two"?

Upvotes: 4

Views: 104

Answers (1)

Peter Cordes
Peter Cordes

Reputation: 365332

When speaking aloud to other humans, you normally wouldn't just read the pronounceable parts of the asm syntax. "R one zero R two" could be mixed up with r10, (r2).

The 0 in the 0(r2) addressing mode is just a placeholder that some people like to include, perhaps because the machine code always has a 16-bit immediate displacement. Speaking out loud, the zero is pure clutter in something that already non-trivial for a listener to "parse" back into an asm instruction.

Reading to myself in my head, I'd say "ell bee into arr one from arr two". And I'm looking at the text syntax and I know that lb r1, r2 is nonsense, so I don't need to mentally add "from memory at arr two". If I was speaking semi-casually to another human who I knew was familiar with MIPS, I might say it that way out loud, e.g. if I was suggesting a possible instruction to be added to some code we were talking about.

(I'm spelling out the phonetic pronunciation of English letter names, like arr for R, ell for L, bee for B.)

If we were looking at some existing code for context, I might just say "the ell bee" if there was only one in a loop or block, or "the LB into arr one".

Another way of reading it is "ell bee from arr two into arr one". Semantically, I tend to think of loads that way, despite finding it more natural to read asm with the destination on the left, like an assignment. (Some asm syntaxes put the destination last, like PDP-11 or m68k. Or more strangely, AT&T syntax for x86 despite the vendor's syntax being the opposite.)

You could also read it as "R one is loaded with a sign-extended byte from (memory at) R two", converting prefix to infix order, like R1 = (R2).

(Recall that in MIPS, the default is sign-extension. lbu is a zero-extending load.)


If you did have a non-zero displacement like lhu r1, 4(r2), I might say:
"ell aich you into arr one from four plus arr two".
Or "load unsigned half-word from four plus arr two into arr one".

"plus" is a good short word that unambiguously indicates an offset, vs. "from" as in "4 bytes away from" - just "from" is already being used to talk about where we load from, and "away from" is unnecessarily long.

Upvotes: 2

Related Questions