Advertisement
AnthonyCagliano

Untitled

Apr 1st, 2023
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. _ll_swap_bytes:
  2. ; de = u8[8]
  3. ; reverses the bytes of a u8[8]
  4. pop bc, de
  5. push de, bc
  6. ld hl, 7
  7. ld c, l
  8. add hl, bc
  9. add hl, de
  10. ld b, 4
  11. .loop:
  12. ld a, (de)
  13. ldi
  14. dec hl
  15. ld (hl), a
  16. dec hl
  17. djnz .loop
  18. ret
  19.  
  20.  
  21. _bytelen_to_bitlen:
  22. ; hl = size
  23. ; iy = dst
  24. ; converts a size_t to a u8[8]
  25. ; outputs in big endian
  26. pop bc, hl, iy
  27. push iy, hl, bc
  28. xor a, a
  29. add hl, hl
  30. rla
  31. add hl, hl
  32. rla
  33. add hl, hl
  34. rla
  35. ld (iy + 6), h
  36. ld (iy + 7), l
  37. ld h, a
  38. ld l, 0
  39. ld (iy + 3), hl
  40. sbc hl, hl
  41. ld (iy + 0), hl
  42. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement