reading integer in mips mars 4.5 - mips

i'm new to mips, stucking at the reading integer lesson.
the code is:
li $v0, 5
syscall
when I click compile all, the program just keep running and won't stop (showing by the pause and the stop button light up, in contrast with the run one line, run all, back one line, back all buttons).
When I click the run one line through the whole things, it show an error
Step: execution terminated due to null instruction.
Error in C:(TH) KTMT\TH2\mips1.asm line 2: Runtime exception at 0x00400004: invalid integer input (syscall 5)
Step: execution terminated with errors.
It was supposed to show a table to let me input data. can the problem come from my mars? cause I'm pretty sure the code is correct.

My mars haven't check in the box: "Settings -> Popup dialog for input syscalls (5,6,7,8,12)", tha's all guys

Related

Can you set an artificial starting point in your code in Octave?

I'm relatively new to using Octave. I'm working on a project that requires me to collect the RGB values of all the pixels in a particular image and compare them to a list of other values. This is a time-consuming process that takes about half a minute to run. As I make edits to my code and test it, I find it annoying that I need to wait for 30 seconds to see if my updates work or not. Is there a way where I can run the code once at first to load the data I need and then set up an artificial starting point so that when I rerun the code (or input something into the command window) it only runs a desired section (the section after the time-consuming part) leaving the untouched data intact?
You may set your variable to save into a global variable,
and then use clear -v instead of clear all.
clear all is a kind of atomic bomb, loved by many users. I have never understood why. Hopefully, it does not close the session: Still some job for quit() ;-)
To illustrate the proposed solution:
>> a = rand(1,3)
a =
0.776777 0.042049 0.221082
>> global a
>> clear -v
>> a
error: 'a' undefined near line 1, column 1
>> global a
>> a
a =
0.776777 0.042049 0.221082
Octave works in an interactive session. If you run your script in a new Octave session each time, you will have to re-compute all your values each time. But you can also start Octave and then run your script at the interactive terminal. At the end of the script, the workspace will contain all the variables your script used. You can type individual statements at the interactive terminal prompt, which use and modify these variables, just like running a script one line at the time.
You can also set breakpoints. You can set a breakpoint at any point in your script, then run your script. The script will run until the breakpoint, then the interactive terminal will become active and you can work with the variables as they are at that point.
If you don't like the interactive stuff, you can also write a script this way:
clear
if 1
% Section 1
% ... do some computations here
save my_data
else
load my_data
end
% Section 2
% ... do some more computations here
When you run the script, Section 1 will be run, and the results saved to file. Now change the 1 to 0, and then run the script again. This time, Section 1 will be skipped, and the previously saved variables will be loaded.

use python to simulate sending user input to spim

I am trying to write a program in python that can run
SPIM
and send user input to the SPIM subroutine
I tried using
mips=subprocess("spim",stdin=PIPE, stdout=output.txt, stderr=output.txt)
mips.stdin.write(b"10")
mips.stdin.write(b"15")
mips.stdin.write(b"15")
but it completely skipped waiting for user input
Here is what the mips subroutine is supposed to do
enter first value: 10
enter second value: 15
enter third value: 15
your Sum is: 40
this works correctly when i call it from terminal and enter values myself but if i run it as a subprocess it prints the following
enter first value:
enter second value:
enter third value:
your Sum is: 101515
the 101515 appears to be printing after spim execution completes
what can i do to programatically enter values into the spim virtual machine
If it helps SPIM is pts not tty
To programmatically send input to spin you place the values in a text file and pipe in
Each value on a new line
So if the mips prompts were
"Enter string"
"Enter digit"
The text file must look as follows with each separate input on its own line
My string input
127
And in terminal you type the following
spim asm-name.s < input-file.txt

Changing the Default Editor on Octave comes with an Error Message

I changed my default Octave editor to Notepad++ with the following lines:
EDITOR('C:\Octave\Octave-5.2.0\notepad++\notepad++.exe');
edit ("editor", sprintf ("%s %%S", EDITOR()))
edit mode async
Notepad pops up when I write edit and it works fine. But every time I open Octave CLI, following errors come up:
error: The EDITOR option of edit has been removed. Use EDITOR() directly.
error: called from
edit at line 165 column 9
C:\Users\emiry\.octaverc at line 8 column 1
How can I change the editor without triggering an error?
the warning is coming from the second line
edit ("editor", sprintf ("%s %%S", EDITOR()))
if you look at help edit
you will notice that editor is not used anymore.
The setting is your first line
EDITOR('C:\Octave\Octave-5.2.0\notepad++\notepad++.exe');

How to type text into Vim's command-line without executing it?

My context:
I frequently take notes in VIM. I'd like a VIM function to type a standard-header into the command line (specifically, a timestamp such as :sav 20180418_) without executing; control would return with VIM still in command-mode (so that user could append remainder of the filename and execute).
My fundamental difficulty: I cannot seem to get a Vim function/macro to enter command-mode, supply text to the command line, then exit while staying in command-mode and not executing the text supplied.
Is this possible?
Thank you.
You can use expand() function. For example if you are currently editing file 20180418_.txt you can type:
:sav <c-r>=expand("%:r")<cr>
where <c-r>= should be typed as Ctrl+R followed by =. Enter key is <cr>. This will expand the text in the command line into:
:sav 20180418_

tcl : exit or error without displaying code?

We have an 'exit -1' command inside a conditional which is nested down inside a few more levels of conditionals.
On redhat linux 5.8, after exiting at the 'exit -1', all of the surrounding / enclosing lines of code are displayed, all the way up to the top level enclosing conditional / enclosing set of braces.
We see the same behavior when using 'error' in place of 'exit'.
Is there a way to suppress this display?
The manual says "exit terminates the running process", so if this causes code to be displayed your setup must be more complex than you said.
Guessing: your script is executed by another script, the first one blows up at receiving returncode 255 (result of exit -1).
Using error would cause a stack trace to be shown - expected behavior.