简体   繁体   English

MIPS 3000汇编,加载和打印32位无符号整数

[英]MIPS 3000 assembly, load and print 32-bit unsigned integer

My program has to accept an input between between 0 and 2^32 or 4,294,967,295. 我的程序必须接受0到2 ^ 32或4,294,967,295之间的输入。

Which bit-wise 32 bytes should be able to do, but i'm overflowing into the negatives because i'm not sure how to make this an unsigned integer. 哪个位32字节应该可以做,但我溢出到负片因为我不知道如何使这个无符号整数。 I see that i have instructions that can do it via arithmetic, but what if i just want to load it into a register and print it? 我看到我有通过算术可以做到的指令,但是如果我只是想将它加载到寄存器并打印它呢? It always prints out the negative number right now. 它总是打印出负数。

Whether the int is signed or unsigned should not matter for how it exists in the register. 无论int是有符号还是无符号,都无论它在寄存器中的存在方式都无关紧要。 Either way it is just a sequence of bits. 无论哪种方式,它只是一个位序列。 2^32 -1 = 0xFFFFFF. 2 ^ 32 -1 = 0xFFFFFF。 If you interpret this as an unsigned integer, this is 4,294,967,295 or 2^32-1. 如果将其解释为无符号整数,则为4,294,967,295或2 ^ 32-1。 If you read it as a signed integer using two's complement, 0xFFFFFFFF is -1. 如果使用二进制补码将其读作有符号整数,则0xFFFFFFFF为-1。 I would guess the problem is in your print command. 我猜这个问题出在你的打印命令中。 Try formatting your print output as unsigned. 尝试将打印输出格式化为无符号。

http://courses.missouristate.edu/KenVollmar/mars/Help/SyscallHelp.html http://courses.missouristate.edu/KenVollmar/mars/Help/SyscallHelp.html

Try service call 36. That prints an unsigned int. 尝试服务调用36.打印unsigned int。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM