Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # HoopStats.s
- # Tripp Whaley
- .data
- buffer: .space 256
- inputName:
- .asciiz "Enter player's last name: "
- inputPoints:
- .asciiz "Enter player's points per game: "
- inputMinutes:
- .asciiz "Enter player's minutes per game: "
- done:
- .asciiz "DONE\n"
- newline:
- .asciiz "\n"
- space:
- .asciiz " "
- .align 2
- .globl main
- .text
- main:
- li $v0, 9 # init memory
- li $a0, 264 # null node
- syscall
- move $t6, $v0
- move $s4, $t6
- sw $s4, 0($t6) #s4 is null head, #t7 is the prev pointer
- #t6 is actual storage of node
- loop:
- move $s2, $t6
- move $t0, $v0
- li $v0, 9 # init memory
- li $a0, 264 # 255 string, 1 null character, 4 float, 4 pointer
- syscall
- sw $v0, 260($t6)
- move $t6, $v0 # store string and mem. addr.
- li $v0, 4
- la $a0, inputName #print string prompt
- syscall
- li $v0,8 #take in input
- la $a0, buffer #load byte space into address
- li $a1, 256 # allot the byte space for string
- move $t0,$a0 #save string to t0
- syscall
- move $t4, $zero
- move $t5, $t6
- strloop:
- lw $t7, 0($t0)
- sw $t7, 0($t5)
- addi $t4, $t4, 4
- addi $t0, $t0, 4
- addi $t5, $t5, 4
- blt $t4, 256, strloop
- move $t1, $a0
- # CHECK STRINGS
- # string is in t1 from move above, load DONE\n into a1
- la $t2, done
- add $t1, $zero, $t1
- add $t2, $zero, $t2
- jal myComp
- beq $v0,$zero, exit #check result
- # END CHECK STRINGS
- li $v0, 4
- la $a0, inputPoints
- syscall
- li $v0, 6
- syscall
- mov.s $f2, $f0 # move float points to s2 mov.s and $a0 instead?
- li $v0, 4
- la $a0, inputMinutes
- syscall
- li $v0, 6
- syscall
- mov.s $f3, $f0 # move float minutes to s3
- div.s $f4, $f2, $f3 # store float and mem. addr.
- s.s $f4, 256($t6)
- #sw $t7, 260($t6) # next node?
- #move $t6, $t7
- b loop
- endloop:
- jr $ra
- j exit
- myComp:
- lb $t3($t1)
- lb $t4($t2)
- beqz $t3, check
- beqz $t4, missmatch
- slt $t5, $t3, $t4
- bnez $t5, missmatch
- addi $t1, $t1, 1
- addi $t2, $t2, 1
- j myComp
- check:
- bnez $t4, missmatch
- li $v0, 0
- j exit
- jr $ra
- missmatch:
- addi $v0, $zero, 1
- jr $ra
- sort:
- lw $t0, 260($s4)
- la $t0, 0($t0)
- jal loopSort
- jr $ra
- loopSort:
- la $a0, 0($t0)
- li $v0, 4
- syscall
- la $a0, space
- li $v0, 4
- syscall
- l.s $f0, 256($t0)
- mov.s $f12, $f0
- li $v0, 2
- syscall
- la $a0, newline
- li $v0, 4
- syscall
- lw $t0, 260($t0)
- beq $t0, $zero, end
- la $t0, 0($t0)
- j loopSort
- exit:
- lw $zero, 260($s2) # set DONE node to 0
- jal sort
- li $v0, 10
- syscall
- end :
- li $v0, 10
- syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement