home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / turbods / xm-td.lbr / TDPAT.ASM < prev    next >
Encoding:
Assembly Source File  |  1985-02-09  |  2.9 KB  |  163 lines

  1. ; TDPAT - patch file for TurboDOS / XMODEM
  2. ; uses COMM port
  3. ;
  4. ; EDITED: 07/14/84    SFK
  5. ;
  6. BASE    EQU    100H        ;start of TPA
  7. ;
  8. PORT    EQU    0        ;0=modem port, 1=console port
  9. ;
  10. ;-------------------------------------------------------------------
  11. ;
  12. ; Jump table: The jump table must be in exactly the same sequence
  13. ; as the one in XMODEM. Note the ORG of 103H - This jump table has
  14. ; no jump to BEGIN.
  15. ;
  16.     ORG    BASE+3    ;start after JMP BEGIN
  17. ;
  18.     if    port
  19. CONOUT:    JMP    0000    ;console out vector (MUST BE JMP 0 IF NOT IMPLEM.)
  20.     else
  21. CONOUT:    JMP    COUT
  22.     endif
  23. PMINIT:    JMP    MINIT    ;initialize whatever has to be (or do RET)
  24. PUNINIT:JMP    UNINIT    ;undo whatever MINIT did (or RET)
  25. PSENDR:    JMP    SENDR    ;send data byte on stack (POP PSW / OUT)
  26. PCAROK:    JMP    CAROK    ;test for carrier. RET Z=ok, NZ=no carrier
  27. PMDIN:    JMP    MDIN    ;receive data byte
  28. PGETCHR:JMP    GETCHR    ;must point to a RET
  29. PRCVRDY:JMP    RCVRDY    ;check receive ready RET Z=ready
  30. PSNDRDY:JMP    SNDRDY    ;check send ready RET Z=ready
  31. PSPEED:    JMP    SPEED    ;get speed factor in ACC
  32. PSPARE1:JMP    SPARE    ;3 jumps for custom routines
  33. PSPARE2:JMP    SPARE
  34. PSPARE3:JMP    SPARE
  35. ;
  36. ;-----------------------------------------------------------------------
  37. ;
  38. GETCHR:            ;no garbage collection done
  39. SPARE:            ;for later use
  40.     RET
  41. MINIT:    mvi    c,41    ;turn off ^@ via a user-defined func
  42.     mvi    b,0
  43.     mvi    h,92h
  44.     mvi    l,0
  45.     jmp    50h
  46. ;
  47. UNINIT:    mvi    c,41    ;re-enable ^@
  48.     mvi    b,0
  49.     mvi    h,92h
  50.     mvi    l,1
  51.     jmp    50h
  52. ;
  53. ; SNDRDY - check if ready to send
  54. ;
  55. SNDRDY:    xra    a    ;assume always ready
  56.     ret
  57. ;
  58.     if    not port
  59. COUT:    push    b
  60.     push    d
  61.     push    h
  62.     mvi    d,1
  63.     jmp    go
  64.     endif
  65. ;
  66. ; SENDR - send character
  67. ;
  68. SENDR:    pop    psw
  69.     push    b
  70.     push    d
  71.     push    h
  72.     mov    e,a
  73.     mvi    d,port
  74. go:    mvi    c,36
  75.     call    50h
  76.     pop    h
  77.     pop    d
  78.     pop    b
  79.     ret
  80. ;
  81. ; RCVRDY - check receive ready
  82. ; RET with Z = character available.
  83. ; return error code in A
  84. ;
  85. RCVRDY:    push    b
  86.     push    d
  87.     push    h
  88.     mvi    c,34
  89.     mvi    d,port
  90.     call    50h
  91.     pop    h
  92.     pop    d
  93.     pop    b
  94.     ora    a
  95.     jnz    rdy
  96.     mvi    a,0afh
  97. rdy    equ    $-1
  98.     ora    a
  99.     ret
  100. ;
  101. ; MDIN - receive a character (GETCHR is identical)
  102. ;
  103. MDIN:    push    b
  104.     push    d
  105.     push    h
  106.     mvi    c,35
  107.     mvi    d,port
  108.     call    50h
  109.     pop    h
  110.     pop    d
  111.     pop    b
  112.     ret
  113. ;
  114. ; SPEED - This routine returns the speed code.
  115. ; 0=110, 1=300, 2=450, 3=600, 4=710, 5=1200
  116. ; Load your speed byte from low memory, or
  117. ; simply MVI A,n and RET for default speed only
  118. ;
  119. ; the following will work correctly for 300 and 1200:
  120. ;
  121. SPEED:    push    b
  122.     push    d
  123.     push    h
  124.     mvi    c,38
  125.     mvi    d,port
  126.     call    50h
  127.     lxi    h,table
  128.     ani    0fh
  129.     add    l
  130.     mov    l,a
  131.     mvi    a,0
  132.     adc    h
  133.     mov    h,a
  134.     mov    a,m
  135.     pop    h
  136.     pop    d
  137.     pop    b
  138.     ret
  139. ;
  140. ; table for baud rates (110,300,600,1200,2400,4800,9600,19200)
  141. ; invalid entries return 110 baud
  142. ;
  143. table:    db    0,0,0,0,0,1,3,5,0,0,6,0,7,0,8,9
  144. ;
  145. ; CAROK - check for presence of carrier.
  146. ; RET with Z = carrier on
  147. ;
  148. CAROK:    push    b
  149.     push    d
  150.     push    h
  151.     mvi    c,40
  152.     call    50h
  153.     pop    h
  154.     pop    d
  155.     pop    b
  156.     xri    20h
  157.     ani    20h
  158.     RET
  159.     END
  160.     mvi    d,port
  161.     call    50h
  162.     pop    h
  163.     pop