Advertisement
AnthonyCagliano

Untitled

Dec 3rd, 2022
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. _get_degree:
  2. ; input: hl = ptr to binary polynomial (little endian-encoded)
  3. ; degree in a
  4. ; destroys: bc, flags
  5. ld bc, 29
  6. add hl, bc
  7. ld c, 30
  8. .byte_loop:
  9. ld a, (hl)
  10. or a ; if byte is 0
  11. jr nz, .found_byte
  12. ld a, d
  13. sub a, 8
  14. ld d, a
  15. dec hl
  16. dec c
  17. jr nz .byte_loop
  18. ; exit
  19. ld a, -1
  20. ret
  21.  
  22. .found_byte:
  23. ; process bits
  24. ld b, 8
  25. .bit_loop:
  26. rla
  27. jr c, .found_bit
  28. dec d
  29. djnz .bit_loop
  30.  
  31. .found_bit:
  32. ld a, c
  33. dec a
  34. dec b
  35. add a, a
  36. add a, a
  37. add a, a
  38. or a, b
  39. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement