How to Read Characters in MIPS

The MIPS assembly language is a low-level programming language for processor development. Assembly is fast because it requires no compilation and works with a processor's native instruction set. However, programming in assembly requires knowledge of how to construct simple system calls that higher-level languages abstract from the programmer, such as input. For example, getting character input from the user requires loading values into appropriate registers and then manually forcing a system call from the computer.

Things You'll Need

  • MIPS emulator
  • Text editor
Show More

Instructions

    • 1

      Create the data for the program that will hold the character:

      .data:
      Character:
      .space 2
      .text

    • 2

      Load the integer "8" into the $v0 register, which the processor checks for system call values:

      .main:
      li $v0, 8

    • 3

      Load the reference for the "Character" variable into register $a0:

      la $a0, Character

    • 4

      Set the character limit to 1 in the $a1 register and then make the system call:

      li $a1, 2
      syscall

Related Searches:

References

Comments

Related Ads

Featured