immediate-operand

why we can't move a 64-bit immediate value to memory?

跟風遠走 提交于 2020-07-09 05:14:31
问题 First I am a little bit confused with the differences between movq and movabsq , my text book says: The regular movq instruction can only have immediate source operands that can be represented as 32-bit two’s-complement numbers. This value is then sign extended to produce the 64-bit value for the destination. The movabsq instruction can have an arbitrary 64-bit immediate value as its source operand and can only have a register as a destination. I have two questions to this. Question 1 The

andi vs. addi instruction in MIPS with negative immediate constant

荒凉一梦 提交于 2020-05-16 06:05:28
问题 Assume $t2= 0x55555550 , then executing the following instruction: andi $t2, $t2, -1 $t2 becomes 0x0005550 This is confirmed by the MIPS emulator 1 However, it is not what I expected. I think the answer should be 0x55555550 & 0xFFFFFFFF = 0x55555550. I think the constant -1 was sign extended to 0xFFFFFFFF before the and logic. But it appears that the answer was 0x55555550 & 0x0000FFFF Why -1 is sign extended to 0x0000FFFF instead of 0xFFFFFFFF Footnote 1: Editor's note: MARS with "extended

Why would we use addiu instead of addi?

你离开我真会死。 提交于 2019-12-28 13:56:09
问题 In MIPS assembly, what is the benefit of using addiu over addi ? Isn't addiu unsigned (and will ruin our calculations?) 回答1: and will ruin our calculations No, MIPS uses two's complement, hence the same instruction for addition/subtraction can be used for both signed and unsigned operations. There's no difference in the result. That's also true for bitwise instructions, non-widening multiplication and many other operations. See Which arithmetic operations are the same on unsigned and two's

Range of immediates in lui instruction

﹥>﹥吖頭↗ 提交于 2019-12-13 04:03:33
问题 I'm not sure what is the range bound for the immediate in lui instruction. When I assemble: lui $t0,32768 It successfully went without errors. However, lui $t0,-32768 notified that -32768 out of range. 回答1: In MIPS the immediate in I-type instructions is always 16-bit long. That means the range will be [0, 65535] if the assembler treats it as unsigned, and [-32768, 32767] for the signed case However what you can use in the assembly depends on the assembler For example some assemblers like

Why would we use addiu instead of addi?

余生颓废 提交于 2019-11-29 02:35:58
In MIPS assembly, what is the benefit of using addiu over addi ? Isn't addiu unsigned (and will ruin our calculations?) and will ruin our calculations No, MIPS uses two's complement , hence the same instruction for addition/subtraction can be used for both signed and unsigned operations. There's no difference in the result. That's also true for bitwise instructions, non-widening multiplication and many other operations. See Which arithmetic operations are the same on unsigned and two's complement signed numbers? Difference between signed and unsigned on bitwise operations The only difference