Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
615B

  1. ld hl, 0x3040 ; memory address where to put contents.
  2. loop:
  3. ld a, 0x03 ; @GET
  4. ld de, 0xffff ; replace with *CL's DCB addr
  5. rst 0x28
  6. jr nz, maybeerror
  7. or a
  8. ret z ; Sending a straight NULL ends the comm.
  9. ; @PUT that char back
  10. ld c, a
  11. ld a, 0x04 ; @PUT
  12. ld de, 0xffff ; replace with *CL's DCB addr
  13. rst 0x28
  14. jr nz, error
  15. ld a, c
  16. cp 0x20
  17. jr z, adjust
  18. write:
  19. ld (hl), a
  20. inc hl
  21. jr loop
  22. adjust:
  23. dec hl
  24. ld a, (hl)
  25. and 0x7f
  26. jr write
  27. maybeerror:
  28. ; was it an error?
  29. or a
  30. jr z, loop ; not an error, just loop
  31. ; error
  32. error:
  33. ld c, a ; Error code from @GET/@PUT
  34. ld a, 0x1a ; @ERROR
  35. rst 0x28
  36. ret