2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -0,0 +1,51 @@
|
|||
# $a0 char val
|
||||
# $a1 address pointer
|
||||
# $a2 PERIOD_HIT_FLAG
|
||||
# $a3 HAS_DIGITS_FLAG
|
||||
|
||||
.data
|
||||
### CHANGE THIS STRING TO TEST DIFFERENT ONES... ###
|
||||
string: .asciiz "-.1236"
|
||||
s_false: .asciiz "False"
|
||||
s_true: .asciiz "True"
|
||||
.text
|
||||
main:
|
||||
set_up: #test for 0th char == 45 or 46 or 48...57
|
||||
la $a1,string
|
||||
lb $a0,($a1)
|
||||
beq $a0,45,loop # == '-'
|
||||
beq $a0,46,loop # == '.'
|
||||
blt $a0,48,exit_false # isn't below the ascii range for chars '0'...'9'
|
||||
bgt $a0,57,exit_false # isn't above the ascii range for chars '0'...'9'
|
||||
loop:
|
||||
addi $a1,$a1,1
|
||||
lb $a0,($a1)
|
||||
beqz $a0,exit_true # test for \0 null char
|
||||
beq $a0,46,period_test #test for a duplicate period
|
||||
blt $a0,48,exit_false #test for
|
||||
bgt $a0,57,exit_false
|
||||
la $a3,1 #set the HAS_DIGITS flag. This line is only reached because the
|
||||
# tests for period and - both jump back to start.
|
||||
j loop
|
||||
|
||||
exit_true:
|
||||
beqz $a3,exit_false
|
||||
la $a0,s_true
|
||||
la $v0,4
|
||||
syscall
|
||||
|
||||
li $v0,10
|
||||
syscall
|
||||
|
||||
exit_false:
|
||||
la $a0,s_false
|
||||
la $v0,4
|
||||
syscall
|
||||
|
||||
li $v0,10
|
||||
syscall
|
||||
|
||||
period_test:
|
||||
beq $a2,1,exit_false
|
||||
li $a2,1
|
||||
j loop
|
||||
Loading…
Add table
Add a link
Reference in a new issue