lui $t1, 0x1001
addi $t1, $t1, 0x0c addi $t1, $t1, 12 ori $t1, $t1, 0x000c
lui $t1, 0x1001 ori $t1, $t1, 0x002c
ori $t1, $t0, 8 -- or -- addi $t1, $t0, 8
sw $t2, 4($t0)
lb $t3, 11($t0)
lw $t3, 4($t0) addi $t3, $t3, 1 sw $t3, 4($t0)
lw $t1, length lw $t2, width mult $t1, $t2 mflo $t3 sw $t3, area
lw $a0, area li $v0, 1 syscall
lui $t0, 0x1001 lw $t1, 0($t0) lw $t2, 4($t0) mult $t1, $t2 mflo $t3 sw $t3, 8($t0)
lui $t0, 0x1001 lw $a0, 8($t0) li $v0, 1 syscall
enter three numbers: 3 4 5 the number is: 12 the number is: 60
10 14 18 22 26
lui $t0, 0x1001 li $t1, 100 # loop limit move $t2, $0 # loop counter move $t3, $t0 # addr of nums loop: li $v0, 4 # code to print string ori $a0, $t0, 508 # addr of prompt syscall li $v0, 5 # code to read an int syscall sw $v0, 0($t3) # store the int in the array addi $t3, $t3, 4 # move to next array element addi $t2, $t2, 1 # increment loop counter blt $t2, $t1, loop # keep looping till $t2 == 100
lui $t0, 0x1001 li $t1, 100 # loop limit move $t2, $0 # loop counter move $t3, $t0 # addr of nums loop: li $v0, 4 # code to print string ori $a0, $t0, 508 # addr of prompt syscall li $v0, 5 # code to read an int syscall beqz $v0, done # if user enters zero, stop reading sw $v0, 0($t3) # store the int in the array addi $t3, $t3, 4 # move to next array element addi $t2, $t2, 1 # increment loop counter blt $t2, $t1, loop # keep looping till $t2 == 100 done: sw $t2, 404($t0) # store number of numbers entered in count
lui $t0, 0x1001 li $t1, 100 # loop limit move $t2, $0 # loop counter move $t3, $t0 # addr of current array element li $v0, 1 # syscall code to print int loop: bge $t2, $t1, done lw $a0, 0($t3) # current array element in $a0 syscall # print current array element addi $t2, $t2, 1 # increment loop counter addi $t3, 4 # move down to next array element b loop done:
lui $t0, 0x1001 li $t1, 50 # loop limit move $t2, $0 # loop counter move $t3, $t0 # addr of current array element li $v0, 1 # syscall code to print int loop: bge $t2, $t1, done lw $a0, 0($t3) # current array element in $a0 syscall # print current array element addi $t2, $t2, 1 # increment loop counter addi $t3, 8 # move down two array elements b loop done:
lui $t0, 0x1001 li $t1, 100 # loop limit move $t2, $0 # loop counter move $t3, $t0 # addr of current array element lw $t4, 0($t0) # first element is largest so far loop: bge $t2, $t1, done lw $t5, 0($t3) # current array element in $t5 ble $t5, $t4, nobig # check for bigger than so far move $t4, $t5 # save new biggest nobig: addi $t2, $t2, 1 # increment loop counter addi $t3, 4 # move to next array element b loop done: li $v0, 1 move $a0, $t4 syscall # print largest
lui $t0, 0x1001 li $t1, 100 # loop limit move $t2, $0 # loop counter move $t3, $t0 # addr of first array element add $t3, 396 # addr of last array element li $v0, 1 # syscall code to print int loop: bge $t2, $t1, done lw $a0, 0($t3) # current array element in $a0 syscall # print current array element addi $t2, $t2, 1 # increment loop counter addi $t3, $t3, -4 # move back to prev array element b loop done:
lui $t0, 0x1001 li $t1, 100 # loop limit move $t2, $0 # loop counter addi $t3, $t0, 408 # addr of mychars loop: li $v0, 11 # code to print a char lbu $a0, 0($t3) # load char from array into $a0 syscall addi $t3, $t3, 1 # move to next array element addi $t2, $t2, 1 # increment loop counter blt $t2, $t1, loop # keep looping till $t2 == 100
lui $t0, 0x1001 li $t1, 100 # loop limit move $t2, $0 # loop counter addi $t3, $t0, 408 # addr of mychars li $t4, 0x61 # ascii code for 'a' ori $t5, $0, 0 # $t5 = 0, count of a's loop: lbu $t6, 0($t3) # load array element bne $t6, $t4, noa # jump around if char is not a addi $t5, $t5, 1 # add to number of a's noa: addi $t3, $t3, 1 # move to next array element addi $t2, $t2, 1 # increment loop counter blt $t2, $t1, loop # keep looping till $t2 == 100 move $v0, 1 # code to print an int move $a0, $t5 # print num of a's syscall
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2021