views:

176

answers:

2

Hey all, I'm working on this final thing for my MIPS project and it's deceptively easy. I need to get a procedure (called feed) and let its main driver program use it by reading it in. I know that I'm supposed to use the call code 14 and .globl sym (I think) in order to feed it into the file and have it read it. I just need a basic tutorial or something, as I CANNOT find it on the Internet or in my book (just lists the call code, real helpful). Here's what I know:

I need to use read, but I also need a file descriptor (don't know where to get it). I need to put the buffer in $a1 and the length in $a2.

Well, that's about it. If there's any decent tutorial you could whip up or if there is one online that I don't see let me know please :). I just need a push in the right direction, I'm sure it can't be too difficult, just can't find any info on it!

A: 

Take a look in the syscall documentation you can find online. (I googled "mips syscall" and it's the first result).

Syscall 13 is open a file, to which you pass the filename, and the return is the file descriptor, which you then use to pass to other syscalls. That first result I googled also has a helpful example at the bottom of the page, which explains what flags and mode are.

Tony van der Peet
A: 

That's the thing, it doesn't actually return the descriptor! I've tried several different codes but the register where the file descriptor is returned: $v0, just stays 13... and eventually gives this error: "File descriptor 13 is not open for reading (syscall 14)"

Sulaiman