Advertisement
AnthonyCagliano

Untitled

Dec 3rd, 2022
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 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 b, 30
  8. ld d, 240
  9. .byte_loop:
  10. ld a, (hl)
  11. or a ; if byte is 0
  12. jr nz, .found_byte
  13. ld a, d
  14. sub a, 8
  15. ld d, a
  16. djnz .byte_loop
  17.  
  18. .found_byte:
  19. ; process bits
  20. ld b, 8
  21. .bit_loop:
  22. rla
  23. jr c, .found_bit
  24. dec d
  25. djnz .bit_loop
  26.  
  27. .found_bit:
  28. dec d
  29. ld a, d
  30. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement