[SOLVED] CS # test_02.s

$25

File Name: CS_#_test_02.s.zip
File Size: 131.88 KB

5/5 - (1 vote)

# test_02.s
#
# A testcase for Asm 2.

.data

.globl fib
fib:
.word0

.globl square
.globl square_size
.globl square_fill
square:
.word1
square_size:
.word10
square_fill:
.byteH

.globl runCheck
runCheck:
.word0

.globl intArray_len
.globl intArray
intArray_len:
.word7
intArray:
.word-10
.word-4
.word0
.word1
.word8
.word34
.word43

.globl countWords
countWords:
.word0

.globl revString
revString:
.word0

.globl str
str:.asciiz Hello world
Hello world

# main()
.text

.globlmain
main:
# call the student code
jalstudentMain

.data
MAIN_HEAD_MSG:
.asciiz Dumping out all of the variables, after the student code ran:

MAIN_LABEL_fib: .asciiz fib:
MAIN_LABEL_square:.asciiz square:
MAIN_LABEL_square_size: .asciiz square_size:
MAIN_LABEL_square_fill: .asciiz square_fill:
MAIN_LABEL_runCheck:.asciiz runCheck:
MAIN_LABEL_countWords:.asciiz countWords:
MAIN_LABEL_revString: .asciiz revString:
MAIN_LABEL_str: .asciiz str:
MAIN_LABEL_intArray_len:.asciiz intArray_len:
MAIN_LABEL_intArray:.asciiz intArray[]:

MAIN_TAIL_MSG:
.asciiz Testcase end

.text

# print_str(HEAD_MSG)
addi$v0, $zero,4
la$a0, MAIN_HEAD_MSG
syscall

# print_str(LABEL_fib)
addi$v0, $zero,4
la$a0, MAIN_LABEL_fib
syscall

# print_int(fib)
addi$v0, $zero,1
la$a0, fib
lw$a0, 0($a0)
syscall

# print_chr(
)
addi$v0, $zero,11
addi$a0, $zero,

syscall

# print_str(LABEL_square)
addi$v0, $zero,4
la$a0, MAIN_LABEL_square
syscall

# print_int(square)
addi$v0, $zero,1
la$a0, square
lw$a0, 0($a0)
syscall

# print_chr(
)
addi$v0, $zero,11
addi$a0, $zero,

syscall

# print_str(LABEL_square_size)
addi$v0, $zero,4
la$a0, MAIN_LABEL_square_size
syscall

# print_int(square_size)
addi$v0, $zero,1
la$a0, square_size
lw$a0, 0($a0)
syscall

# print_chr(
)
addi$v0, $zero,11
addi$a0, $zero,

syscall

# print_str(LABEL_square_fill)
addi$v0, $zero,4
la$a0, MAIN_LABEL_square_fill
syscall

# print_int(square_fill)
addi$v0, $zero,1
la$a0, square_fill
lb$a0, 0($a0)
syscall

# print_chr(
)
addi$v0, $zero,11
addi$a0, $zero,

syscall

# print_str(LABEL_runCheck)
addi$v0, $zero,4
la$a0, MAIN_LABEL_runCheck
syscall

# print_int(runCheck)
addi$v0, $zero,1
la$a0, runCheck
lw$a0, 0($a0)
syscall

# print_chr(
)
addi$v0, $zero,11
addi$a0, $zero,

syscall

# print_str(LABEL_countWords)
addi$v0, $zero,4
la$a0, MAIN_LABEL_countWords
syscall

# print_int(countWords)
addi$v0, $zero,1
la$a0, countWords
lw$a0, 0($a0)
syscall

# print_chr(
)
addi$v0, $zero,11
addi$a0, $zero,

syscall

# print_str(LABEL_revString)
addi$v0, $zero,4
la$a0, MAIN_LABEL_revString
syscall

# print_int(revString)
addi$v0, $zero,1
la$a0, revString
lw$a0, 0($a0)
syscall

# print_chr(
)
addi$v0, $zero,11
addi$a0, $zero,

syscall

# print_str(LABEL_str)
addi$v0, $zero,4
la$a0, MAIN_LABEL_str
syscall

# print_int(str)
addi$v0, $zero,4
la$a0, str
syscall

# print_chr()
addi$v0, $zero,11
addi$a0, $zero,’
syscall

# print_chr(
)
addi$v0, $zero,11
addi$a0, $zero,

syscall

# print_str(LABEL_intArray_len)
addi$v0, $zero,4
la$a0, MAIN_LABEL_intArray_len
syscall

# print_int(intArray_len)
addi$v0, $zero,1
la$a0, intArray_len
lw$a0, 0($a0)
syscall

# print_chr(
)
addi$v0, $zero,11
addi$a0, $zero,

syscall

# Dump out intArray[]
#
# for (int i=0; i = intArray_len) break

# print_chr( ) twice
addi$v0, $zero,11
addi$a0, $zero,
syscall
syscall

sll $t8, $t2,2# t8 = i*4
add $t8, $t0,$t8# t8 = &intArray[i]

# print_int(intArray[i])
addi$v0, $zero,1
lw$a0, 0($t8)
syscall

# print_chr(
)
addi$v0, $zero,11
addi$a0, $zero,

syscall

addi$t2, $t2,1# i++
j MAIN_LOOP
MAIN_LOOP_DONE:

# print_str(TAIL_MSG)
addi$v0, $zero,4
la$a0, MAIN_TAIL_MSG
syscall

# sys_exit()
addi$v0, $zero,10
syscall

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS # test_02.s
$25