Last active
September 28, 2016 17:41
-
-
Save bestknighter/fa3969c3776af0954f7693762902bf04 to your computer and use it in GitHub Desktop.
(MIPS) Macros for loading immediate integers into Coprocessor 1's floating point registers in MARS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.macro li.s (%f_reg, %value) | |
addi $sp, $sp, -4 # sp++ | |
li $at, %value # at = %value | |
sw $at, ($sp) # push(at) | |
lwc1 %f_reg, ($sp) # %f_reg = pop() | |
addi $sp, $sp, 4 # sp-- | |
cvt.s.w %f_reg,%f_reg # %f_reg = (float)%f_reg | |
.end_macro | |
.macro li.d (%f_reg, %value) | |
addi $sp, $sp, -4 # sp++ | |
li $at, %value # at = %value | |
sw $at, ($sp) # push(at) | |
lwc1 %f_reg, ($sp) # %f_reg = pop() | |
addi $sp, $sp, 4 # sp-- | |
cvt.d.w %f_reg,%f_reg # %f_reg = (double)%f_reg | |
.end_macro |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment