home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols100 / vol156 / xmr2-1.asm < prev   
Encoding:
Assembly Source File  |  1994-07-13  |  8.3 KB  |  246 lines

  1.  
  2. ; XMR2-1.ASM - XMODEMxx PATCH FILE FOR TRS-80 2/12/16/16B     12/02/83
  3. ;
  4. ;------------------------------------------------------------------------
  5. ; 12/02/83    Adapted for Z80 SIO, CTC as used in TRS-80 2/12/16/16B
  6. ; XMR2-1.ASM                    - Herb Robinson
  7. ;------------------------------------------------------------------------
  8. ;
  9. ; This file adapts XMODEMxx to an external modem.  This particular setup
  10. ; uses Z-80 SIO and CTC chips.    To use, first edit any options desired into
  11. ; XMODEMxx.ASM, then assemble (can use ASM.COM) and load which supplies
  12. ; XMODEMxx.COM.  Then edit this file as needed (check the CONOUT routine
  13. ; if you want to locally see file transfer time and the record count
  14. ; while programs are being sent).  Then assemble (can use ASM.COM) and
  15. ; merge via DDT or SID:
  16. ;
  17. ;    B>DDT XMODEMxx.COM
  18. ;    DDT VERS 2.2
  19. ;    NEXT  PC
  20. ;    1180 0100
  21. ;    -IXMR2-1.HEX        (note the 'I' command)
  22. ;    -R            ('R' loads in the .HEX file)
  23. ;    NEXT  PC
  24. ;    1180 0000
  25. ;    -G0            (return to CP/M)
  26. ;    B>SAVE 16 XMODEMxx.COM    (now have a modified .COM file)
  27. ;
  28. ; NOTE: Save 21 (rather than 16) if LOGCAL is YES
  29. ;
  30. ;=======================================================================
  31. ;
  32. ; 12/02/83 - Renamed to XMR2-1.ASM    - Herb Robinson
  33. ; 11/17/83 - Renamed to XMEX-1.ASM    - Irv Hoff
  34. ; 10/22/83 - Updated to XMODEM77    - Irv Hoff
  35. ; 04/04/83 - Updated to XMODEM74    - Irv Hoff
  36. ; 03/27/83 - Updated to XMODEM73    - Irv Hoff
  37. ; 03/17/83 - Updated to XMODEM72    - Irv Hoff
  38. ; 03/15/83 - Updated to XMODEM71    - Irv Hoff
  39. ;
  40. ; 03/07/83  Added instructions on how to adapt this file to XMODEM70.COM.
  41. ;        Standardized the format.  Added automatic MSPEED from "BYE"
  42. ;        program.  Added CONOUT information.  Adapted from XM70PMMI.
  43. ;                    - Irv Hoff
  44. ;
  45. ;=======================================================================
  46. YES:    EQU    0FFH
  47. NO:    EQU    0
  48. ;
  49. ;=======================================================================
  50. ;
  51. MODDATP: EQU    0F4H        ;data in port
  52. MODDATO: EQU    MODDATP     ;data out port
  53. MODCTLP: EQU    MODDATP+2    ;control/status port
  54. MODSNDB: EQU    04H        ;bit to test for send
  55. MODSNDR: EQU    04H        ;value when ready
  56. MODRCVB: EQU    01H        ;bit to test for receive
  57. MODRCVR: EQU    01H        ;value when ready
  58. ;
  59. RESSTA:  EQU    00010000b    ;Reset ext/status
  60. ;
  61. MODDCDB: EQU    00001000b    ;carrier detect bit
  62. MODDCDA: EQU    00001000b    ;value when active
  63. MODPARE: EQU    00010000b    ;value for parity error
  64. MODOVRE: EQU    00100000b    ;value for overrun error
  65. MODFRME: EQU    01000000b    ;value for framing error
  66. ;
  67.  
  68. LSPEED: EQU    YES        ;yes if using 'BYE' with speed selection
  69.                 ;no if using 'SPEED' manual selection
  70. MSPEED: EQU    3CH        ;location of baud rate factor (set by
  71.                 ;'BYE')  set location in 'BYE' to agree.
  72.                 ;3dh and 3eh often used by newer ver-
  73.                 ;sions of 'ZCPR'.
  74. XSPEED: EQU    5        ;speed for file time transfer without
  75.                 ;auto-set.  use one of the following:
  76.                 ;0=110 1=300 2=450 3=600 4=710 5=1200
  77. BASE:    EQU    100H        ;start of cp/m normal program area
  78. ;
  79. ;-------------------------------------------------------------------
  80. ;
  81. ; Jump table: The jump table must be in exactly the same sequence as the
  82. ; one in XMODEM.  Note the ORG of 103H - This jump table has no jump to
  83. ; 'BEGIN'.
  84.  
  85. ;
  86.      ORG    BASE+3        ;start after 'JMP BEGIN'
  87. ;
  88. CONOUT:  JMP    00000H        ;must be 00000h if not used, see below
  89. PMINIT:  JMP    MINIT        ;initialization routine (if needed)
  90. PUNINIT: JMP    UNINIT        ;undo whatever 'MINIT' did (or return)
  91. PSENDR:  JMP    SENDR        ;send character (via pop psw)
  92. PCAROK:  JMP    CAROK        ;test for carrier
  93. PMDIN:     JMP    MDIN        ;receive data byte
  94. PGETCHR: JMP    GETCHR        ;get character from modem
  95. PRCVRDY: JMP    RCVRDY        ;check receive ready
  96. PSNDRDY: JMP    SNDRDY        ;check send ready
  97. PSPEED:  JMP    SPEED        ;get speed value for file transfer time
  98. PEXTRA1: JMP    EXTRA1        ;extra for custom routine
  99. PEXTRA2: JMP    EXTRA2        ;extra for custom routine
  100. PEXTRA3: JMP    EXTRA3        ;extra for custom routine
  101. ;
  102. ;=======================================================================
  103. ;
  104. ; -- To Display the Record Count on the CRT During Program Transfers --
  105. ;    
  106. ;    This one addition requires some work on the part of the user.
  107. ; When "BYE" is added, CP/M is normally moved lower to accomodate the
  108. ; new program above CP/M.  Whenever BYE is called to enable the RCPM
  109. ; capability, it steals some of the addresses contained in the BIOS jump
  110. ; vector table.  In order to display on the CRT during program transfers
  111. ; you need to get into the BIOS console output routine directly, else
  112. ; what is being displayed also tries to go out the modem.  This is a big
  113. ; NO-NO at that time.  (This cannot be done automatically by XMODEM,
  114. ; since BYE has already taken the address we need to find, by the time
  115. ; XMODEM is automatically activated by the remote station.)
  116. ;
  117. ;    So with the disk containing BYE, but prior to activating BYE, do
  118. ; this:
  119. ;        1) Cold reboot to move CP/M (and BIOS) to the new area
  120. ;            needed when BYE is activated on the same disk.
  121. ;        2) Use DDT and dump the area from 0000H to 0002H.  This
  122. ;            gives the warm reboot address in BIOS.
  123. ;        3) Add 9 Bytes to that address to get your console out-
  124. ;             put jump vector.
  125. ;        4) Pick off the address contained in the jump vector and
  126. ;             install that in "CONOUT", below.  Example of one
  127. ;             system in use:
  128. ;
  129. ;            FIRST, COLD REBOOT WITH DISK CONTAINING "BYE"
  130. ;
  131. ;      0000    C3 03 E0    (location of warm reboot on disk with BYE
  132. ;
  133. ;            PRIOR TO ACTIVATING BYE BUT ON SAME DISK
  134. ;
  135. ;      E003    C3 E9 E0    (BIOS warm reboot jump vector on this disk)
  136. ;      E006    C3 00 E9    (BIOS get console status routine)
  137. ;      E009    C3 B7 E1    (BIOS console input routine)
  138. ;      E00C    C3 D4 E1    (BIOS console output routine)
  139. ;
  140. ;        The address we need is thus E1D4.  Put that below, in
  141. ;        our example it would be:    CONOUT   JMP   0E1D4H
  142. ;
  143. ;
  144. ;    CONOUT:   JMP    00000H    ;If you wish to show the record count
  145. ;                ;during program transfer, fill in this
  146. ;                ;address at 'CONOUT' above.
  147. ;
  148. ;                    - Irv Hoff
  149. ;
  150. ;=======================================================================
  151. ;
  152. ; ---> CAROK - check for presence of carrier.  RET with Z = carrier on
  153. ;
  154. CAROK:    MVI    A,RESSTA
  155.     OUT    MODCTLP
  156.     IN    MODCTLP     ;get status
  157.     ANI    MODDCDB     ;get carrier detect bit
  158.     CPI    MODDCDA     ;test bit
  159.     RET
  160. ;
  161. ;=======================================================================
  162. ;
  163. EXTRA1: RET            ;for later use
  164. EXTRA2: RET            ;for later use
  165. EXTRA3: RET            ;for later use
  166. ;
  167. ;=======================================================================
  168. ;
  169. ; ---> GETCHR - get a character, same as MDIN
  170. ; ---> MDIN - - get a character, same as GETCHR
  171. ;
  172. GETCHR:
  173. MDIN:    IN    MODDATP     ;get character from data in port
  174.     RET
  175. ;
  176. ;=======================================================================
  177. ;
  178. MINIT:    RET            ;no initialization required
  179. ;
  180. ;=======================================================================
  181. ;
  182. ; ---> RCVRDY - check receive ready.  RET with Z = character available.
  183. ;        Return with error code in A-reg.
  184. ;
  185. RCVRDY: MVI    A,10H
  186.     OUT    MODCTLP
  187.     IN    MODCTLP
  188.     PUSH    B        ;save scratch register
  189.     PUSH    PSW        ;stack read reg 0
  190.     MVI    A,01H
  191.     OUT    MODCTLP
  192.     IN    MODCTLP     ;get read reg 1
  193.     ANI    MODFRME+MODOVRE+MODPARE
  194.     MOV    B,A        ;save it for a moment
  195.     POP    PSW
  196.     ANI    MODRCVB     ;isolate ready bit
  197.     CPI    MODRCVR     ;test it
  198.     MOV    A,B        ;get the error code char. back
  199.     POP    B
  200.     RET
  201. ;
  202. ;=======================================================================
  203. ;
  204. ; ---> SENDR - send character
  205. ;
  206. SENDR:    POP    PSW        ;get the character back
  207.     OUT    MODDATO     ;send it to the modem output
  208.     RET
  209. ;
  210. ;=======================================================================
  211. ;
  212. ; ---> SNDRDY - check if ready to send.
  213. ;
  214. SNDRDY: MVI    A,10H        ;select read reg 0
  215.     OUT    MODCTLP
  216.     IN    MODCTLP     ;get status byte
  217.     ANI    MODSNDB     ;isolate ready bit
  218.     CPI    MODSNDR     ;ready to send?
  219.     RET
  220. ;
  221. ;=======================================================================
  222. ;
  223. ; ---> SPEED - sets the time shown for program transfer.
  224. ;
  225. SPEED:     IF    LSPEED
  226.     LDA    MSPEED        ;get index for baud rate from 'BYE'
  227.      ENDIF
  228. ;
  229.      IF    NOT LSPEED
  230.     MVI    A,XSPEED    ;get index for baud rate from 'XSPEED'
  231.      ENDIF
  232. ;
  233.     RET
  234. ;
  235. ;=======================================================================
  236. ;
  237. UNINIT: RET            ;not initialized, so no 'UN-INITIALIZE'
  238. ;
  239. ;=======================================================================
  240. ;
  241. ;
  242.             ;not initialized, so no 'UN-INITIALIZE'
  243. ;
  244. ;=======================================================================
  245. ;