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.

46 lines
930B

  1. .equ COM_DRV_ADDR 0x0238 ; replace with *CL's DCB addr
  2. .equ DEST_ADDR 0x3000 ; memory address where to put contents.
  3. ; We process the 0x20 exception by pre-putting a mask in the (HL) we're going
  4. ; to write to. If it wasn't a 0x20, we put a 0xff mask. If it was a 0x20, we
  5. ; put a 0x7f mask.
  6. ld hl, DEST_ADDR
  7. loop:
  8. ld a, 0xff
  9. ld (hl), a ; default mask
  10. loop2:
  11. ld a, 0x03 ; @GET
  12. ld de, COM_DRV_ADDR
  13. rst 0x28
  14. jr nz, maybeerror
  15. or a
  16. ret z ; Sending a straight NULL ends the comm.
  17. ; @PUT that char back
  18. ld c, a
  19. ld a, 0x04 ; @PUT
  20. rst 0x28
  21. jr nz, error
  22. ld a, c
  23. cp 0x20
  24. jr z, escapechar
  25. ; not an escape char, just apply the mask and write
  26. and (hl)
  27. ld (hl), a
  28. inc hl
  29. jr loop
  30. escapechar:
  31. ; adjust by setting (hl) to 0x7f
  32. res 7, (hl)
  33. jr loop2
  34. maybeerror:
  35. ; was it an error?
  36. or a
  37. jr z, loop2 ; not an error, just loop
  38. ; error
  39. error:
  40. ld c, a ; Error code from @GET/@PUT
  41. ld a, 0x1a ; @ERROR
  42. rst 0x28
  43. ret