Advertisement
AnthonyCagliano

Untitled

Dec 4th, 2022
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. _lshiftc:
  2. ; de = dest
  3. ; hl = src
  4. ; a = shift count
  5. push af
  6. and a, 7
  7. jr z, .skip_bitshift
  8. inc a
  9. ld c, a
  10. .loop_nbits:
  11. ld b, 30
  12. push hl,de
  13. or a
  14. .lshift_bits:
  15. ld a, (hl)
  16. rla
  17. ld (de), a
  18. inc hl
  19. inc de
  20. djnz .lshift_bits
  21. pop de,hl
  22. dec c
  23. jr nz, .loop_nbits
  24. .skip_bitshift:
  25. pop af
  26. or a
  27. rra
  28. rra
  29. rra
  30. or a
  31. ret z
  32. ld bc, 0 ; make sure bcu is zeroed
  33. ld c, 30 ; c is total length of region to copy bytes to
  34. ld b, a ; b is number of bytes to set to 0
  35. xor a ; zero a
  36. .zero_nbytes:
  37. ld (de), a
  38. inc de ; increase de
  39. dec c ; decrease c
  40. djnz .zero_nbytes ; should stop when b = 0 and c = remaining bytes to copy
  41. ldir ; hl = LSB of src, de = next byte of dest
  42. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement