Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. # Add you macro definition here - do not touch cs47_common_macro.asm"
  2. #<------------------ MACRO DEFINITIONS ---------------------->#
  3.  
  4. # $regD : will contain 0x0 or 0x1 depending on nth bit being 0 or 1
  5. #$regS: Source bit pattern
  6. #$regT: Bit position n (0-31)
  7. .macro extract_nth_bit($regD, $regS, $regT)
  8. srlv $regD, $regS, $regT
  9. and $regD, $regD, 0x1
  10. .end_macro
  11.  
  12. # $regD : This the bit pattern in which 1 to be inserted at nth position register to insert to
  13. # $regS: Value n, from which position the bit to be inserted (0-31) bit position
  14. # $regT: Register that contains 0x1 or 0x0 (bit value to insert) value to insert
  15. # $maskReg: Register to hold temporary mask holder
  16. .macro insert_one_to_nth_bit ($regD, $regS, $regT, $maskReg)
  17. la $maskReg, 0($regD)
  18. srlv $regD, $regD, $regS
  19. and $regD, $regT, 0x1
  20. sllv $regD, $regD, $regS
  21. or $regD, $regD, $maskReg
  22. .end_macro
  23.  
  24. .macro invert($toInvert)
  25. not $toInvert, $toInvert
  26. addi $toInvert, $toInvert, 1
  27. .end_macro
  28.  
  29.  
  30. .macro bit_replicator($replicate)
  31. beq $replicate, 1, MLPR_bit_one
  32. MLPR_bit_zero:
  33. li $replicate, 0x0
  34. j replicate_end
  35.  
  36. MLPR_bit_one:
  37. li $replicate, 0xffffffff
  38. replicate_end:
  39. .end_macro
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement