Advertisement
Guest User

Untitled

a guest
May 14th, 2022
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. po = 5
  2. # _ matches fields in table at:
  3. # https://libre-soc.org/openpower/sv/bitmanip/
  4. xo = 0b1_0010_110
  5. if 'w' in opcode:
  6. xo |= 0b100_000
  7. if 'i' in opcode:
  8. xo |= 0b1000_000
  9. Rc = 1 if '.' in opcode else 0
  10. rt = int(fields[0])
  11. ra = int(fields[1])
  12. rb_imm = int(fields[2])
  13. instr = po
  14. instr = (instr << 5) | rt
  15. instr = (instr << 5) | ra
  16. if opcode == 'grevi' or opcode == 'grevi.':
  17. assert 0 <= rb_imm < 64
  18. instr = (instr << 6) | rb_imm
  19. instr = (instr << 9) | xo
  20. else:
  21. assert 0 <= rb_imm < 32
  22. instr = (instr << 5) | rb_imm
  23. instr = (instr << 10) | xo
  24. instr = (instr << 1) | Rc
  25. asm = f"{opcode} {rt}, {ra}, {rb_imm}"
  26. yield f".4byte {hex(instr)} # {asm}"
  27. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement