开发者

MIPS Assembler Instruction parameters

why does such a instruction as

mul   $t1, $v0 , 4 

evaluates as expected. But

mul   $t1, 4 , $v0 

results in a syntax error!

I wonder why the first one works, because mul only works with registers per default, so I expect that only a solution like this will be workin

li   $t1, 4             # set $t1 = 4
mul   $t1,开发者_JAVA技巧 $v0 , $t1      # set $t1 = 4 * n

I'm using the SPIM simulator.


Ok, I would suggest looking at the opcode output. Perhaps the multiply by 4 is being swapped for adds or perhaps sll immediate for speed purposes. The 4,reg version may not be caught via this 'optimization' and that is why it is throwing an error.


This results in a syntax error simply because MIPS only supports the pseudo-instruction mul [rs] [rt] [imm], and not mul [rs] [imm] [rt]. I'm assuming it does this for consistency because there is no real instruction in MIPS that supports an immediate value in the middle of an instruction.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜