开发者

MIPS: Can I get unsigned int value from user via syscall?

开发者 https://www.devze.com 2023-04-11 03:12 出处:网络
The title pretty much sums this up. I am writing a program in 32-bit MIPS Assembly Language (using the MARS emulator) for a school project and I\'m having zero luck reading in int values > 2,147,483,6

The title pretty much sums this up. I am writing a program in 32-bit MIPS Assembly Language (using the MARS emulator) for a school project and I'm having zero luck reading in int values > 2,147,483,647.

I spent a decent amount of time hunting around the internet and in my book to no avail. This is not central to the assignment (which, if you happen to know it is impossible, you probably already realized) but curiosity is killing this cat. Now that I've hit this brick wall, I must know for sure.

Notes:

  1. I'm specifically looking for a way to grab an unsigned int as opposed to taking a float or a double.
  2. The standard code for grabbing an int with syscall:

    li $v0, 5
    syscall
    move $t0, $v0
    
  3. The error that occurs when 2 500 000 000 is passed at prompt for integer:

    Error in C:\DEV\....... line 57: Runtime ex开发者_StackOverflow社区ception at 
    0x004000034: invalid integer input (syscall 5)
    

Help me Obi-Wan, you're my only hope!


You'll need to use a different system call -- MARS is throwing the exception, not anything "inside" the MIPS CPU. Try, for instance, syscalls 8 or 12 (read string and read character). Note that, as a result, you'll have to implement a lot more of the parsing yourself to make these work.

Alternatively, you might try reading a double (syscall 7) and converting it to an integer...

There's a full list of MARS syscalls online at:

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

0

精彩评论

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