0
votes

I would like to specify to MARS that I'm entering an octal number as an immediate operand.

I know that it is possible with Hex- Something like:

li  $t0, 0x24    #this is ASCII '$'

Is it possible to do the same with Octal?

2
Have you tried prefixing with just 0 yet? - Ignacio Vazquez-Abrams
didn't understood. you mean li $t0, 024 ? - ALUFTW
@ALUFTW: Yes, if you want to load immediate 24 (in octal) prefix de immediate with 0, i.e. li $t0, 024 - gusbro
For ASCII char values, you can just use li $t0, '$' in the first place, instead of needing a magic number and a comment. Octal could be useful for other cases, though, so I hope that's just a silly choice of example. - Peter Cordes

2 Answers

0
votes

Just prefix the immediate with 0, like in C:

li $t0, 024

Thanks to @gusbro

0
votes

Unlike MARS, qtspim and pcspim don't support the leading-0 for octal. For example, 024 and 037 are treated as decimal constants, the same as 24 and 37

You must manually convert to a decimal or hex for SPIM's built-in assembler.