sendbyte.z80 356 B

1234567891011121314151617181920212223242526272829303132
  1. SendByte:
  2. ;E is the byte to send
  3. ;BC is the wait length
  4. ld a,3
  5. out (0),a
  6. ld d,a
  7. _:
  8. in a,(0)
  9. and d
  10. jr nz,+_
  11. dec bc
  12. ld a,b
  13. or c
  14. jr nz,-_
  15. dec bc
  16. ret
  17. _:
  18. ld b,8
  19. SendByteLoop:
  20. ;E is the byte to send
  21. ;D is the mask
  22. xor a
  23. rlc e
  24. jr c,+_ ;could use rla
  25. inc a
  26. _:
  27. out (0),a
  28. djnz SendByteLoop
  29. xor a
  30. out (0),a
  31. ld c,a
  32. ret