문제

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 exception 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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top