# echo2.asm # # Written by: Dan Stearns # For: CPE 315 # Date: 11/17/02 # # Modifications: # 2/28/08 - removed loop counter; used byte instructions # # # This program echos characters forever on the SPIM console # using the SPIM memory-mapped I/O. # # Notes: # 1. To run: xspim -noexception -mapped_io echo.asm # .globl __start # bit 0 is the ready bit RCVR_CONTROL = 0xffff0000 .ktext __start: # load Receiver control address la $t0, RCVR_CONTROL # poll for an input character poll: lbu $t4, 0($t0) and $t4, $t4, 1 beq $t4, 0, poll # get the character lbu $t5, 4($t0) # echo the character to console hang: lbu $t4, 8($t0) and $t4, $t4, 1 beq $t4, 0, hang sb $t5, 0xC($t0) # go wait for next character beq $0,$0,poll