0
votes

So if mips syscalls are R-type instructions, that means they should have an opcode and a funct code, correct?

I understand the opcode should be binary 0x000000 since it's an R-type instruction, but how do I find the funct code for various mips syscalls?

I need to know the funct codes for these syscalls:

syscall #print integer
syscall #print string
syscall #terminate

I've only found one resource across the web that has a funct code but it seems general: https://www.d.umn.edu/~gshute/mips/rtype.xhtml

It says the funct code for syscall is : 001100

Is this really the funct code for all three of those ^? (print int, print string, terminate)

I don't think it should be but I'm not completely sure.

1

1 Answers

1
votes

syscall function numbers are passed in a register, e.g. $v0 for the MARS toy system calls you're talking about. https://courses.missouristate.edu/KenVollmar/MARS/Help/SyscallHelp.html It's up to software in the syscall handler to implement them (on a real MIPS system).

The call-number is not encoded in the syscall instruction itself; that's why syscall takes no operands in asm syntax, and why you need li $v0, 1 ahead of syscall to get the print-integer behaviour.

The funct field of the R-type encoding of syscall is 001100, assuming that page you linked is correct. That has absolutely nothing to do with what the system-call handler does based on looking at $v0.