Question

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 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

Edlt Execute 1 dat Line: 99 Column: 22 Show Line Numbe O Type hene to search

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

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 data will serve as our map between t...
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...

    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" #...

  • 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...

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