assembly code

crypt1c

n00b
Joined
Oct 28, 2004
Messages
1
For anyone who can help me with spim assembly...

I'm trying to input a string from a file using MIPS, every resource i read says to use the following code. And my teacher mentioned using -file ps3.a < hex.txt but everything i do still waits for the user to enter an input... Any advise would help.

I've tried with pcSpim on a windows box and xspim on a linux box and got same result.

li $v0, 8
la $a0, hexInput
li $a1, 10
syscall
 
Is this a problem with SPIM command line arguments or is it a problem with getting the right system calls? If you execute your program with the -file command, does the string show up in the SPIM address space? In other words, are you sure that the string is loading correctly?

It's been a long time, and I don't have a reference handy, but I think 8 is specific to reading the string from the console. Is the idea to get the txt file to replace the standard console?

edit: Just found this site
http://www.utdallas.edu/~hxh017200/mips/QwikRef.html

looks like you need syscalls 13, 14 and 16? to open a file, read the file and then close the file. As a guess, look into something like this.

Code:
li  $v0, 13
la  $a0, fileName
# not sure of values for $a1 and $a2, try 0 to start?
syscall
li  $v0, 14
la  $a1, string  #or wherever you've set asie memory for this string
la  $a2, 10      #replace 10 with the length of the string to read
syscall
li  $v0, 16
syscall

your string shoudl be loaded after that (or something similar).
 
Back
Top