Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Add you macro definition here - do not touch cs47_common_macro.asm"
- #<------------------ MACRO DEFINITIONS ---------------------->#
- # $regD : will contain 0x0 or 0x1 depending on nth bit being 0 or 1
- #$regS: Source bit pattern
- #$regT: Bit position n (0-31)
- .macro extract_nth_bit($regD, $regS, $regT)
- srlv $regD, $regS, $regT
- and $regD, $regD, 0x1
- .end_macro
- # $regD : This the bit pattern in which 1 to be inserted at nth position register to insert to
- # $regS: Value n, from which position the bit to be inserted (0-31) bit position
- # $regT: Register that contains 0x1 or 0x0 (bit value to insert) value to insert
- # $maskReg: Register to hold temporary mask holder
- .macro insert_one_to_nth_bit ($regD, $regS, $regT, $maskReg)
- la $maskReg, 0($regD)
- srlv $regD, $regD, $regS
- and $regD, $regT, 0x1
- sllv $regD, $regD, $regS
- or $regD, $regD, $maskReg
- .end_macro
- .macro invert($toInvert)
- not $toInvert, $toInvert
- addi $toInvert, $toInvert, 1
- .end_macro
- .macro bit_replicator($replicate)
- beq $replicate, 1, MLPR_bit_one
- MLPR_bit_zero:
- li $replicate, 0x0
- j replicate_end
- MLPR_bit_one:
- li $replicate, 0xffffffff
- replicate_end:
- .end_macro
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement