SPIM Programs Question Write and assemble in MIPS assembly l

SPIM Programs Question

Write and assemble in MIPS assembly language using Qtspim

This program receives a single-letter keyboard input at a time. The letter inputs must be lower case a through z (no upper-case or non-letter characters allowed; only lower-case letters). Only one letter must be input at a time; make sure that the character is ONLY a lower-case letter.

[In the data declaration, declare an alphabetized string of letters (named “str”), a-z.]

This program must input a character from the keyboard, determine its place in the string, and make a space in the string for this character, inserting it in the proper alphabetical order. After the alphabetized string of 26 letters, declare a sequence of 30 nulls (using the “.space” directive), as expansion space for the string as you insert characters into the alphabetized list.

At any point, you can ask to print the current string (i.e., with as many letter inserts as have been made so far) by inputting capital P from the keyboard.

Program MUST use a recursive routine to insert the letter in the correct point in the program. Actually, using recursion is not the only way to accomplish this programming task, but it does make it relatively straightforward.

Solution

Answer

   class KeyInputTest
{
public void runTest()
{
KeyInput in = new KeyInput();
System.out.print(\"Type an integer: \");
int n = in.readInteger();
System.out.println(\"Integer was: \" + n);
System.out.print(\"Type a long: \");
long l = in.readLong();
System.out.println(\"Long was: \" + l);
System.out.print(\"Type a double: \");
double d = in.readDouble();
System.out.println(\"Double was: \" + d);
System.out.print(\"Type a float: \");
float f = in.readFloat();
System.out.println(\"float was: \" + f);
System.out.print(\"Type a char: \");
char c = in.readCharacter();
System.out.println(\"char was: \" + c);
c = in.readCharacter();
System.out.print(\"Type a String: \");
String s = in.readString();
System.out.println(\"String was: \" + s);
}
public static void main(String[] args)
{
KeyInputTest inputTest = new KeyInputTest();
inputTest.runTest();
}
}

SPIM Programs Question Write and assemble in MIPS assembly language using Qtspim This program receives a single-letter keyboard input at a time. The letter inpu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site