0

there is a difference between those two instructions? addI $12,$1,0x0000ffff vs addI $12,$1,0xffff

I need to know what is the value of $12 after those instruction :

lui $1,0xffffff00
addi $12,$1,0x0000ffff

should i treat 0x0000ffff as sign extended - 0xfffffffff or as it is - 0x0000ffff and then $12 is 0xff00fffff ? thanks

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
AVITAL
  • 11
  • 2
  • Try it yourself and notice the assembler warning or error about the value not being representable as a 16-bit sign-extended immediate. (Or with MARS extended pseudo-instructions, using multiple instructions to materialize `0x0000ffff` in a register to add with that.) Asm source uses values, not bit-patterns for immediates. – Peter Cordes Nov 27 '22 at 16:46
  • Related: [andi vs. addi instruction in MIPS with negative immediate constant](https://stackoverflow.com/q/40090168) / [Why is MARS mips 32 bit immediate possible?](https://stackoverflow.com/q/42798624). Looks like a duplicate of [In a MIPS assembly \`addi\` instruction, how is a hexadecimal immediate interpreted?](https://stackoverflow.com/q/37159516) which was only answered in comments. Also [Range of immediates in lui instruction](https://stackoverflow.com/q/53467887) – Peter Cordes Nov 27 '22 at 16:48
  • This is a question of interpretation of syntax rather than of instruction set, therefore it is a question of what the assembler does, and as there are several MIPS assemblers, so the answers can vary. – Erik Eidt Nov 27 '22 at 16:53
  • Unfortunately it depends entirely on the assembler. – puppydrum64 Nov 28 '22 at 15:54

0 Answers0