How to Convert Hex to Decimal in MIPS

MIPS is a 64-bit assembly programming language developed by MIPS Technologies in the early 1980s. The MIPS language is used in embedded systems that can be found in network hardware and video game consoles. MIPS utilizes traditional decimal numbering systems as well as base-16 hexadecimal positional systems. Converting a hexadecimal number to a decimal in MIPS requires the use of a "for loop" that performs a mathematical operation on the original value to calculate the decimal equivalent.

Instructions

    • 1

      Type the following initialization code into the beginning of the MIPS program:

      #include <stdio.h>

    • 2

      Enter the following code into the program to define the conversion variable:

      extern int hexconvert(char* c);

    • 3

      Type the following code into the MIPS program to define the main argument:

      int main(int argc,char **argv)
      {
      int i=0;
      char digits[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','F'};
      }

    • 4

      Construct the loop by entering the following code after the "char digits" declaration:

      for (;i<16;i++)
      {

      }
      return 0;

    • 5

      Enter the following line in between the brackets of the loop:

      printf("%c\t%d\n",digits[i],hexconvert(digits+i));

    • 6

      Compile and run the code to convert any hexadecimal value to a decimal value.

Related Searches:

References

Resources

Comments

Related Ads

Featured