Question

This is a mips assemble language code and it won't take user inpit .data # This...

This is a mips assemble language code and it won't take user inpit

.data

# This data will serve as our map between the roman

# and the decimal numbers. Here, each list will

# serve as our makeshift "array", where the conversion

# from decimal to roman will be according to each indice,

# i.e. decimalNumeral[i] will dictate romanNumeral[i].

# This also will be useful when converting roman to

# decimal, as romanNumeral[i] will dictate decimalNumeral[i]

decimalNumeral: .word 1000 100 50 10 5 1 # the decimal map

romanNumeral: .asciiz "MDCLXVI" # the roman map

# Request the user for a roman numeral.

req: .asciiz "Roman Numeral: "

# The error message that will be displayed if the

# format is invalid or contains a token that is not

# a valid roman/decimal numeral.

err: .asciiz "Input contains invalid tokens or format"

.text

.globl main

main:

jal conversion

conversion:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshot

----------------------------------------------------------------------------------

Program

.data

# This data will serve as our map between the roman

# and the decimal numbers. Here, each list will

# serve as our makeshift "array", where the conversion

# from decimal to roman will be according to each indice,

# i.e. decimalNumeral[i] will dictate romanNumeral[i].

# This also will be useful when converting roman to

# decimal, as romanNumeral[i] will dictate decimalNumeral[i]

decimalNumeral: .word 1000 100 50 10 5 1 # the decimal map

romanNumeral: .asciiz "MCLXVI" # the roman map

# Request the user for a roman numeral.

req: .asciiz "Roman Numeral: "

# The error message that will be displayed if the

# format is invalid or contains a token that is not

# a valid roman/decimal numeral.

err: .asciiz "Input contains invalid tokens or format"

.text

.globl main

main:
    #Prompt for roman numeral
    addi $v0,$0,4
    la $a0,req
    syscall
    #Read roman numeral
    addi $v0,$0,12
    syscall
    #Move character into a0 for function call
    move $a0,$v0
    #Address of roman array
    la $a1,romanNumeral
     #Address of decimal array
    la $a2,decimalNumeral
    #Call conversion function
    jal conversion
    #End of the program
    addi $v0,$0,10
    syscall
#Conversion function implementation
conversion:
     #First roman numeral in t0
     lb $t0,($a1)
     #Counter for index of array
     addi $t1,$0,0
#Loop until end of numeral array
Loop:
     #If not found until end call error message display part
     beq $t0,0,error
     #Check numeral array data and user input are equal
     #Equal gotto result display part
     beq $t0,$a0,result
     #Otherwise increment address for next eleemnt in numeral array
     addi $a1,$a1,1
     #Increment index
     addi $t1,$t1,1
     #Get value
     lb $t0,($a1)
     #Repeat
     j Loop
#Display decimal corresponding to roman numeral
result:
     #For ptinting next line
     addi $v0,$0,11
     addi $a0,$0,10
     syscall
     #Display decimal
     addi $v0,$0,1
     #For getting correct index of array
     mul $t1,$t1,4
     add $a2,$a2,$t1
     lw $a0,($a2)
     syscall
     j return
#Display error message
error:
     addi $v0,$0,11
     addi $a0,$0,10
     syscall
    addi $v0,$0,4
    la $a0,err
    syscall
#Return from function
return:
    jr $ra

---------------------------------------

Output

Roman Numeral: M
1000
-- program is finished running --

Add a comment
Know the answer?
Add Answer to:
This is a mips assemble language code and it won't take user inpit .data # This...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is a mips assemble language code and it won't take user inpit .data # This data will serve as our map between t...

    This is a mips assemble language code and it won't take user inpit .data # This data will serve as our map between the roman # and the decimal numbers. Here, each list will # serve as our makeshift "array", where the conversion # from decimal to roman will be according to each indice, # i.e. decimalNumeral[i] will dictate romanNumeral[i]. # This also will be useful when converting roman to # decimal, as romanNumeral[i] will dictate decimalNumeral[i] decimalNumeral: .word 1000...

  • .data # This data will serve as our map between the roman # and the decimal numbers. Here, each list will # serve as our...

    .data # This data will serve as our map between the roman # and the decimal numbers. Here, each list will # serve as our makeshift "array", where the conversion # from decimal to roman will be according to each indice, # i.e. decimalNumeral[i] will dictate romanNumeral[i]. # This also will be useful when converting roman to # decimal, as romanNumeral[i] will dictate decimalNumeral[i] decimalNumeral: .word 1000 100 50 10 5 1 # the decimal map romanNumeral: .asciiz "MDCLXVI" #...

  • Can someone code this asap? Use any language that you want. 2. Ancestral Names Given a...

    Can someone code this asap? Use any language that you want. 2. Ancestral Names Given a list of strings comprised of a name and a Roman numeral, sort the list first by name, then by decimal value of the Roman numeral. In Roman numerals, a value is not repeated more than three times. At that point, a smaller value precedes a larger value to indicate subtraction. For example, the letter I represents the number 1, and Vrepresents 5. Reason through...

  • MIPS ASSEMBLY LANGUAGE Write MIPS code to convert binary to decimal: (01110001)2 to (113)10 .data   binary_digit:  ...

    MIPS ASSEMBLY LANGUAGE Write MIPS code to convert binary to decimal: (01110001)2 to (113)10 .data   binary_digit:       .word       0 1 1 1 0 0 0 1       # is 113 in decimal .globl main main: # Load arguments to argument registers # Call convert()      # Print return value # (it's in $v0, make sure to copy it before overwriting to print)        # Properly end program    convert: # This label is where conversion of the current...

  • i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due...

    i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due Sunday, 19 May 2019, 11:59 PM Due Friday, 24 May 2019, 11:59 PM Part B: Minimum Submission Requirements Ensure that your Lab4 folder contains the following files (note the capitalization convention): o Diagram.pdf o Lab4. asm O README.txt Commit and push your repository Lab Objective In this lab, you will develop a more detailed understanding of how...

  • Here is the code I have so far. I'm trying to figure out how to implement...

    Here is the code I have so far. I'm trying to figure out how to implement a boolean and use precedence. The 2nd expression should be 14 but it comes out as 28 so I'm definitely not understanding. #include <stack> #include <iostream> #include <string> using namespace std; // Function to find precedence of // operators. int precedence(char op) {    if (op == '+' || op == '-')        return 1;    if (op == '*' || op ==...

  • Computer Architecture Project Description: farh-to-cel.asm : # Revised and added code taken from Hennesey and Patterson...

    Computer Architecture Project Description: farh-to-cel.asm : # Revised and added code taken from Hennesey and Patterson 5th edition # to work with this simulator. # # Prompts a user to enter a Fahrenheit temperature as a floating point. # Displays the converted temperature in Celcius. # 10/28/2015 .data const5: .float 5.0 # store a floating point constant 5.0 const9: .float 9.0 const32: .float 32.0 .align 2 # align the next string on a word boundary .space 100 prompt: .asciiz "Please...

  • Write a program called EventManager, that allows a user to search for 9-1-1 incidents recorded in Seattle The data is g...

    Write a program called EventManager, that allows a user to search for 9-1-1 incidents recorded in Seattle The data is given to you in file Seattle_911_Incidents.csv which contains 500 records (a subset of the approximately 53,000 911 calls made in Seattle in the years 2015-2017). This dataset is the Police responses to 9-1-1 calls within the city during the 2015-2017 years. You can get the full data set from http://data.seattle.gov. The data consists of 500 rows, where each row is...

  • I NEED SAMPLE PRINT OUT AS WELL AS CODE PLEASE!!!! Objectives: To gain experience with stacks....

    I NEED SAMPLE PRINT OUT AS WELL AS CODE PLEASE!!!! Objectives: To gain experience with stacks. Documentation: Explain the purpose of the program as detail as possible - 8%. Develop a solution for the problem and mention algorithms to be used -12% List data structures to be used in solution. - 5%. Give a description of how to use the program and expected input/output - 5% Explain the purpose of each class you develop in the program. - 5%. Programming:...

  • Hello, I have some errors in my C++ code when I try to debug it. I...

    Hello, I have some errors in my C++ code when I try to debug it. I tried to follow the requirements stated below: Code: // Linked.h #ifndef INTLINKEDQUEUE #define INTLINKEDQUEUE #include <iostream> usingnamespace std; class IntLinkedQueue { private: struct Node { int data; Node *next; }; Node *front; // -> first item Node *rear; // -> last item Node *p; // traversal position Node *pp ; // previous position int size; // number of elements in the queue public: IntLinkedQueue();...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT