.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: this mips program doesn't ask for input when i run it
#include<stdio.h>
#include<string.h>
//returns the decimal number according to the roman character
int digit(char c){
int value=0;
switch(c){
case 'I': value = 1; break;
case 'V': value = 5; break;
case 'X': value = 10; break;
case 'L': value = 50; break;
case 'C': value = 100; break;
case 'D': value = 500; break;
case 'M': value = 1000; break;
default: value = -1;
}
return value;
}
int main(){
char roman_Number[1000];
int i=0;
long int number =0;
printf("Enter any roman number (Valid digits are I, V, X, L, C, D,
M): \n");
scanf("%s",roman_Number);
while(roman_Number[i]){
if(digit(roman_Number[i]) < 0){ //for checking whether the given
number is a roman or not
printf("Invalid roman digit : %c",roman_Number[i]);
return 0;
}
if((strlen(roman_Number) -i) > 2){ //for checking the order of
roman numbers
if(digit(roman_Number[i]) < digit(roman_Number[i+2])){
printf("Invalid roman number");
return 0;
}
}
if(digit(roman_Number[i]) >= digit(roman_Number[i+1]))
number = number + digit(roman_Number[i]);
else{
number = number + (digit(roman_Number[i+1]) -
digit(roman_Number[i]));
i++;
}
i++;
}
printf("decimal number is : %ld",number);
return 0;
}
//In your problem roman value for 500 is not mentioned as D->500
.data # This data will serve as our map between the roman # and the decimal numbers. Here, each list will # serve as our...
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...
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...