#####################################################################
#   Title:   Demonstrate the various syscalls for Input and Output
#   Author:  Bary W Pollack
#   File:    SimpleIO.asm
#   Date:    Apr. 27, 2004 - 01:00
#####################################################################

    .data
str:    .asciiz " My Favorite Number!\n\nEnd of Story\n\nType an int [Enter]: ?"
get:    .asciiz "Please enter a string [Enter]: ?"
buffr: .space   256     # space for 256 characters

#####################################################################

    .globl  main        # make main "global"
    .text

main:
    li      $v0, 1      # syscall code for print int
    li      $a0, -12345 # number to be printed
    syscall

    li      $v0, 4      # syscall code for print string
    la      $a0, str    # pointer to the string to be printed
    syscall

    li      $v0, 5      # syscall code for read int
    syscall

    li      $v0, 4      # syscall code for print string
    la      $a0, get    # pointer to the string to be printed
    syscall

    li      $v0, 8      # syscall code for read string
    li      $a1, 32     # Initial length of the buffer
    la      $a0, buffr  # pointer to the buffer that will hold the string
    syscall

    li      $v0, 1      # print number code
    move    $a0, $a1    # a0 <- a1
    syscall

    li      $v0, 4      # print string code
    la      $a0, buffr
    syscall

    li      $v0, 10     # syscall code for EXIT
    syscall
    .end

#####################################################################

