Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .text
- .globl __start
- __start:
- # f1 = 0.0
- l.s $f1, zero_float
- # Counter for floats with non-biased exp.
- li $t0, 0
- while:
- # Read float on $f0
- jal read_float
- # If $f0 == 0.0, exit
- c.eq.s $f0, $f1
- bc1t exit
- # Move the binary directly to s0
- mfc1 $s0, $f0
- # Move the exp bits from 30:23 to 6:0
- sll $s0, $s0, 1
- srl $s0, $s0, 24
- # unbiased exp = exp - 127
- sub $s0, $s0, 127
- # If unbiased exp > 0, then increment counter
- bge $s0, $zero, add_one
- # Else jump back to loop
- j while
- add_one:
- add $t0, $t0, 1
- j while
- exit:
- # Print message
- la $a0, message
- jal print_string
- # Print counter
- move $a0, $t0
- jal print_int
- li $v0, 10
- syscall
- #
- # Functions
- #
- # Prints $a0
- print_int: li $v0, 1
- syscall
- jr $ra
- # Prints $f12
- print_float: li $v0, 2
- syscall
- jr $ra
- # Prints $a0
- print_string: li $v0, 4
- syscall
- jr $ra
- # Outputs float in $f0
- read_float: li $v0, 6
- syscall
- jr $ra
- #
- # Data
- #
- .data
- zero_float: .float 0.0
- message: .asciiz "Floats with non-biased exponent: "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement