daily pastebin goal
41%
SHARE
TWEET

linkSend

Zeda Sep 20th, 2017 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define bcall(x) rst 28h \ .dw x
  2. .db $BB,$6D
  3. .org $9D95
  4.     ld hl,teststr
  5.     ld bc,teststr_end-teststr
  6.     call sendBytes
  7.     ld hl,str_success
  8.     jr c,$+5
  9.     ld hl,str_fail
  10.     bcall(450Ah)
  11.     bcall(452Eh)
  12.     ret
  13. str_success:
  14. .db "Send success!",0
  15. str_fail:
  16. .db "Send failed :(",0
  17. teststr:
  18. .db "This is a test."
  19. teststr_end:
  20. ;==============================================
  21. ;==============================================
  22. ;==============================================
  23. sendBytes:
  24. ;Input:
  25. ;   HL points to the bytes to send
  26. ;   BC is the number of bytes to send
  27. ;Output:
  28. ;   BC is the number of bytes remaning to be sent
  29. ;   HL points to the bytes to be sent
  30. ;   c is set upon success
  31. ;   nc if failure
  32.     push hl
  33.     push bc
  34.     ld a,c
  35.     call sendByte
  36.     pop bc
  37.     push bc
  38.     ld a,b
  39.     call c,sendByte
  40.     jp nc,sendBytes_fail
  41.     or a
  42.     .db $C2
  43. sendBytes_loop
  44.     push hl
  45.     push bc
  46.     ld a,(hl)
  47.     call sendByte
  48. sendBytes_fail:
  49.     pop bc
  50.     pop hl
  51.     ret nc
  52.     cpi
  53.     jp pe,sendBytes_loop
  54.     scf
  55.     ret
  56. sendByte:
  57. ;   c is set upon success
  58. ;   nc if failure
  59.     di
  60.     ld e,a
  61.     ld bc,$5503  ;Bit counter in b, bit mask in c
  62.     ld a,%00000010
  63.     out (0),a   ;Indicate we are ready to send
  64. _:
  65.     in a,(4)
  66.     and 8
  67.     jr z,_sendByte_ret
  68.     in a,(0)   ;Loop is 59 T-states maximum
  69.     and c
  70.     jr nz,-_
  71.     out (0),a
  72. _:
  73.     rrc e
  74.     ccf
  75.     rla
  76.     sla b
  77.     ccf
  78.     rla
  79.     out (0),a
  80.     ex (sp),hl
  81.     ex (sp),hl
  82.     nop
  83.     jr nz,-_
  84. ;need 37cc
  85.     push hl
  86.     pop hl
  87.     scf
  88.     sbc a,a
  89.     inc a
  90.     nop
  91. _sendByte_ret
  92.     out (0),a
  93.     ret
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top