如何计算 MIPS 汇编中的负数?

How to calculate negative number in MIPS assembly?

我正在尝试编译以下汇编源代码,首先是代码:

#include <xc.h>

.global main
.text

.set noreorder

.ent main 

main:
    
nop /* "no operation"... replace this. */
nop /* "no operation"... replace this. */
nop /* "no operation"... replace this. */
    
addiu $s1, $zero, 22
addiu $s2, $zero, 59
sub   $t2, $s1,   $s2  

.end main 

这是我的问题:

如您所见,$s1 = 22 = 59。所以,22 - 59 = -37

但是当我观察 $t2 变量时它有 4294967259 (十进制)。 我不明白为什么...应该是-37...

这是输出照片:

问题一

如何解决上述问题?

问题二

如何计算负数?

例如,-22 - 33 = - 55

及其源代码:

add $s1, $zero, -22
add $s2, $zero, -10
sub $t2, $s1,   $s2   

但这也行不通。 $s1 类似于 4294967274 十进制..和 $s2 相同..

非常感谢你能帮我解决这个问题。 (我运行编译器调用了MPLAB XIDE)

我不确定问题 1 - 但是,对于问题 2:

addi $s1, $zero, -22
addi $s2, $zero, -10
sub  $t2, $s1,   $s2

这应该可以解决问题。