```## LSU EE 4720 Computer Architecture Fall 2010
#
#

.data
msg:
.asciiz "The value of 0x%/s4/x is %/a1/s\n"
str:
.align 4
.space 12
values:
.word 1234
.word 0x1234
.word 0xf00d
.word -1

.text
.globl __start
__start:
la \$s2, values
MLOOP:
lw \$a0, 0(\$s2)
la \$a1, str
lui \$t0, 0x2020
ori \$t0, \$t0, 0x2020
sw \$t0, 0(\$a1)
sw \$t0, 4(\$a1)
sw \$t0, 8(\$a1)
sb \$0, 11(\$a1)
jal itos
lw \$s4, 0(\$s2)
la \$a1, str
la \$a0, msg
syscall
bne \$s4, \$s3 MLOOP
li \$v0, 10
syscall
nop

###############################################################################
#
# Int to Hex String
#

itos:
## Register Usage
#
# \$a0: CALL VALUE: Integer to convert
#      Initialized as null-terminated string of blanks.
# \$a2: Length of storage.
#
# RETURN:
#      Write storage with hex representation of \$a0.
#
# NOTE: 'a' = 97, 'z' = 122,  'a' - 'A' = 32
# Note: '0' = 48 = 0x30

LOOP:

andi \$t0, \$a0, 0xf

slti \$t3, \$t0, 10  #  t3 = t0 < 10;

bne \$t3, \$0, SKIP

SKIP:

sb \$t0, 0(\$t4)

srl \$a0, \$a0, 4

bne \$a0, \$0 LOOP