# NOTES: 
# This is RISC-V version; 2020
# Use simulator RARS: https://github.com/TheThirdOne/rars/releases (Download only: rars1_4.jar)
# If unsure about an instruction or system-call (i.e., environment-call), always check:
# [instructions]  https://github.com/TheThirdOne/rars/wiki/Supported-Instructions 
# [system calls]  https://github.com/TheThirdOne/rars/wiki/Environment-Calls 

.data

yournumber:  .asciz "Please enter a number (I'll add a 5 to it): \n"
numsum:      .asciz "Your number added to 5 is: \n"

.globl main
.text
  
main:

  # prompt user to enter a  number at console
  li a7, 4
  la a0, yournumber 
  ecall  
  
  # read integer from console; for that we need to use the Call Number = 5 as
  # described here: https://github.com/TheThirdOne/rars/wiki/Environment-Calls
  # user's int is placed into register a0;
  li a7, 5
  ecall      

  addi t0, a0, 5 # Add the constant value of 5 to the user's number; just a simple example;
  
  # Let user know the result of the addition;
  # first print a string stored in "numsum":
  li a7, 4
  la a0, numsum
  ecall  
  
  # second, print the actual result of addition:
  li a7, 1 # again, see: https://github.com/TheThirdOne/rars/wiki/Environment-Calls !!
  mv a0, t0
  ecall   
  # NOTE: the use of "mv" could have been avoided by simply having the addition
  # earlier place the result directly into register a0 !!

  # exit the program
  li a7, 10 
  ecall
