Question

Batch numeric conversion: Using the code from Pgm2, create a batch conversion process which reads input...

Batch numeric conversion: Using the code from Pgm2, create a batch conversion process which reads input data (input type, input data, and output type) from a file but still outputs to the console window. For MARS, the input files are expected in the same directory (folder) where MARS resides, by default. Since the input values are not naturally displayed in the console, this program needs to reflect the input from the file as well as outputting the converted value.

Upload code and report here.

Here's the program 2 description for reference:

Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal.

1. Request input data type.

2. Request input data.

3. Request output data type.

4. Output the data.

Upload code and report here.

Homework Answers

Answer #1

# convert between decimal and hexadecimal.

data

prompt: .asciiz "Enter the decimal number to convert: "

ans: .asciiz "\nHexadecimal equivalent: "

result: .space 8

.text

.globl main

main:

la $a0, prompt

li $v0, 4

syscall

li $v0, 5

syscall

move $t2, $v0 la $a0, ans

li $v0, 4

syscall

li $t0, 8 # counter

la $t3, result # where answer will be stored

Loop: beqz $t0, Exit # branch to exit if counter is equal to zero

rol $t2, $t2, 4 # rotate 4 bits to the left

and $t4, $t2, 0xf # mask with 1111

ble $t4, 9, Sum # if less than or equal to nine, branch to sum addi $t4, $t4, 55

# if greater than nine, add 55

b End

Sum: addi $t4, $t4, 48 # add 48 to result

End: sb $t4, 0($t3) #store hex digit into result

addi $t3, $t3, 1 # increment address counter

addi $t0, $t0, -1 # decrement loop counter

j Loop
Exit:

la $a0, result li $v0, 4

syscall

la $v0, 10

syscall

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal....
Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal. 1. Request input data type. 2. Request input data. 3. Request output data type. 4. Output the data. The suggested approach was to take the input data as a string. But I am really lost as to how to process the string and then converting it to another data type. Thanks for the help!
Each part of this lab will use the same input file, named “lab3-in.dat.” This file will...
Each part of this lab will use the same input file, named “lab3-in.dat.” This file will be located in the same directory as the executables (do not specify a path for the file in the Select statements). This file is a roster of animals in a travelling carnival. The record format for the file is as follows: Field Description Length Data Type Name 12 String Gender 1 String Species 15 String The end result of each part of this assignment...
Write a C++ program that converts time of day from a 24-hour notation to a 12-hour...
Write a C++ program that converts time of day from a 24-hour notation to a 12-hour notation. For example, it should convert 14:25 to 2:25 PM. (A) The user provides input as two integers separated by ‘:’. The following function prototype should capture the user inputs as described below: void input(int& hours24, int& minutes); //Precondition: input(hours, minutes) is called with //arguments capable of being assigned values. //Postcondition: // user is prompted for time in 24 hour format: // HH:MM, where...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input operator>> a bigint in the following manner: Read in any number of digits [0-9] until a semi colon ";" is encountered. The number may span over multiple lines. You can assume the input is valid. Overload the operator+ so that it adds two bigint together. Overload the subscript operator[]. It should return the i-th digit, where i is the 10^i position. So the first...
please can you make it simple. For example using scanner or hard coding when it is...
please can you make it simple. For example using scanner or hard coding when it is a good idea instead of arrays and that stuff.Please just make one program (or class) and explain step by step. Also it was given to me a txt.htm 1.- Write a client program and a server program to implement the following simplified HTTP protocol based on TCP service. Please make sure your program supports multiple clients. The webpage file CS3700.htm is provided. You may...
Finish the CustomerAccountTransactions program that reads customer accounts receivable data from a file and then applies...
Finish the CustomerAccountTransactions program that reads customer accounts receivable data from a file and then applies a series of transactions to the accounts. Its main() method uses the CustomerAccounts class to manage a collection of CustomerAccount objects: reading customer accounts data & transactions, and obtaining a String showing the customer accounts data after the operations are complete. You will need to complete the readCustomerAccounts () and applyTransactions() methods in the CustomerAccounts class. First, please fill in your name in the...
Cpp Task: Create a class called Mixed. Objects of type Mixed will store and manage rational...
Cpp Task: Create a class called Mixed. Objects of type Mixed will store and manage rational numbers in a mixed number format (integer part and a fraction part). Details and Requirements Your class must allow for storage of rational numbers in a mixed number format. Remember that a mixed number consists of an integer part and a fraction part (like 3 1/2 – “three and one-half”). The Mixed class must allow for both positive and negative mixed number values. A...