home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / d / k6ker.src < prev    next >
Text File  |  2020-01-01  |  409KB  |  8,100 lines

  1. <<< k6gsys.asm >>>
  2. *         Kermit68K: source file K68SYS
  3. *
  4. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  5. * Bologna University, Physics Department, July 1987.
  6. *
  7. * All rights reserved to Bologna University, Italy.
  8. *
  9. * Permission is granted to any individual or institution
  10. * to use, copy, or redistribute this software so long as
  11. * it  is not  sold for  profit, provided  this copyright
  12. * notice is retained.
  13. *
  14. * Modification History:
  15. *
  16. * Version  Date    Who              Comments
  17. *
  18. * 1.0.00   870701  Roberto Bagnara  First official release
  19.  
  20. ********************************* InpChar *****************************
  21. *                                                                     *
  22. *  Try to read a character from the specified logical channel.        *
  23. *                                                                     *
  24. *         Entry conditions : D1.B logical channel number              *
  25. *                                                                     *
  26. *         Exit  conditions : D0.B character received, if any          *
  27. *                            D1.B Completion Code (see below)         *
  28. *                                                                     *
  29. *              CC symbol        Meaning                               *
  30. *                                                                     *
  31. *              AllOk            No errors, character in D0            *
  32. *              BadChan          Inexistent channel                    *
  33. *              ResChan          Access reserved, permission denied    *
  34. *              DevNotRd         Device not ready (e.g. unmounted)     *
  35. *              NotInpCh         Input impossible on this channel      *
  36. *              NotOpRd          File not open for read                *
  37. *              UnrInpF          Unrecoverable failure during input    *
  38. *              InChLost         Input character lost                  *
  39. *              InpBreak         Break received on input               *
  40. *              BufEmpty         Input buffer empty                    *
  41. *              BufOvflw         Input buffer overflow                 *
  42. *              EndOfFil         End of file reached on input          *
  43. *                                                                     *
  44. ***********************************************************************
  45. InpChar:  RTS
  46.  
  47. ********************************* OutChar *****************************
  48. *                                                                     *
  49. *  Try to write a character to the specified logical channel.         *
  50. *                                                                     *
  51. *         Entry conditions : D0.B character to write                  *
  52. *                            D1.B logical channel number              *
  53. *                                                                     *
  54. *         Exit  conditions : D0.B character just sent                 *
  55. *                            D1.B Completion Code (see below)         *
  56. *                                                                     *
  57. *              CC symbol        Meaning                               *
  58. *                                                                     *
  59. *              AllOk            No errors                             *
  60. *              BadChan          Inexistent channel                    *
  61. *              ResChan          Access reserved, permission denied    *
  62. *              DevNotRd         Device not ready (e.g. unmounted)     *
  63. *              NotOutCh         Output impossible on this channel     *
  64. *              NotOpWr          File not open for write               *
  65. *              UnrOutF          Unrecoverable failure during output   *
  66. *              DevFull          Device full, not enough space         *
  67. *                                                                     *
  68. ***********************************************************************
  69. OutChar:  RTS
  70.  
  71. ********************************* ChanCtrl ****************************
  72. *                                                                     *
  73. *  Performs control operations on logical channels.                   *
  74. *                                                                     *
  75. *         Entry conditions : D0.B Request Code (see below)            *
  76. *                                                                     *
  77. *              RC symbol        Meaning                               *
  78. *                                                                     *
  79. *              SetBaud          Set baud rate on port                 *
  80. *              RawMode          Enable raw mode                       *
  81. *              TextMode         Enable text mode                      *
  82. *              DoXCntrl         Enable XON/XOFF protocol              *
  83. *              NoXCntrl         Disable XON/XOFF protocol             *
  84. *              SndBreak         Send a break over RS 232 C line       *
  85. *              ClrInpBf         Clear input buffer                    *
  86. *              ClrOutBf         Clear output buffer                   *
  87. *                                                                     *
  88. *                            D1.B channel number                      *
  89. *                            D2.L additional data (only requested     *
  90. *                                 baud rate now)                      *
  91. *                                                                     *
  92. *         Exit  conditions : D0.B Completion Code (see below)         *
  93. *                                                                     *
  94. *              CC symbol        Meaning                               *
  95. *                                                                     *
  96. *              AllOk            No errors                             *
  97. *              BadChan          Inexistent channel                    *
  98. *              ResChan          Access reserved, permission denied    *
  99. *              DevNotRd         Device not ready (e.g. unmounted)     *
  100. *              BadCtReq         I/O control request code invalid      *
  101. *                                                                     *
  102. ***********************************************************************
  103. ChanCtrl: RTS
  104.  
  105. ********************************* SysInit *****************************
  106. *                                                                     *
  107. *  Initialize any system dependent thing.                             *
  108. *                                                                     *
  109. *         Entry conditions : none                                     *
  110. *                                                                     *
  111. *         Exit  conditions : none                                     *
  112. *                                                                     *
  113. ***********************************************************************
  114. SysInit:  RTS
  115.  
  116. ********************************* SysExod *****************************
  117. *                                                                     *
  118. *  Return control to system.                                          *
  119. *                                                                     *
  120. *         Entry conditions : D0.B completion code, exit status        *
  121. *                                                                     *
  122. *         Exit  conditions : none                                     *
  123. *                                                                     *
  124. ***********************************************************************
  125. SysExod:
  126.  
  127. ********************************** System *****************************
  128. *                                                                     *
  129. *  Performs system commands. Called with a request code and 0, 1 or 2 *
  130. *  null terminated argument strings, depending on request code.       *
  131. *                                                                     *
  132. *         Entry conditions : D0.B Request Code (see below)            *
  133. *                                                                     *
  134. *         RC symbol             Meaning                               *
  135. *                                                                     *
  136. *         Directry              Display a directory listing           *
  137. *         SpacInfo              Display informations about disk usage *
  138. *         DeletFil              Delete file(s)                        *
  139. *         CopyFile              Copy file(s)                          *
  140. *         ChangDir              Change the default directory          *
  141. *         PrntFile              Print file(s)                         *
  142. *         RenamFil              Rename file(s)                        *
  143. *         TypeFile              Type file(s)                          *
  144. *                                                                     *
  145. *                            A0.L pointer to argument 1 (see below)   *
  146. *                            A1.L pointer to argument 2 (see below)   *
  147. *                                                                     *
  148. *         RC symbol             Arguments number and meaning          *
  149. *                                                                     *
  150. *         Directry              0 or 1  directory path                *
  151. *         SpacInfo              0 or 1  device or account name        *
  152. *         DeletFil              1       file name                     *
  153. *         CopyFile              2       source and target file names  *
  154. *         ChangDir              0 or 1  path to new directory         *
  155. *         PrntFile              1       file name                     *
  156. *         RenamFil              2       old and new file names        *
  157. *         TypeFile              1       file name                     *
  158. *                                                                     *
  159. *         Exit  conditions : D0.B completion code                     *
  160. *                                                                     *
  161. ***********************************************************************
  162. System:   RTS
  163.  
  164. ******************************** GetCmdLP *****************************
  165. *                                                                     *
  166. *  Try to return a pointer to the command line, null terminated.      *
  167. *                                                                     *
  168. *         Entry conditions : none                                     *
  169. *                                                                     *
  170. *         Exit  conditions : A0.L pointer to the command line, if any *
  171. *                            D0.B completion code                     *
  172. *                                                                     *
  173. ***********************************************************************
  174. GetCmdLP  RTS
  175.  
  176. ********************************* FilOpen *****************************
  177. *                                                                     *
  178. *  Open a disk file or an I/O channel.                                *
  179. *                                                                     *
  180. *         Entry conditions : D0.B Request Code (see below)            *
  181. *                                                                     *
  182. *              RC symbol        Meaning                               *
  183. *                                                                     *
  184. *              RdWrOp           Open for read/write                   *
  185. *              ReadOp           Open for read                         *
  186. *              WriteOp          Open for write                        *
  187. *              AppendOp         Open for append                       *
  188. *                                                                     *
  189. *                            D1.B logical channel number.             *
  190. *                            A0.L points to file name null terminated *
  191. *                                                                     *
  192. *         Exit  conditions : D0.B completion code                     *
  193. *                            A0.L still points to the file name       *
  194. *                                                                     *
  195. ***********************************************************************
  196. FilOpen:  RTS
  197.  
  198. ******************************** FilClose *****************************
  199. *                                                                     *
  200. *  Close a disk file or an I/O channel.                               *
  201. *                                                                     *
  202. *         Entry conditions : D1.B logical channel number.             *
  203. *                                                                     *
  204. *         Exit  conditions : D0.B completion code                     *
  205. *                                                                     *
  206. ***********************************************************************
  207. FilClose: RTS
  208.  
  209. ********************************* FilDelet ****************************
  210. *                                                                     *
  211. *  Delete a file.                                                     *
  212. *                                                                     *
  213. *         Entry conditions : A0.L points to file name null terminated *
  214. *                                                                     *
  215. *         Exit  conditions : D0.B completion code                     *
  216. *                                                                     *
  217. ***********************************************************************
  218. FilDelet: RTS
  219.  
  220. ********************************* ExpandFN ****************************
  221. *                                                                     *
  222. *  Expand a wildcard file name into an array of file names, returns   *
  223. *  the number of files that match the passed string, with data        *
  224. *  structures set up so that the first file name (if any) will be     *
  225. *  returned by the next GetNxtF call.                                 *
  226. *                                                                     *
  227. *         Entry conditions : A0.L points to file name null terminated *
  228. *                                                                     *
  229. *         Exit  conditions : D0.L number of matches found, negative   *
  230. *                                 if too many matches for user buffer *
  231. *                            A0.L still points to the file name       *
  232. *                                                                     *
  233. ***********************************************************************
  234. ExpandFN: RTS
  235.  
  236. ********************************* GetNxtF *****************************
  237. *                                                                     *
  238. *  Get the next file name from the list created by ExpandFN, returns  *
  239. *  a true completion code if there's another file, copying its name   *
  240. *  into the target string, or false if no more file names in list.    *
  241. *                                                                     *
  242. *         Entry conditions : A0.L points to the target string         *
  243. *                                                                     *
  244. *         Exit  conditions : D0.B completion code                     *
  245. *                            A0.L points to the target string         *
  246. *                                                                     *
  247. ***********************************************************************
  248. GetNxtF:  RTS
  249.  
  250. ********************************* CRemTLoc ****************************
  251. *                                                                     *
  252. *  Convert filenames from remote system in a form suitable for the    *
  253. *  local system.                                                      *
  254. *                                                                     *
  255. *         Entry conditions : A0.L points to the string to be          *
  256. *                                 converted                           *
  257. *                                                                     *
  258. *         Exit  conditions : A0.L points to the same string suitably  *
  259. *                                 converted                           *
  260. *                                                                     *
  261. ***********************************************************************
  262. CRemTLoc: RTS
  263.  
  264. ********************************* CLocTRem ****************************
  265. *                                                                     *
  266. *  Convert filenames in local system syntax in a form suitable for    *
  267. *  the remote Kermit system. The job that this routine must do is     *
  268. *  explained here in detail.                                          *
  269. *                                                                     *
  270. *  Adapted from the "Kermit Protocol Manual", Sixth Edition, p. 16    *
  271. *                                                                     *
  272. *   1. Delete all pathnames and attributes from the file              *
  273. *      specification. The file name should not contain directory      *
  274. *      or device names; if it does, it may cause the recipient to     *
  275. *      try to store the file in an inaccessible or nonexistent area,  *
  276. *      or it may result in a very strange filename.                   *
  277. *                                                                     *
  278. *   2. After stripping any pathname, convert the remainder of the     *
  279. *      file specification to the form "name.type", with no            *
  280. *      restriction on length (except that it fit in the data field    *
  281. *      of the F packet), and:                                         *
  282. *                                                                     *
  283. *         a. Include no more than one dot.                            *
  284. *         b. Not begin or end with a dot.                             *
  285. *         c. The name and type fields contain digits and uppercase    *
  286. *            letters only.                                            *
  287. *                                                                     *
  288. *         Entry conditions : A0.L points to the string to be          *
  289. *                                 converted                           *
  290. *                                                                     *
  291. *         Exit  conditions : A0.L points to the same string suitably  *
  292. *                                 converted                           *
  293. *                                                                     *
  294. ***********************************************************************
  295. CLocTRem: RTS
  296.  
  297. ********************************** NewName ****************************
  298. *                                                                     *
  299. *  Make a new name for the given file to avoid file name collisions.  *
  300. *                                                                     *
  301. *         Entry conditions : A0.L points to the file name string      *
  302. *                                                                     *
  303. *         Exit  conditions : A0.L points to the same string suitably  *
  304. *                                 modified                            *
  305. *                                                                     *
  306. ***********************************************************************
  307. NewName:  RTS
  308.  
  309. ********************************** Sleep ******************************
  310. *                                                                     *
  311. *  Puts the process to sleep.                                         *
  312. *                                                                     *
  313. *         Entry conditions : D0.B time interval to wait (seconds)     *
  314. *                                                                     *
  315. *         Exit  conditions : none                                     *
  316. *                                                                     *
  317. ***********************************************************************
  318. Sleep:    RTS
  319.  
  320.           END
  321. <<< k6ocm2.asm >>>
  322.           nam       Kermit68K
  323.           ttl       SET command subroutines module
  324.  
  325. *         Kermit68K: source file K68CM2
  326. *
  327. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  328. * Bologna University, Physics Department, July 1987.
  329. *
  330. * All rights reserved to Bologna University, Italy.
  331. *
  332. * Permission is granted to any individual or institution
  333. * to use, copy, or redistribute this software so long as
  334. * it  is not  sold for  profit, provided  this copyright
  335. * notice is retained.
  336. *
  337. * Modification History:
  338. *
  339. * Version  Date    Who              Comments
  340. *
  341. * 1.0.00   870701  Roberto Bagnara  First official release
  342.  
  343.           use       DefsFile
  344.  
  345. Edition   equ       0
  346.           psect     K68Commands2,0,0,Edition,0,0
  347.  
  348. DoSET:    LEA       SETTable(PC),A1    Pointer to SET parameters table
  349.           ST        D1
  350.           BSR       ParsKyW            Look for a valid SET parameter
  351.           TST.B     D0                 Ok ?
  352.           BLT.S     DoSET1             No, return
  353.           LEA       DoSetTab(PC),A1    Pointer to SET jump table
  354.           BRA       IndxJump           Join common jump routine
  355. DoSET1    RTS
  356.  
  357. DoSSEND:  LEA       SSRTable(PC),A1    Point to SET SEND/RECEIVE params table
  358.           ST        D1
  359.           BSR       ParsKyW            Look for a valid SET SEND/RECEIVE param
  360.           TST.B     D0                 Ok ?
  361.           BLT.S     DoSSEND1           No, return
  362.           LEA       DoSetSTb(PC),A1    Pointer to SET SEND jump table
  363.           BRA       IndxJump           Join common jump routine
  364. DoSSEND1  RTS
  365.  
  366. DoSRECV:  LEA       SSRTable(PC),A1    Point to SET SEND/RECEIVE params table
  367.           ST        D1
  368.           BSR       ParsKyW            Look for a valid SET SEND/RECEIVE param
  369.           TST.B     D0                 Ok ?
  370.           BLT.S     DoSRECV1           No, return
  371.           LEA       DoSetRTb(PC),A1    Pointer to SET RECEIVE jump table
  372.           BRA       IndxJump           Join common jump routine
  373. DoSRECV1  RTS
  374.  
  375. DoSFILE:  LEA       SFILTabl(PC),A1    Point to SET FILE parameters table
  376.           ST        D1
  377.           BSR       ParsKyW            Look for a valid SET FILE parameter
  378.           TST.B     D0                 Ok ?
  379.           BLT.S     DoSFILE1           No, return
  380.           LEA       DoSFlTab(PC),A1    Pointer to SET FILE jump table
  381.           BRA       IndxJump           Join common jump routine
  382. DoSFILE1  RTS
  383.  
  384. DoSRTRY:  LEA       SRETTabl(PC),A1    Point to SET RETRY parameters table
  385.           ST        D1
  386.           BSR       ParsKyW            Look for a valid SET RETRY parameter
  387.           TST.B     D0                 Ok ?
  388.           BLT.S     DoSRTRY1           No, return
  389.           LEA       DoSRtTab(PC),A1    Pointer to SET RETRY jump table
  390.           BRA       IndxJump           Join common jump routine
  391. DoSRTRY1  RTS
  392.  
  393. DoStPRM:  LEA       DataBuf(A6),A1     Pointer to temporary buffer
  394.           MOVEA.L   A1,A0              Pass it to ParsTxt
  395.           BSR       ParsTxt            Get a text string from the command line
  396.           TST.B     D0                 Ok ?
  397.           BLT.S     DoStPRM1           No, return
  398.           LEA       Prompt(A6),A0      Pointer to the prompt string
  399.           MOVEQ     #PromptML,D0       Max prompt length
  400.           BSR       CopyStr            Copy
  401. DoStPRM1  RTS
  402.  
  403. DoSetESC: MOVEQ     #Escape,D7         Relative address escape character
  404.           BRA.S     SetCtCh            Join common parameter setter
  405.  
  406. DoStRMrk: MOVEQ     #IStPckCh,D7       Relative address receive pack marker
  407.           BRA.S     SetCtCh            Join common parameter setter
  408.  
  409. DoStSMrk: MOVEQ     #OStPckCh,D7       Relative address send packet marker
  410.           BRA.S     SetCtCh            Join common parameter setter
  411.  
  412. DoStRPdC: MOVEQ     #IPadChar,D7       Relative address receive pad character
  413.           BRA.S     SetCtCh            Join common parameter setter
  414.  
  415. DoStSPdC: MOVEQ     #OPadChar,D7       Relative address send pad character
  416.           BRA.S     SetCtCh            Join common parameter setter
  417.  
  418. DoStREOL: MOVEQ     #IEOL,D7           Relative address receive EOL character
  419.           BRA.S     SetCtCh            Join common parameter setter
  420.  
  421. DoStSEOL: MOVEQ     #OEOL,D7           Relative address send EOL character
  422. *          BRA.S     SetCtCh            Join common parameter setter
  423.  
  424. ********************************* SetCtCh ****************************
  425. *                                                                     *
  426. *  Look for a control character ASCII code specification, then set    *
  427. *  the addressed variable.                                            *
  428. *                                                                     *
  429. *         Entry conditions : D7.L Relative (to A6) address of the     *
  430. *                                 variable to set                     *
  431. *                                                                     *
  432. *         Exit  conditions : none                                     *
  433. *                                                                     *
  434. ***********************************************************************
  435. SetCtCh   MOVEQ     #Asc_Nul,D1        Valid range lower bound
  436.           MOVEQ     #Asc_Del,D2        Valid range upper bound
  437.           BSR       ParsNm             Try to get a number
  438.           TST.B     D1                 Invalid number ?
  439.           BLT.S     SetCtCh2           Yes, return
  440.           CMPI.B    #Asc_US,D0         No, check for ASCII control range
  441.           BLS.S     SetCtCh1           Ok, set the parameter
  442.           CMPI.L    #Asc_Del,D0        Delete ?
  443.           BEQ.S     SetCtCh1           Yes, set the parameter
  444.           LEA       SetCtStr(PC),A1    No, not in control range
  445.           LEA       DataBuf(A6),A0     Point to the guilty number
  446.           BSR       ParsErr            Give appropriate error message
  447.           BRA.S     SetCtCh2
  448. SetCtCh1  MOVE.B    D0,(A6,D7.L)       Finally set the parameter
  449. SetCtCh2  RTS
  450.  
  451. DoStRPdN: MOVEQ     #IPadNumb,D7       Relative address receive pad number
  452.           MOVEQ     #0,D1              Valid range lower bound
  453.           MOVEQ     #100,D2            Valid range upper bound
  454.           BRA.S     SetNPar            Join common parameter setter
  455.  
  456. DoStSPdN: MOVEQ     #OPadNumb,D7       Relative address send pad number
  457.           MOVEQ     #0,D1              Valid range lower bound
  458.           MOVEQ     #100,D2            Valid range upper bound
  459.           BRA.S     SetNPar            Join common parameter setter
  460.  
  461. DoStRTIM: ST        TimInFlg(A6)       Set flag to allow overriding Send-Init
  462.           MOVEQ     #ITimInt,D7        Relative address receive timeout
  463.           MOVEQ     #1,D1              Valid range lower bound
  464.           MOVEQ     #50,D2             Valid range upper bound
  465.           BRA.S     SetNPar            Join common parameter setter
  466.  
  467. DoStSTIM: MOVEQ     #OTimInt,D7        Relative address send timeout interval
  468.           MOVEQ     #1,D1              Valid range lower bound
  469.           MOVEQ     #50,D2             Valid range upper bound
  470.           BRA.S     SetNPar            Join common parameter setter
  471.  
  472. DoStRMPS: MOVEQ     #IMPckSiz,D7       Relative address receive max packet size
  473.           MOVEQ     #10,D1             Valid range lower bound
  474.           MOVEQ     #94,D2             Valid range upper bound
  475.           BRA.S     SetNPar            Join common parameter setter
  476.  
  477. DoStSMPS: ST        SndPSFlg(A6)       Set flag to allow overriding Send-Init
  478.           MOVEQ     #OMPckSiz,D7       Relative address send max packet size
  479.           MOVEQ     #10,D1             Valid range lower bound
  480.           MOVEQ     #94,D2             Valid range upper bound
  481.           BRA.S     SetNPar            Join common parameter setter
  482.  
  483. DoStDLAY: MOVEQ     #Delay,D7          Relative address delay time before send
  484.           MOVEQ     #0,D1              Valid range lower bound
  485.           MOVEQ     #100,D2            Valid range upper bound
  486.           BRA.S     SetNPar            Join common parameter setter
  487.  
  488. DoSetRtI: MOVEQ     #RtryInit,D7       Relative address initial retry limit
  489.           MOVEQ     #0,D1              Valid range lower bound
  490.           MOVEQ     #100,D2            Valid range upper bound
  491.           BRA.S     SetNPar            Join common parameter setter
  492.  
  493. DoSetRtP: MOVEQ     #RtryPack,D7       Relative address normal retry limit
  494.           MOVEQ     #0,D1              Valid range lower bound
  495.           MOVEQ     #100,D2            Valid range upper bound
  496. *          BRA.S     SetNPar           Join common parameter setter
  497.  
  498. ********************************* SetNPar  ***************************
  499. *                                                                     *
  500. *  Look for a number specification, then set the addressed variable.  *
  501. *                                                                     *
  502. *         Entry conditions : D7.L Relative (to A6) address of the     *
  503. *                                 variable to set                     *
  504. *                            D1.L range specification, lower bound    *
  505. *                            D2.L range specification, upper bound    *
  506. *                                                                     *
  507. *         Exit  conditions : none                                     *
  508. *                                                                     *
  509. ***********************************************************************
  510. SetNPar   BSR       ParsNm             Try to get a number
  511.           TST.B     D1                 Invalid number ?
  512.           BLT.S     SetNPar1           Yes, return
  513.           MOVE.B    D0,(A6,D7.L)       No, set the parameter
  514. SetNPar1  RTS
  515.  
  516. DoStPAR:  LEA       ParTable(PC),A1    Pointer to parity keywords table
  517.           ST        D1
  518.           BSR       ParsKyW            Look for a valid parity specification
  519.           TST.B     D0                 Ok ?
  520.           BLT.S     DoStPAR1           No, return
  521.           MOVE.B    D0,Parity(A6)      Yes, set parity to the requested value
  522. DoStPAR1  RTS
  523.  
  524. DoStBCT:  LEA       BlCkTabl(PC),A1    Pointer to block check type table
  525.           ST        D1                 A keyword is mandatory
  526.           BSR       ParsKyW            Look for valid block check specification
  527.           TST.B     D0                 Ok ?
  528.           BLT.S     DoStBCT1           No, return
  529.           MOVE.B    D0,BlChkRq(A6)     Yes, set block check to requested value
  530. DoStBCT1  RTS
  531.  
  532. DoStIFD:  LEA       IFlDTabl(PC),A1    Points to incomplete file disp table
  533.           ST        D1
  534.           BSR       ParsKyW            Look for valid disposition specification
  535.           TST.B     D0                 Ok ?
  536.           BLT.S     DoStIFD1           No, return
  537.           SNE       Keep(A6)           Yes, set the keep flag accordingly
  538. DoStIFD1  RTS
  539.  
  540. DoStFNm:  LEA       FNamTabl(PC),A1    Points to incomplete file disp table
  541.           ST        D1
  542.           BSR       ParsKyW            Look for valid disposition specification
  543.           TST.B     D0                 Ok ?
  544.           BLT.S     DoStFNm1           No, return
  545.           SNE       FNameCnv(A6)       Yes, set conversion flag accordingly
  546. DoStFNm1  RTS
  547.  
  548. DoStFDs:  LEA       OnOfTabl(PC),A1    Points to on/off keywords table
  549.           ST        D1
  550.           BSR       ParsKyW            Look for valid on/off specification
  551.           TST.B     D0                 Ok ?
  552.           BLT.S     DoStFDs1           No, return
  553.           SEQ       Quiet(A6)          Yes, set the quiet flag accordingly
  554. DoStFDs1  RTS
  555.  
  556. DoStFTp:  LEA       FTypTabl(PC),A1    Points to file type keywords table
  557.           ST        D1
  558.           BSR       ParsKyW            Look for a valid file type specification
  559.           TST.B     D0                 Ok ?
  560.           BLT.S     DoStFTp1           No, return
  561.           SNE       Binary(A6)         Yes, set the binary flag accordingly
  562. DoStFTp1  RTS
  563.  
  564. DoStFWn:  LEA       OnOfTabl(PC),A1    Points to on/off keywords table
  565.           ST        D1
  566.           BSR       ParsKyW            Look for valid on/off specification
  567.           TST.B     D0                 Ok ?
  568.           BLT.S     DoStFWn1           No, return
  569.           SNE       Warning(A6)        Yes, set the warning flag accordingly
  570. DoStFWn1  RTS
  571.  
  572. DoStDUP:  LEA       DuplTabl(PC),A1    Points to duplex keywords table
  573.           ST        D1
  574.           BSR       ParsKyW            Look for valid duplex specification
  575.           TST.B     D0                 Ok ?
  576.           BLT.S     DoStDUP1           No, return
  577.           SNE       Duplex(A6)         Yes, set the duplex flag accordingly
  578. DoStDUP1  RTS
  579.  
  580. DoStFLW:  LEA       FlowTabl(PC),A1    Points to flow control keywords table
  581.           ST        D1
  582.           BSR       ParsKyW            Look for valid flow specification
  583.           TST.B     D0                 Ok ?
  584.           BLT.S     DoStFLW1           No, return
  585.           MOVE.B    D0,Flow(A6)        Yes, set the flow control variable
  586. DoStFLW1  RTS
  587.  
  588. DoStHND:  LEA       HandTabl(PC),A1    Points to handshake chars keywords table
  589.           ST        D1
  590.           BSR       ParsKyW            Look for valid handshake specification
  591.           TST.B     D0                 Ok ?
  592.           BLT.S     DoStHND1           No, return
  593.           SNE       TurnFlag(A6)       Yes, set the handshake flag accordingly
  594.           MOVE.B    D0,TurnChar(A6)    Line turnaround character
  595. DoStHND1  RTS
  596.  
  597. DoStLIN:  LEA       DataBuf(A6),A1     Pointer to temporary buffer
  598.           MOVEA.L   A1,A0              Pass it to ParsTxt
  599.           BSR       ParsTxt            Get a text string from the command line
  600.           TST.B     D0                 Ok ?
  601.           BLT.S     DoStLIN1           No, return
  602.           MOVEQ     #HostLine,D1       Yes, close the old line
  603.           BSR       FilClose
  604.           MOVEQ     #RdWrOp,D0         Try to open the new line
  605.           MOVEQ     #HostLine,D1       This is the channel number
  606.           MOVEA.L   A1,A0              Point to the new line name
  607.           BSR       FilOpen            Open, if possible
  608.           TST.B     D0                 Ok ?
  609.           BEQ.S     DoStLIN2           No, give error message, reopen old line
  610.           LEA       LineName(A6),A0    Yes, point to the line name string
  611.           MOVEQ     #LinNamML,D0       Max line name length
  612.           BSR       CopyStr            Copy
  613.           LEA       ConLinNm(PC),A1    Point to the console line name
  614.           BSR       CompStr            Compare the two line names
  615.           TST.B     D0                 Are equal ?
  616.           SEQ       Local(A6)          If not we are local, remote otherwise
  617.           BEQ.S     DoStLIN1           If local, leave speed unchanged
  618.           MOVE.L    #-1,Speed(A6)      If remote, say speed unknown
  619. DoStLIN1  RTS
  620. DoStLIN2  LEA       OpLnEStr(PC),A1    Point to the error message string
  621.           BSR       ParsErr            Say that we can't open the new line
  622.           LEA       LineName(A6),A0    Point to the line name string
  623.           MOVEQ     #RdWrOp,D0         Reopen the old line
  624.           MOVEQ     #HostLine,D1       This is the channel number
  625.           BSR       FilOpen            Open now
  626.           RTS
  627.  
  628. DoStSPE:  MOVEQ     #50,D1             Valid range lower bound
  629.           MOVE.L    #19200,D2          Valid range upper bound
  630.           BSR       ParsNm             Try to get a valid number specification
  631.           TST.B     D1                 Valid number on input ?
  632.           BLT.S     DoStSPE1           No, return
  633.           BSR.S     ChkBaud            Check if requested speed is supported
  634.           TST.B     D1                 Ok ?
  635.           BEQ.S     DoStSPE1           No, return
  636.           MOVE.L    D0,Speed(A6)       Yes, set the baud rate variable
  637.           MOVE.L    D0,D2              Pass baud rate to ChanCtrl
  638.           MOVEQ     #HostLine,D1       Pass channel number to ChanCtrl
  639.           MOVEQ     #SetBaud,D0        Pass request code to ChanCtrl
  640.           BSR       ChanCtrl           Physically set the host line baud rate
  641. DoStSPE1  RTS
  642.  
  643. ChkBaud:  LEA       SpeedTbl(PC),A0    Pointer to baud rates table
  644. ChkBaud1  TST.L     (A0)               End of table ?
  645.           BLT.S     ChkBaud2           Yes, unsupported baud rate
  646.           CMP.L     (A0)+,D0           No, compare, baud rate found ?
  647.           BNE.S     ChkBaud1           No, loop until found or end of table
  648.           ST        D1                 Yes, set completion code accordingly
  649.           RTS
  650. ChkBaud2  LEA       DataBuf(A6),A0     Point to the guilty number
  651.           LEA       UnsBRStr(PC),A1    Point to the error message
  652.           BSR       ParsErr            Give error message
  653.           SF        D1                 Return a negative completion code
  654.           RTS
  655.  
  656. SpeedTbl  DC.L         50
  657.           DC.L        110
  658.           DC.L        150
  659.           DC.L        300
  660.           DC.L        600
  661.           DC.L       1200
  662.           DC.L       2400
  663.           DC.L       4800
  664.           DC.L       9600
  665.           DC.L      19200
  666.           DC.L      38400
  667.           DC.L      -1
  668.  
  669.           ends
  670.           END
  671. <<< k6ocm3.asm >>>
  672.           nam       Kermit68K
  673.           ttl       REMOTE and SHOW commands subroutines module
  674.  
  675. *         Kermit68K: source file K68CM3
  676. *
  677. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  678. * Bologna University, Physics Department, July 1987.
  679. *
  680. * All rights reserved to Bologna University, Italy.
  681. *
  682. * Permission is granted to any individual or institution
  683. * to use, copy, or redistribute this software so long as
  684. * it  is not  sold for  profit, provided  this copyright
  685. * notice is retained.
  686. *
  687. * Modification History:
  688. *
  689. * Version  Date    Who              Comments
  690. *
  691. * 1.0.00   870701  Roberto Bagnara  First official release
  692.  
  693.           use       DefsFile
  694.  
  695. Edition   equ       0
  696.           psect     K68Commands3,0,0,Edition,0,0
  697.  
  698. *** Code for REMOTE commands execution ***
  699.  
  700. Rm1FlOp   MOVE.B    D0,D7              Save command
  701.           LEA       DataBuf(A6),A1     Pointer to temporary buffer
  702.           MOVEA.L   A1,A0              Pass it to ParsTxt
  703.           BSR       ParsTxt            Get a text string from the command line
  704.           TST.B     D0                 Remote file specified ?
  705.           BLT.S     Rm1FlOp1           No, give error message
  706.           MOVEA.L   A1,A2              Yes
  707.           MOVE.B    D7,D0              Restore command
  708.           SUBA.L    A3,A3              Terminate the SetGCmd arguments list
  709.           BSR       SetGCmd            Setup data buffer and involved variables
  710.           MOVEQ     #SndSrvIS,D7
  711.           BSR       KPSwtch            Enter the protocol automaton switcher
  712.           RTS
  713. Rm1FlOp1  LEA       Rm1FOStr(PC),A0
  714.           BSR       ConWrite
  715.           RTS
  716.  
  717. Rm2FlOp   MOVE.B    D0,D7              Save command
  718.           LEA       DataBuf(A6),A1     Pointer to temporary buffer
  719.           MOVEA.L   A1,A0              Pass it to ParsTxt
  720.           BSR       ParsWrd            Get a text string from the command line
  721.           TST.B     D0                 Remote file 1 specified ?
  722.           BLT.S     Rm2FlOp1           No, give error message
  723.           MOVEA.L   A1,A2              Yes
  724.           LEA       1(A0),A1
  725.           MOVEA.L   A1,A0              Pass it to ParsTxt
  726.           BSR       ParsTxt            Get a text string from the command line
  727.           TST.B     D0                 Remote file 2 specified ?
  728.           BLT.S     Rm2FlOp1           No, give error message
  729.           MOVEA.L   A1,A3              Yes
  730.           MOVE.B    D7,D0              Restore command
  731.           SUBA.L    A4,A4              Terminate the SetGCmd arguments list
  732.           BSR       SetGCmd            Setup data buffer and involved variables
  733.           MOVEQ     #SndSrvIS,D7
  734.           BSR       KPSwtch            Enter the protocol automaton switcher
  735.           RTS
  736. Rm2FlOp1  LEA       Rm2FOStr(PC),A0
  737.           BSR       ConWrite
  738.           RTS
  739.  
  740. *** REMOTE command ***
  741.  
  742. DoREMOT:  BSR       ChkLocl            Check mode
  743.           LEA       REMTable(PC),A1    Pointer to REMOTE commands table
  744.           ST        D1                 Keyword specification is mandatory
  745.           BSR       ParsKyW            Look for a valid REMOTE command
  746.           TST.B     D0                 Ok ?
  747.           BLT.S     DoREMOT1           No, return
  748.           LEA       DoRemTab(PC),A1    Pointer to REMOTE jump table
  749.           BRA       IndxJump           Join common jump routine
  750. DoREMOT1  RTS
  751.  
  752. *** REMOTE COPY command ***
  753.  
  754. DoRemCOP: MOVEQ     #'K',D0            Copy command
  755.           BSR       Rm2FlOp            Call the remote file operation routine
  756.           RTS
  757.  
  758. *** REMOTE CWD command ***
  759.  
  760. DoRmCWD:  SUBA.L    A2,A2              No SetGCmd arguments by default
  761.           LEA       DataBuf(A6),A1     Pointer to temporary buffer
  762.           MOVEA.L   A1,A0              Pass it to ParsTxt
  763.           BSR       ParsTxt            Get a text string from the command line
  764.           TST.B     D0                 Remote directory specified ?
  765.           BLT.S     DoRmCWD1           No, no arguments
  766.           MOVEA.L   A1,A2              Yes
  767.           SUBA.L    A3,A3              Nullify next argument pointer
  768. DoRmCWD1  MOVEQ     #'C',D0            Change working directory command
  769.           BSR       SetGCmd
  770.           MOVEQ     #SndGCmdS,D7
  771.           BSR       KPSwtch            Enter the protocol automaton switcher
  772.           RTS
  773.  
  774. *** REMOTE DELETE command ***
  775.  
  776. DoRemDEL: MOVEQ     #'E',D0            Delete command
  777.           BSR       Rm1FlOp            Call the remote file operation routine
  778.           RTS
  779.  
  780. *** REMOTE DIRECTORY command ***
  781.  
  782. DoRmDIR:  SUBA.L    A2,A2              No SetGCmd arguments by default
  783.           LEA       DataBuf(A6),A1     Pointer to temporary buffer
  784.           MOVEA.L   A1,A0              Pass it to ParsTxt
  785.           BSR       ParsTxt            Get a text string from the command line
  786.           TST.B     D0                 Remote file or directory specified ?
  787.           BLT.S     DoRmDIR1           No, no arguments
  788.           MOVEA.L   A1,A2              Yes
  789.           SUBA.L    A3,A3              Nullify next argument pointer
  790. DoRmDIR1  MOVEQ     #'D',D0            Remote directory command
  791.           BSR       SetGCmd            Setup data buffer and involved variables
  792.           MOVEQ     #SndSrvIS,D7
  793.           BSR       KPSwtch            Enter the protocol automaton switcher
  794.           RTS
  795.  
  796. *** REMOTE HELP command ***
  797.  
  798. DoRmHELP: SUBA.L    A2,A2              No arguments for SetGCmd
  799.           MOVEQ     #'H',D0            Remote help command
  800.           BSR       SetGCmd            Setup data buffer and involved variables
  801.           MOVEQ     #SndSrvIS,D7
  802.           BSR       KPSwtch            Enter the protocol automaton switcher
  803.           RTS
  804.  
  805. *** REMOTE HOST command ***
  806.  
  807. DoRemHOS: LEA       DataBuf(A6),A1
  808.           MOVEA.L   A1,A0
  809.           BSR       ParsTxt
  810.           LEA       CmdBuf(A6),A0
  811.           MOVEQ     #CmdBufLn,D0
  812.           BSR       CopyStr
  813.           BSR       TrnsInit
  814.           MOVE.B    #'C',ServrCmd(A6)
  815.           MOVEQ     #SndSrvIS,D7
  816.           BSR       KPSwtch            Enter the protocol automaton switcher
  817.           RTS
  818.  
  819. *** REMOTE KERMIT command ***
  820.  
  821. DoRemKER: RTS
  822.  
  823. *** REMOTE PRINT command ***
  824.  
  825. DoRemPRI: MOVEQ     #'S',D0
  826.           BSR       Rm1FlOp            Call the remote file operation routine
  827.           RTS
  828.  
  829. *** REMOTE RENAME command ***
  830.  
  831. DoRemREN: MOVEQ     #'R',D0            Rename command
  832.           BSR       Rm2FlOp            Call the remote file operation routine
  833.           RTS
  834.  
  835. *** REMOTE SET command ***
  836.  
  837. DoRemSET: RTS
  838.  
  839. *** REMOTE SPACE command ***
  840.  
  841. DoRmSPA:  SUBA.L    A2,A2              No SetGCmd arguments by default
  842.           LEA       DataBuf(A6),A1     Pointer to temporary buffer
  843.           MOVEA.L   A1,A0              Pass it to ParsTxt
  844.           BSR       ParsTxt            Get a text string from the command line
  845.           TST.B     D0                 Remote directory specified ?
  846.           BLT.S     DoRmSPA1           No, no arguments
  847.           MOVEA.L   A1,A2              Yes
  848.           SUBA.L    A3,A3              Nullify next argument pointer
  849. DoRmSPA1  MOVEQ     #'U',D0            Remote space query command
  850.           BSR       SetGCmd            Setup for generic commands
  851.           MOVEQ     #SndGCmdS,D7
  852.           BSR       KPSwtch            Enter the protocol automaton switcher
  853.           RTS
  854.  
  855. *** REMOTE SUBMIT command ***
  856.  
  857. DoRemSUB: MOVEQ     #'P',D0            Submit command
  858.           BSR       Rm1FlOp            Call the remote file operation routine
  859.           RTS
  860.  
  861. *** REMOTE TYPE command ***
  862.  
  863. DoRemTYP: MOVEQ     #'T',D0            Type command
  864.           BSR       Rm1FlOp            Call the remote file operation routine
  865.           RTS
  866.  
  867. *** REMOTE WHO command ***
  868.  
  869. DoRmWHO:  SUBA.L    A2,A2              No SetGCmd arguments by default
  870.           LEA       DataBuf(A6),A1     Pointer to temporary buffer
  871.           MOVEA.L   A1,A0              Pass it to ParsTxt
  872.           BSR       ParsTxt            Get a text string from the command line
  873.           TST.B     D0                 Remote user name specified ?
  874.           BLT.S     DoRmWHO1           No, no arguments
  875.           MOVEA.L   A1,A2              Yes
  876.           SUBA.L    A3,A3              Nullify next argument pointer
  877. DoRmWHO1  MOVEQ     #'W',D0            Remote who command
  878.           BSR       SetGCmd            Setup data buffer and involved variables
  879.           MOVEQ     #SndSrvIS,D7
  880.           BSR       KPSwtch            Enter the protocol automaton switcher
  881.           RTS
  882.  
  883. *** SHOW command ***
  884.  
  885. DoSHOW:   LEA       SHOWTabl(PC),A1    Pointer to SHOW parameters table
  886.           ST        D1
  887.           BSR       ParsKyW            Look for a valid SHOW option
  888.           TST.B     D0                 Ok ?
  889.           BLT.S     DoSHOW1            No, return
  890.           LEA       DoShoTab(PC),A1    Pointer to SHOW jump table
  891.           BRA       IndxJump           Join common jump routine
  892. DoSHOW1   RTS
  893.  
  894. *** SHOW VERSION command ***
  895.  
  896. DoShoVer: LEA       VersStr(PC),A0     Show the current Kermit68K version
  897.           BSR       ConWrite
  898.           LEA       ShVerStr(PC),A0    And then the warning
  899.           BSR       ConWrite
  900.           RTS
  901.  
  902. *** SHOW PARAMETERS command ***
  903.  
  904. DoShoP:   LEA       ShPStr1(PC),A0     Line name
  905.           BSR       ConWrite
  906.           LEA       LineName(A6),A0
  907.           BSR       ConWrite
  908.  
  909.           LEA       ShPStr2(PC),A0     Line speed
  910.           BSR       ConWrite
  911.           MOVE.L    Speed(A6),D0       Load it
  912.           BLT.S     DoShoP0            Negative, unknown speed
  913.           BSR       TypeUNum           Write the baud rate
  914.           BRA.S     DoShoP01
  915. DoShoP0   LEA       ShPStr3(PC),A0     Say unknown speed
  916.           BSR       ConWrite
  917.  
  918. DoShoP01  LEA       ShPStr4(PC),A0     Mode
  919.           BSR       ConWrite
  920.           TST.B     Local(A6)
  921.           BEQ.S     DoShoP1
  922.           LEA       ShPStr5(PC),A0
  923.           BRA.S     DoShoP2
  924. DoShoP1   LEA       ShPStr6(PC),A0
  925. DoShoP2   BSR       ConWrite
  926.  
  927.           LEA       ShPStr7(PC),A0     Parity selected
  928.           BSR       ConWrite
  929.           MOVE.B    Parity(A6),D0
  930.           CMPI.B    #'E',D0
  931.           BEQ.S     DoShoP3
  932.           CMPI.B    #'O',D0
  933.           BEQ.S     DoShoP4
  934.           CMPI.B    #'M',D0
  935.           BEQ.S     DoShoP5
  936.           CMPI.B    #'S',D0
  937.           BEQ.S     DoShoP6
  938.           LEA       ShPStr12(PC),A0    none
  939.           BRA.S     DoShoP7
  940. DoShoP3   LEA       ShPStr8(PC),A0     even
  941.           BRA.S     DoShoP7
  942. DoShoP4   LEA       ShPStr9(PC),A0     odd
  943.           BRA.S     DoShoP7
  944. DoShoP5   LEA       ShPStr10(PC),A0    mark
  945.           BRA.S     DoShoP7
  946. DoShoP6   LEA       ShPStr11(PC),A0    space
  947. DoShoP7   BSR       ConWrite
  948.  
  949.           LEA       ShPStr13(PC),A0    Duplex
  950.           BSR       ConWrite
  951.           TST.B     Duplex(A6)
  952.           BEQ.S     DoShoP8
  953.           LEA       ShPStr14(PC),A0
  954.           BRA.S     DoShoP9
  955. DoShoP8   LEA       ShPStr15(PC),A0
  956. DoShoP9   BSR       ConWrite
  957.  
  958.           LEA       ShPStr16(PC),A0    Flow control
  959.           BSR       ConWrite
  960.           MOVE.B    Flow(A6),D0
  961.           BEQ.S     DoShoP11
  962.           CMPI.B    #1,D0 Flow(A6)
  963.           BNE.S     DoShoP10
  964.           LEA       ShPStr17(PC),A0
  965.           BRA.S     DoShoP12
  966. DoShoP10  MOVEQ     #0,D2
  967.           BSR       DoShoP42
  968.           BRA.S     DoShoP13
  969. DoShoP11  LEA       ShPStr12(PC),A0
  970. DoShoP12  BSR       ConWrite
  971.  
  972. DoShoP13  LEA       ShPStr18(PC),A0    Handshake
  973.           BSR       ConWrite
  974.           TST.B     TurnFlag(A6)
  975.           BNE.S     DoShoP14
  976.           LEA       ShPStr12(PC),A0
  977.           BSR       ConWrite
  978.           BRA.S     DoShoP15
  979. DoShoP14  MOVE.B    TurnChar(A6),D0
  980.           MOVEQ     #0,D2
  981.           BSR       DoShoP42
  982.  
  983. DoShoP15  LEA       ShPStr19(PC),A0
  984.           BSR       ConWrite
  985.  
  986.           MOVE.B    TimInFlg(A6),D0
  987.           OR.B      SndPSFlg(A6),D0
  988.           BEQ.S     DoShoP16
  989.           LEA       ShPStr20(PC),A0
  990.           BSR       ConWrite
  991.  
  992. DoShoP16  LEA       ShPStr21(PC),A0
  993.           BSR       ConWrite
  994.           MOVE.B    OTimInt(A6),D0     Send timeout interval
  995.           BSR       DoShoP40
  996.           MOVE.B    ITimInt(A6),D0     Receive timeout interval
  997.           BSR       DoShoP41
  998.           TST.B     TimInFlg(A6)
  999.           BEQ.S     DoShoP17
  1000.           MOVEQ     #'*',D0
  1001.           BSR       ConOut
  1002.  
  1003. DoShoP17  LEA       ShPStr22(PC),A0
  1004.           BSR       ConWrite
  1005.           MOVE.B    OPadNumb(A6),D0    Send padding
  1006.           BSR       DoShoP40
  1007.           MOVE.B    IPadNumb(A6),D0    Receive padding
  1008.           BSR       DoShoP41
  1009.  
  1010.           LEA       ShPStr23(PC),A0
  1011.           BSR       ConWrite
  1012.           MOVE.B    OPadChar(A6),D0    Send padding character
  1013.           BSR       DoShoP40
  1014.           MOVE.B    IPadChar(A6),D0    Receive padding character
  1015.           BSR       DoShoP41
  1016.  
  1017.           LEA       ShPStr24(PC),A0
  1018.           BSR       ConWrite
  1019.           MOVE.B    OStPckCh(A6),D0    Send packet start character
  1020.           BSR       DoShoP40
  1021.           MOVE.B    IStPckCh(A6),D0    Receive packet start character
  1022.           BSR       DoShoP41
  1023.  
  1024.           LEA       ShPStr25(PC),A0
  1025.           BSR       ConWrite
  1026.           MOVE.B    OEOL(A6),D0        Send End-Of-Line character
  1027.           BSR       DoShoP40
  1028.           MOVE.B    IEOL(A6),D0        Receive End-Of-Line character
  1029.           BSR       DoShoP41
  1030.  
  1031.           LEA       ShPStr26(PC),A0
  1032.           BSR       ConWrite
  1033.           MOVE.B    OMPckSiz(A6),D0    Send max packet size
  1034.           BSR       DoShoP40
  1035.  
  1036.           TST.B     SndPSFlg(A6)
  1037.           BEQ.S     DoShoP18
  1038.           MOVEQ     #'*',D0
  1039.           BRA.S     DoShoP19
  1040. DoShoP18  MOVEQ     #' ',D0
  1041. DoShoP19  BSR       ConOut
  1042.           MOVE.B    IMPckSiz(A6),D0    Receive max packet size
  1043.           MOVEQ     #8,D2
  1044.           BSR       DoShoP42
  1045.  
  1046.           LEA       ShPStr27(PC),A0
  1047.           BSR       ConWrite
  1048.           MOVE.B    BlChkRq(A6),D0     Block check type
  1049.           MOVEQ     #0,D2
  1050.           BSR       DoShoP42
  1051.  
  1052.           LEA       ShPStr28(PC),A0
  1053.           BSR       ConWrite
  1054.           MOVE.B    Delay(A6),D0       Delay
  1055.           MOVEQ     #0,D2
  1056.           BSR       DoShoP42
  1057.  
  1058.           LEA       ShPStr29(PC),A0
  1059.           BSR       ConWrite
  1060.           MOVE.B    RtryInit(A6),D0    Retry limit for initial connection
  1061.           MOVEQ     #0,D2
  1062.           BSR       DoShoP42
  1063.  
  1064.           LEA       ShPStr30(PC),A0
  1065.           BSR       ConWrite
  1066.           MOVE.B    RtryPack(A6),D0    Retry limit for normal packets
  1067.           MOVEQ     #0,D2
  1068.           BSR       DoShoP42
  1069.  
  1070.           TST.B     Bit8Flag(A6)
  1071.           BEQ.S     DoShoP20
  1072.           LEA       ShPStr31(PC),A0
  1073.           BSR       ConWrite
  1074.           MOVE.B    Bit8Quot(A6),D0    8-th bit prefix
  1075.           BSR       ConOut
  1076.  
  1077. DoShoP20  TST.B     ReptFlag(A6)
  1078.           BEQ.S     DoShoP21
  1079.           LEA       ShPStr32(PC),A0
  1080.           BSR       ConWrite
  1081.           MOVE.B    ReptQuot(A6),D0    Repeat prefix
  1082.           BSR       ConOut
  1083.  
  1084. DoShoP21  LEA       ShPStr33(PC),A0
  1085.           BSR       ConWrite
  1086.           TST.B     FNameCnv(A6)       File name
  1087.           BEQ.S     DoShoP22
  1088.           LEA       ShPStr34(PC),A0
  1089.           BRA.S     DoShoP23
  1090. DoShoP22  LEA       ShPStr35(PC),A0
  1091. DoShoP23  BSR       ConWrite
  1092.  
  1093.           LEA       ShPStr36(PC),A0
  1094.           BSR       ConWrite
  1095.           TST.B     Binary(A6)         File type
  1096.           BEQ.S     DoShoP24
  1097.           LEA       ShPStr37(PC),A0
  1098.           BRA.S     DoShoP25
  1099. DoShoP24  LEA       ShPStr38(PC),A0
  1100. DoShoP25  BSR       ConWrite
  1101.  
  1102.           LEA       ShPStr39(PC),A0
  1103.           BSR       ConWrite
  1104.           TST.B     Warning(A6)        File warning
  1105.           BEQ.S     DoShoP26
  1106.           LEA       ShPStr40(PC),A0
  1107.           BRA.S     DoShoP27
  1108. DoShoP26  LEA       ShPStr41(PC),A0
  1109. DoShoP27  BSR       ConWrite
  1110.  
  1111.           LEA       ShPStr42(PC),A0
  1112.           BSR       ConWrite
  1113.           TST.B     Quiet(A6)          File display
  1114.           BNE.S     DoShoP28
  1115.           LEA       ShPStr40(PC),A0
  1116.           BRA.S     DoShoP29
  1117. DoShoP28  LEA       ShPStr41(PC),A0
  1118. DoShoP29  BSR       ConWrite
  1119.  
  1120.           LEA       ShPStr43(PC),A0
  1121.           BSR       ConWrite
  1122.           TST.B     Keep(A6)           Incomplete file disposition
  1123.           BEQ.S     DoShoP30
  1124.           LEA       ShPStr44(PC),A0
  1125.           BRA.S     DoShoP31
  1126. DoShoP30  LEA       ShPStr45(PC),A0
  1127. DoShoP31  BSR       ConWrite
  1128.  
  1129.           BSR       NewLine
  1130.           RTS
  1131.  
  1132. DoShoP40  MOVEQ     #11,D2             Use a 11 characters field
  1133.           BRA.S     DoShoP42           Join common part
  1134. DoShoP41  MOVEQ     #9,D2              Use a 9 characters field
  1135. DoShoP42  LEA       DataBuf+34(A6),A0  Point to the end of a temporary buffer
  1136.           EXT.W     D0                 Extend to word
  1137.           EXT.L     D0                 Extend to long word
  1138.           ST        D1                 Unsigned conversion wanted
  1139.           MOVEQ     #10,D3             Base is 10
  1140.           BSR       IntToAs            Convert the number into a string
  1141.           BSR       ConWrite           Write the obtained string
  1142.           RTS
  1143.  
  1144.           ends
  1145.           END
  1146. <<< k6ocm4.asm >>>
  1147.           nam       Kermit68K
  1148.           ttl       Command line parser module
  1149.  
  1150. *         Kermit68K: source file K68CM4
  1151. *
  1152. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  1153. * Bologna University, Physics Department, July 1987.
  1154. *
  1155. * All rights reserved to Bologna University, Italy.
  1156. *
  1157. * Permission is granted to any individual or institution
  1158. * to use, copy, or redistribute this software so long as
  1159. * it  is not  sold for  profit, provided  this copyright
  1160. * notice is retained.
  1161. *
  1162. * Modification History:
  1163. *
  1164. * Version  Date    Who              Comments
  1165. *
  1166. * 1.0.00   870701  Roberto Bagnara  First official release
  1167.  
  1168.           use       DefsFile
  1169.  
  1170. Edition   equ       0
  1171.           psect     K68Commands4,0,0,Edition,0,0
  1172.  
  1173. ********************************** CmdLnP *****************************
  1174. *                                                                     *
  1175. *  Kermit68K command line parser.                                     *
  1176. *                                                                     *
  1177. *         Entry conditions : none                                     *
  1178. *                                                                     *
  1179. *         Exit  conditions : none                                     *
  1180. *                                                                     *
  1181. ***********************************************************************
  1182. CmdLnP:   BSR       GetCmdLP           Try to get the command line pointer
  1183.           TST.B     D0                 Success ?
  1184.           BEQ       CmdLnP10           No, return
  1185.           MOVEA.L   A0,A5              Yes, load pointer for parser functions
  1186.           MOVEQ     #-1,D7             Say no protocol commands yet
  1187.           SF        D5                 Set the connect before flag to false
  1188.           SF        D6                 Set the connect after flag to false
  1189. CmdLnP1   LEA       RecBuf(A6),A4      This pointer is used by DoCmLA
  1190.           MOVEA.L   A4,A0              Put here the command line options
  1191.           BSR       ParsWrd            Try to get a word from command line
  1192.           TST.B     D0                 Success ?
  1193.           BLT.S     CmdLnP2            No, exit loop
  1194.           CMPI.B    #'-',(A4)+         Options begins with dash
  1195.           BNE       DoCmLA4            Not an options, give usage info
  1196.           BSR       DoCmLA             Got an option, handle it
  1197.           BRA.S     CmdLnP1            Loop until the whole line is parsed
  1198.  
  1199. CmdLnP2   TST.B     Local(A6)          Are we running in local mode ?
  1200.           BNE.S     CmdLnP4            Yes, no problem
  1201.           CMPI.B    #SndSrvIS,D7       Are we issuing a get command ?
  1202.           BEQ.S     CmdLnP3            Yes, fatal error
  1203.           MOVEQ     #SndGCmdS,D7       Are we issuing a finish command ?
  1204.           BEQ.S     CmdLnP3            Yes, fatal error
  1205.           TST.B     D5                 Are we connecting trough the host line ?
  1206.           BEQ.S     CmdLnP4            No, all ok
  1207. CmdLnP3   LEA       LBReqStr(PC),A0    Give message about -l and -b need
  1208.           BRA       FatalEr            Return to system
  1209.  
  1210. CmdLnP4   CMPI.B    #SndFileS,D7       Are we sending a file ?
  1211.           BEQ.S     CmdLnP5            Yes, set the display flag
  1212.           CMPI.B    #RecFileS,D7       Are we receiving a file ?
  1213.           BEQ.S     CmdLnP5            Yes, set the display flag
  1214.           CMPI.B    #SndSrvIS,D7       Are we getting a file ?
  1215.           BEQ.S     CmdLnP5            Yes, set the display flag
  1216.           TST.B     Argumnt2(A6)       No, has a file as-name been specified ?
  1217.           BEQ.S     CmdLnP5            No, all is fine
  1218.           LEA       ABadUStr(PC),A0    Yes, bad use of the -a option
  1219.           BRA       FatalEr            Give message and exit the program
  1220.  
  1221. CmdLnP5   TST.B     Local(A6)          Are we running in local mode ?
  1222.           BEQ.S     CmdLnP6            No
  1223.           ST        Display(A6)        Yes, set the display flag on
  1224. CmdLnP6   TST.B     TermOut(A6)        Are we outputting to the terminal ?
  1225.           BEQ.S     CmdLnP7            No
  1226.           SF        Display(A6)        Yes, set the display flag off
  1227.  
  1228. CmdLnP7   TST.B     Quiet(A6)          Has quiet been requested ?
  1229.           BEQ.S     CmdLnP8            No
  1230.           SF        Display(A6)        Yes, set the display flag off
  1231.  
  1232.           TST.B     D5                 Is the connect before flag on ?
  1233.           BEQ.S     CmdLnP8            No
  1234.           BSR       DoCONN             Yes, connect to the remote host
  1235.  
  1236. CmdLnP8   TST.B     D7                 We must invoke the protocol switcher ?
  1237.           BLT.S     CmdLnP10           No, let's return
  1238.           BSR       TrnsInit           Yes, initialize any protocol thing
  1239.           BSR       KPSwtch            Enter the protocol switcher
  1240.  
  1241.           TST.B     D6                 Is the connect after flag on ?
  1242.           BEQ.S     CmdLnP9            No, return the cc from the automaton
  1243.           BSR       DoCONN             Yes, connect to the remote host
  1244.           ST        D0                 Return a positive completion code
  1245. CmdLnP9   BRA       SysExod
  1246.  
  1247. CmdLnP10  RTS
  1248.  
  1249. ********************************** DoCmLA *****************************
  1250. *                                                                     *
  1251. *  Handle command line arguments.                                     *
  1252. *                                                                     *
  1253. *         Entry conditions : A4.L pointer to a null terminated        *
  1254. *                                 string containing the command line  *
  1255. *                                 argument(s)                         *
  1256. *                                                                     *
  1257. *         Exit  conditions : none                                     *
  1258. *                                                                     *
  1259. ***********************************************************************
  1260. DoCmLA    TST.B     (A4)               Null option ?
  1261.           BEQ.S     DoCmLA4            Yes, give an error message
  1262. DoCmLA1   MOVE.B    (A4)+,D0           Get the option letter
  1263.           BNE.S     DoCmLA2            Not null, handle it
  1264.           RTS                          End of option bundling, return
  1265.  
  1266. DoCmLA2   SUBI.B    #97,D0             Map the option letter from zero on
  1267.           CMPI.B    #22,D0             Above 'w' ?
  1268.           BHI       DoCmLA4            Yes, error
  1269.           EXT.W     D0                 No, extend to word size
  1270.           ADD.W     D0,D0              Scale by a factor of two
  1271.           MOVE.W    DoCmLA3(PC,D0.W),D0 Load service routine relative address
  1272.           JMP       DoCmLA3(PC,D0.W)   Jump to the option service routine
  1273.  
  1274. DoCmLA3   DC.W      DoCmLA16-DoCmLA3   -a option, file as-name
  1275.           DC.W      DoCmLA14-DoCmLA3   -b option, line baud rate
  1276.           DC.W      DoCmLA25-DoCmLA3   -c command, connect before
  1277.           DC.W      DoCmLA4-DoCmLA3    -d invalid
  1278.           DC.W      DoCmLA4-DoCmLA3    -e invalid
  1279.           DC.W      DoCmLA24-DoCmLA3   -f option, finish remote server
  1280.           DC.W      DoCmLA23-DoCmLA3   -g command, get file(s) from server
  1281.           DC.W      DoCmLA18-DoCmLA3   -h request, give usage informations
  1282.           DC.W      DoCmLA7-DoCmLA3    -i option, treate files as binary
  1283.           DC.W      DoCmLA4-DoCmLA3    -j invalid
  1284.           DC.W      DoCmLA20-DoCmLA3   -k command, receive file(s) to terminal
  1285.           DC.W      DoCmLA11-DoCmLA3   -l option, set communication line
  1286.           DC.W      DoCmLA4-DoCmLA3    -m invalid
  1287.           DC.W      DoCmLA4-DoCmLA26   -n command, connect after
  1288.           DC.W      DoCmLA4-DoCmLA3    -o invalid
  1289.           DC.W      DoCmLA15-DoCmLA3   -p option, communication line parity
  1290.           DC.W      DoCmLA9-DoCmLA3    -q option, be quiet
  1291.           DC.W      DoCmLA19-DoCmLA3   -r command, receive file(s)
  1292.           DC.W      DoCmLA21-DoCmLA3   -s command, send file(s)
  1293.           DC.W      DoCmLA10-DoCmLA3   -t option, line turnaround handshake
  1294.           DC.W      DoCmLA4-DoCmLA3    -u invalid
  1295.           DC.W      DoCmLA4-DoCmLA3    -v invalid
  1296.           DC.W      DoCmLA8-DoCmLA3    -w option, file collisions warnings
  1297.  
  1298. DoCmLA4   LEA       InvArStr(PC),A0    No, invalid argument, fatal error
  1299.           BRA       FatalEr
  1300. DoCmLA5   LEA       InvABStr(PC),A0    Invalid argument bundling, fatal error
  1301.           BRA       FatalEr
  1302. DoCmLA6   LEA       CnfAcStr(PC),A0    Conflicting commands, fatal error
  1303.           BRA       FatalEr
  1304.  
  1305. *** -i image option ***
  1306.  
  1307. DoCmLA7   ST        Binary(A6)         Treat files as binary
  1308.           BRA       DoCmLA1            See if options are bundled
  1309.  
  1310. *** -w warning option ***
  1311.  
  1312. DoCmLA8   ST        Warning(A6)        Give file collisions warnings
  1313.           BRA       DoCmLA1            See if options are bundled
  1314.  
  1315. *** -q quiet option ***
  1316.  
  1317. DoCmLA9   ST        Quiet(A6)          Yes, be quiet during file transfers
  1318.           BRA       DoCmLA1            See if options are bundled
  1319.  
  1320. *** -t line turnaround option ***
  1321.  
  1322. DoCmLA10  ST        Duplex(A6)         Set half duplex on
  1323.           SF        Flow(A6)           Set flow control off
  1324.           ST        TurnFlag(A6)       Set line turnaround handshake on
  1325.           MOVE.B    Asc_DC1,TurnChar(A6) Set XON as the turnaround character
  1326.           BRA       DoCmLA1            See if options are bundled
  1327.  
  1328. *** -l set line option ***
  1329.  
  1330. DoCmLA11  TST.B     (A4)               Invalid argument bundling ?
  1331.           BNE.S     DoCmLA5            Yes, error
  1332.  
  1333.           LEA       DataBuf(A6),A0     No, put here the line name
  1334.           BSR       ParsWrd            Get the line name, if any
  1335.           TST.B     D0                 Has the line name been specified ?
  1336.           BLT.S     DoCmLA12           No, error
  1337.  
  1338.           LEA       DataBuf(A6),A0     Reload pointer to the parsed line name
  1339.           MOVEQ     #RdWrOp,D0         Try to open the new line
  1340.           MOVEQ     #HostLine,D1       This is the channel number
  1341.           BSR       FilOpen            Open, if possible
  1342.           TST.B     D0                 Ok ?
  1343.           BEQ.S     DoCmLA13           No, give an error message
  1344.  
  1345.           LEA       LineName(A6),A1    This is the line name string
  1346.           EXG       A0,A1              Adjust pointers
  1347.           MOVEQ     #LinNamML,D0       Maximum line name length
  1348.           BSR       CopyStr            Copy now
  1349.  
  1350.           LEA       ConLinNm(PC),A1    Point to the console line name
  1351.           BSR       CompStr            Compare the two line names
  1352.           TST.B     D0                 Are equal ?
  1353.           SEQ       Local(A6)          If not we are local, remote otherwise
  1354.           BEQ       DoCmLA1            If local, leave speed unchanged
  1355.           MOVE.L    #-1,Speed(A6)      If remote, say speed unknown
  1356.           RTS
  1357.  
  1358. DoCmLA12  LEA       MisLNStr(PC),A0    Give missing line name error
  1359.           BRA       FatalEr
  1360. DoCmLA13  LEA       UnOpLStr(PC),A0    Give unable to open line error
  1361.           BRA       FatalEr
  1362.  
  1363. *** -b set line baud rate option ***
  1364.  
  1365. DoCmLA14  TST.B     (A4)               Invalid argument bundling ?
  1366.           BNE       DoCmLA5            Yes, error
  1367.           MOVEQ     #50,D1             Valid range lower bound
  1368.           MOVE.L    #19200,D2          Valid range upper bound
  1369.           BSR       ParsNm             Try to get a valid number specification
  1370.           TST.B     D1                 Valid number on input ?
  1371.           BLT       FatalEr1           No, fatal error
  1372.           BSR       ChkBaud            Check if requested speed is supported
  1373.           TST.B     D1                 Ok ?
  1374.           BEQ       FatalEr1           No, fatal error
  1375.           MOVE.L    D0,Speed(A6)       Yes, set the baud rate variable
  1376.           MOVE.L    D0,D2              Pass baud rate to ChanCtrl
  1377.           MOVEQ     #HostLine,D1       Pass channel number to ChanCtrl
  1378.           MOVEQ     #SetBaud,D0        Pass request code to ChanCtrl
  1379.           BSR       ChanCtrl           Physically set the host line baud rate
  1380.           RTS
  1381.  
  1382. *** -p set parity option ***
  1383.  
  1384. DoCmLA15  TST.B     (A4)               Invalid argument bundling ?
  1385.           BNE       DoCmLA5            Yes, error
  1386.           LEA       ParTable(PC),A1    No, point to the parity keywords table
  1387.           ST        D1                 This keyword is mandatory
  1388.           BSR       ParsKyW            Look for a valid parity specification
  1389.           TST.B     D0                 Ok ?
  1390.           BLT       FatalEr1           No, fatal error
  1391.           MOVE.B    D0,Parity(A6)      Yes, set parity to the requested value
  1392.           RTS
  1393.  
  1394. *** -a file as-name option ***
  1395.  
  1396. DoCmLA16  TST.B     (A4)               Invalid argument bundling ?
  1397.           BNE       DoCmLA5            Yes, error
  1398.           LEA       Argumnt2(A6),A0    No, put here the file as-name
  1399.           BSR       ParsWrd            Get the file as-name, if any
  1400.           TST.B     D0                 Has it been specified ?
  1401.           BLT.S     DoCmLA17           No, error
  1402.           RTS
  1403.  
  1404. DoCmLA17  LEA       MsFlNStr(PC),A0    Give missing file name error message
  1405.           BSR       FatalEr
  1406.  
  1407. *** -h help request ***
  1408.  
  1409. DoCmLA18  LEA       UsageStr(PC),A0    Point to the usage string
  1410.           BSR       ConWrite           Write it to the terminal
  1411.           BRA       DoCmLA1            See if options are bundled
  1412.  
  1413. *** -r receive command ***
  1414.  
  1415. DoCmLA19  TST.B     D7                 Conflicting commands ?
  1416.           BGE       DoCmLA6            Yes, error
  1417.           MOVEQ     #RecInitS,D7       Start state for the protocol automaton
  1418.           BRA       DoCmLA1            See if options are bundled
  1419.  
  1420. *** -k receive to terminal command ***
  1421.  
  1422. DoCmLA20  TST.B     D7                 Conflicting commands ?
  1423.           BGE       DoCmLA6            Yes, error
  1424.           ST        TermOut(A6)        We want output to the terminal line
  1425.           MOVEQ     #RecInitS,D7       Start state for the protocol automaton
  1426.           BRA       DoCmLA1            See if options are bundled
  1427.  
  1428. *** -s send command ***
  1429.  
  1430. DoCmLA21  TST.B     D7                 Conflicting commands ?
  1431.           BGE       DoCmLA6            Yes, error
  1432.           TST.B     (A4)               Invalid argument bundling ?
  1433.           BNE       DoCmLA5            Yes, error
  1434.           LEA       Argumnt1(A6),A0    Point to file name string
  1435.           BSR       ParsInF            Try to get a valid input file name
  1436.           TST.B     D0                 Some error ?
  1437.           BLT.S     DoCmLA22           Yes
  1438.           MOVEQ     #SndInitS,D7       No, Send-Init is the start state
  1439.           RTS
  1440. DoCmLA22  CMPI.B    #-3,D0             Has a file name been specified ?
  1441.           BEQ.S     DoCmLA17           No, give missing file name message
  1442.           RTS                          Yes, message already given, return
  1443.  
  1444. *** -g get command ***
  1445.  
  1446. DoCmLA23  TST.B     D7                 Conflicting commands ?
  1447.           BGE       DoCmLA6            Yes, error
  1448.           TST.B     (A4)               Invalid argument bundling ?
  1449.           BNE       DoCmLA5            Yes, error
  1450.           LEA       Argumnt1(A6),A0    Point to file name string
  1451.           BSR       ParsWrd            Try to get a file name
  1452.           TST.B     D0                 Missing file name ?
  1453.           BLT.S     DoCmLA17           Yes, give error message
  1454.           MOVE.B    #'R',ServrCmd(A6)  Get command
  1455.           MOVEQ     #SndSrvIS,D7       Send-Server-Init is the start state
  1456.           RTS
  1457.  
  1458. *** -f finish command ***
  1459.  
  1460. DoCmLA24  TST.B     D7                 Conflicting commands ?
  1461.           BGE       DoCmLA6            Yes, error
  1462.           SUBA.L    A2,A2              No arguments for SetGCmd
  1463.           MOVEQ     #'F',D0            Finish server command
  1464.           BSR       SetGCmd            Set up for generic commands
  1465.           MOVEQ     #SndGCmdS,D7
  1466.           BRA       DoCmLA1            See if options are bundled
  1467.  
  1468. *** -c connect before ***
  1469.  
  1470. DoCmLA25  ST        D5                 Set the connect before flag on
  1471.           BRA       DoCmLA1            See if options are bundled
  1472.  
  1473. *** -n connect after ***
  1474.  
  1475. DoCmLA26  ST        D6                 Set the connect after flag on
  1476.           BRA       DoCmLA1            See if options are bundled
  1477.  
  1478. FatalEr   BSR       ConWrite           Write the message
  1479. FatalEr1  SF        D0                 Set a bad completion code
  1480.           BRA       SysExod            Return it to system
  1481.  
  1482.           ends
  1483.           END
  1484. <<< k6ocmd.asm >>>
  1485.           nam       Kermit68K
  1486.           ttl       Top-level commands subroutines module
  1487.  
  1488. *         Kermit68K: source file K68CMD
  1489. *
  1490. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  1491. * Bologna University, Physics Department, July 1987.
  1492. *
  1493. * All rights reserved to Bologna University, Italy.
  1494. *
  1495. * Permission is granted to any individual or institution
  1496. * to use, copy, or redistribute this software so long as
  1497. * it  is not  sold for  profit, provided  this copyright
  1498. * notice is retained.
  1499. *
  1500. * Modification History:
  1501. *
  1502. * Version  Date    Who              Comments
  1503. *
  1504. * 1.0.00   870701  Roberto Bagnara  First official release
  1505.  
  1506.           use       DefsFile
  1507.  
  1508. Edition   equ       0
  1509.           psect     K68Commands,0,0,Edition,0,0
  1510.  
  1511. ********************************** Parser *****************************ok
  1512. *                                                                     *
  1513. *  Kermit68K interactive command parser.                              *
  1514. *                                                                     *
  1515. *         Entry conditions : none                                     *
  1516. *                                                                     *
  1517. *         Exit  conditions : D1.B destroyed                           *
  1518. *                            A0.L destroyed                           *
  1519. *                                                                     *
  1520. ***********************************************************************
  1521. Parser:   LEA       VersStr(PC),A0     Give version informations
  1522.           BSR       ConWrite
  1523.  
  1524. Parser1   TST.B     IntMacro(A6)       Are we interpreting a macro ?
  1525.           BEQ.S     Parser2            No, see if we are interpreting a file
  1526.           BSR       McCmdIn            Yes, get the next line of the macro
  1527.           TST.B     D0                 End of macro ?
  1528.           BNE.S     Parser4            No, join the common part
  1529.           SF        IntMacro(A6)       Yes, we're no longer interpreting a macro
  1530.  
  1531. Parser2   MOVE.B    TakLevel(A6),D1    Are we interpreting a take file ?
  1532.           BLT.S     Parser3            No, get a command from terminal
  1533.           ADD.B     #TakeFil0,D1       Yes, compute its channel number
  1534.           BSR       FlCmdIn            Get a command line from file
  1535.           TST.B     D0                 End of file ?
  1536.           BNE.S     Parser4            No, join the common part
  1537.           MOVE.B    TakLevel(A6),D1    Yes, compute the file channel number
  1538.           ADD.B     #TakeFil0,D1       Add this offset
  1539.           BSR       FilClose           Close it
  1540.           SUBQ.B    #1,TakLevel(A6)    Continue with outer take file, if any
  1541.           BRA.S     Parser1
  1542.  
  1543. Parser3   LEA       Prompt(A6),A0      Point to the prompt string
  1544.           BSR       ConWrite           Write it
  1545.           BSR       CCmdIn             Input a command line
  1546.           TST.B     D0                 EOF ?
  1547.           SEQ       Done(A6)           Set the termination flag accordingly
  1548.           BSR       NewLine            Start a new line
  1549.  
  1550. Parser4   SF        Display(A6)        Turn off the display flag
  1551.           LEA       CmdBuf(A6),A0      Command to parse is here
  1552.           BSR       DoCommd            Parse command and execute it
  1553.           TST.B     Done(A6)           Done ?
  1554.           BEQ.S     Parser1            No, stay in loop
  1555.           RTS                          Yes, return to main
  1556.  
  1557. ********************************** DoCommd ****************************ok
  1558. *                                                                     *
  1559. *  Main switcher for commands execution.                              *
  1560. *                                                                     *
  1561. *         Entry conditions : A0.L points to the command line          *
  1562. *                                                                     *
  1563. *         Exit  conditions : D1.B destroyed                           *
  1564. *                            A1.L destroyed                           *
  1565. *                                                                     *
  1566. ***********************************************************************
  1567. DoCommd   MOVEA.L   A0,A5              This is the pointer to command line
  1568.           TST.B     IntMacro(A6)       Are we interpreting a macro ?
  1569.           BNE.S     DoCommd6           Yes, don't search in macro table
  1570.           MOVE.L    A5,-(A7)           No, save the pointer to command line
  1571.           LEA       Argumnt1(A6),A0    Put here the command verb, if any
  1572.           BSR       ParsWrd            Try to get the command verb
  1573.           TST.B     D0                 Success ?
  1574.           BLT.S     DoCommd2           No, return
  1575.           LEA       Argumnt1(A6),A0    Yes, here is the macro name to find
  1576.           BSR       MacFind            Search this name in macro table
  1577.           TST.B     D0                 Found ?
  1578.           BEQ.S     DoCommd4           No, search in command table
  1579. DoCommd1  TST.B     (A0)+              Yes, skip the macro name
  1580.           BNE.S     DoCommd1           Loop until end of macro name
  1581.           MOVE.L    A0,MacroPnt(A6)    Setup this pointer for reading the macro
  1582.           ST        IntMacro(A6)       NOW we are intepreting a macro !
  1583. DoCommd2  ADDQ.L    #4,A7              Remove the line pointer from stack
  1584. DoCommd3  RTS
  1585.  
  1586. DoCommd4  MOVE.L    (A7)+,A5           Restore the pointer to command line
  1587. DoCommd6  LEA       CmdTable(PC),A1    Pointer to command table
  1588.           SF        D1                 The command verb is not mandatory
  1589.           BSR       ParsKyW            Look for a valid command verb
  1590.           TST.B     D0                 Ok ?
  1591.           BLT.S     DoCommd3           No, return
  1592.           LEA       DoCmdTab(PC),A1    Start of jump table
  1593.           BRA       IndxJump           Jump to appropriate command handler
  1594.  
  1595. *** Code for top level commands execution ***
  1596.  
  1597. ChkLocl:  TST.B     Local(A6)          Are we running in local mode ?
  1598.           BNE.S     ChkLocl1           Yes, all ok
  1599.           LEA       StLnFStr(PC),A0    No, load pointer to the error message
  1600.           BSR       ConWrite           Give error message
  1601.           ADDQ.L    #4,A7              Remove caller's return address
  1602. ChkLocl1  RTS
  1603.  
  1604. DoBYE:    BSR       ChkLocl            Check mode
  1605.           SUBA.L    A2,A2              No arguments for SetGCmd
  1606.           MOVEQ     #'L',D0            Logout command
  1607.           BSR       SetGCmd            Setup for generic commands
  1608.           MOVEQ     #SndGCmdS,D7
  1609.           BSR       KPSwtch            Enter the protocol automaton switcher
  1610.           RTS
  1611.  
  1612. *** % command (Treat the rest of the line as a comment) ***
  1613.  
  1614. DoCOMMNT: LEA       DataBuf(A6),A0     Pointer to temporary buffer
  1615.           BSR       ParsWrd            Get a word from the command line
  1616.           TST.B     D0                 End of line ?
  1617.           BGE.S     DoCOMMNT           No, continue
  1618.           RTS                          Yes, return
  1619.  
  1620. *** CONNECT command ***
  1621.  
  1622. DoCONN:   BSR       ChkLocl            Check mode
  1623.           TST.L     Speed(A6)          Is line speed setted ?
  1624.           BGT.S     DoCONN1            Yes, continue
  1625.           LEA       StSpeStr(PC),A0    No, give error message and return
  1626.           BSR       ConWrite
  1627.           RTS
  1628.  
  1629. DoCONN1   LEA       ConnStr1(PC),A0    Yes, give the start of connection message
  1630.           BSR       ConWrite
  1631.           LEA       LineName(A6),A0    Write the line name
  1632.           BSR       ConWrite
  1633.  
  1634.           LEA       ConnStr3(PC),A0    Line speed
  1635.           BSR       ConWrite
  1636.           MOVE.L    Speed(A6),D0       Load speed
  1637.           BSR       TypeUNum           Write the baud rate
  1638.  
  1639.           LEA       ConnStr5(PC),A0    Escape character
  1640.           BSR       ConWrite
  1641.           MOVE.B    Escape(A6),D0      Get the escape character
  1642.           CMPI.B    #' ',D0            Printable character ?
  1643.           BGE.S     DoCONN3            Yes, print it out
  1644.           ADDI.B    #64,D0             Make it printable
  1645.           MOVEQ     #'^',D2            Prefix character for control
  1646.           EXG       D0,D2              Exchange
  1647.           BSR       ConOut             Output prefix
  1648.           EXG       D0,D2              Exchange
  1649. DoCONN3   BSR       ConOut             Output character
  1650.           MOVEQ     #' ',D0            Write a blank
  1651.           BSR       ConOut
  1652.           MOVEQ     #'(',D0            Write an open parenthesis
  1653.           BSR       ConOut
  1654.           MOVEQ     #0,D0              Write the ASCII code of the escape char
  1655.           MOVE.B    Escape(A6),D0
  1656.           BSR       TypeUNum
  1657.           LEA       ConnStr6(PC),A0    Close the parenthesis and give some info
  1658.           BSR       ConWrite
  1659.  
  1660.           MOVEQ     #TextMode,D0       Put line in text mode
  1661.           MOVEQ     #HostLine,D1
  1662.           BSR       ChanCtrl
  1663.           CMPI.B    #AllOk,D0          All ok ?
  1664.           BEQ.S     DoCONN4            Yes, enter the connect loop
  1665.           LEA       CCndLStr(PC),A0    No, point to the error message
  1666.           BSR       ConWrite           Write it on the screen
  1667.           RTS
  1668.  
  1669. DoCONN4   MOVEQ     #Terminal,D1       Try to get a character from terminal
  1670.           BSR       InpChar
  1671.           TST.B     D1                 Character received ?
  1672.           BNE       DoCONN14           No, look at the host line
  1673.           CMP.B     Escape(A6),D0      Escape character ?
  1674.           BNE       DoCONN13           No
  1675.           BSR       ConInp             Get a single character command
  1676.           MOVE.B    D0,D3              Uppercase it
  1677.           BSR       UppCase
  1678.           CMPI.B    #'C',D3            Close command ?
  1679.           BEQ       DoCONN12           Yes
  1680.           CMPI.B    #'?',D3            Help command ?
  1681.           BNE.S     DoCONN5            No
  1682.           LEA       ConnStr8(PC),A0    Yes, give the help message
  1683.           BSR       ConWrite
  1684.           BRA       DoCONN14
  1685. DoCONN5   CMPI.B    #'0',D3            Send null command ?
  1686.           BNE.S     DoCONN6            No
  1687.           MOVEQ     #0,D0              Yes, obey it
  1688.           BSR       HostOut
  1689.           BRA.S     DoCONN14
  1690. DoCONN6   CMPI.B    #'B',D3            Send break command ?
  1691.           BNE.S     DoCONN7
  1692.           MOVEQ     #SndBreak,D0       Request code
  1693.           MOVEQ     #HostLine,D1       Logical channel number
  1694.           BSR       ChanCtrl           Call the channel control routine
  1695.           BRA.S     DoCONN14
  1696. DoCONN7   CMPI.B    #'S',D3            Show status command ?
  1697.           BNE.S     DoCONN9            No
  1698.           LEA       ConnStr2(PC),A0    Yes, show the communication status
  1699.           BSR       ConWrite
  1700.           LEA       LineName(A6),A0    Write the line name
  1701.           BSR       ConWrite
  1702.           LEA       ConnStr3(PC),A0    Write the line speed
  1703.           BSR       ConWrite
  1704.           MOVE.L    Speed(A6),D0       Load speed
  1705.           BSR       TypeUNum           Write the baud rate
  1706.           BSR       NewLine            Start a new line
  1707.           BRA.S     DoCONN14
  1708. DoCONN9   CMPI.B    #'H',D3            Hangup and close command ?
  1709.           BNE.S     DoCONN10           No
  1710. *
  1711. *         Place code for hangup here
  1712. *
  1713.           BRA.S     DoCONN12           Close the connection
  1714. DoCONN10  CMP.B     Escape(A6),D3      Escape character again ?
  1715.           BNE.S     DoCONN11           No
  1716.           MOVE.B    Escape(A6),D0      Yes, send it
  1717.           BSR       HostOut
  1718.           BRA.S     DoCONN14
  1719. DoCONN11  MOVEQ     #Asc_Bel,D0        Invalid command, ring bell
  1720.           BSR       ConOut
  1721.           BRA.S     DoCONN14
  1722. DoCONN12  LEA       ConnStr7(PC),A0    Yes, give the end of connection message
  1723.           BSR       ConWrite
  1724.           RTS                          Exit from transparent mode
  1725.  
  1726. DoCONN13  BSR       HostOut            Output the character just received
  1727.           TST.B     Duplex(A6)         Half duplex ?
  1728.           BEQ.S     DoCONN14           No
  1729.           BSR       ConOut             Yes, echo the character to the terminal
  1730. DoCONN14  MOVEQ     #HostLine,D1       Try to get a character from host
  1731.           BSR       InpChar
  1732.           TST.B     D1                 Character received ?
  1733.           BNE       DoCONN4            No, look at the terminal line
  1734.           BSR       HndlPar            Yes, handle the parity bit
  1735.           BSR       ConOut             Output the character just received
  1736.           BRA       DoCONN4
  1737.  
  1738. *** (Local) COPY command ***
  1739.  
  1740. DoCOPY:   LEA       Argumnt1(A6),A0    Source file specification
  1741.           BSR       ParsWrd            Get it, if any
  1742.           LEA       Argumnt2(A6),A0    Target file specification
  1743.           BSR       ParsTxt            Get it, if any
  1744.           LEA       Argumnt1(A6),A0    Pass arguments addresses ...
  1745.           LEA       Argumnt2(A6),A1    ... to the System subroutine
  1746.           MOVEQ     #CopyFile,D0       Copy file system function wanted
  1747.           BSR       System             Call the external handler
  1748.           LEA       NoCopStr(PC),A0    This is the "on failure" error message
  1749.           BRA       CSysErr            Check cc and, on failure, give message
  1750.  
  1751. *** (Local) CWD command ***
  1752.  
  1753. DoCWD:    LEA       Argumnt1(A6),A0    Directory specification
  1754.           BSR       ParsTxt            Get it, if any
  1755.           LEA       Argumnt1(A6),A0    Pass argument address to System
  1756.           MOVEQ     #ChangDir,D0       Change working directory function
  1757.           BSR       System             Call the external handler
  1758.           LEA       NoCWDStr(PC),A0    This is the "on failure" error message
  1759.           BRA       CSysErr            Check cc and, on failure, give message
  1760.  
  1761. *** DEFINE command ***
  1762.  
  1763. DoDEFN:   TST.B     IntMacro(A6)       Are we interpreting from a macro ?
  1764.           BNE       DoDEFN11           Yes, error
  1765.           LEA       Argumnt1(A6),A0    Put here the macro name, if any
  1766.           BSR       ParsWrd            Try to get it
  1767.           TST.B     D0                 Success ?
  1768.           BLT       DoLIST3            No, notify that macro name is missing
  1769.           LEA       Argumnt1(A6),A0    Yes, point to the parsed macro name
  1770.           BSR       MacFind            Check if this macro is already defined
  1771.           TST.B     D0                 Found ?
  1772.           BEQ.S     DoDEFN4            No, create it
  1773. *                                      Yes, erase it from macro table
  1774. DoDEFN1   MOVEA.L   A0,A1              Macro definition start address
  1775.           BSR       MacSkip            Skip to end of macro body
  1776.           TST.B     D0                 It was the last one ?
  1777.           BNE.S     DoDEFN3            Yes, simply adjust pointer to table end
  1778.           MOVE.L    MTNxtChF(A6),D0    No, load address of the next byte free
  1779. DoDEFN2   MOVE.B    (A1)+,(A0)+        Shift the macro table
  1780.           CMP.L     A1,D0              At end of macro table ?
  1781.           BNE.S     DoDEFN2            No, stay in loop
  1782. DoDEFN3   MOVE.L    A0,MTNxtChF(A6)    Next byte free in macro table is here
  1783.  
  1784. DoDEFN4   LEA       Argumnt1(A6),A1    Point to the parsed macro name
  1785. DoDEFN5   MOVE.B    (A1)+,(A0)+        Store the macro name in macro table
  1786.           BNE.S     DoDEFN5            Loop until end of macro name
  1787.           BSR       ParsTxt            Try to get a one-line macro body
  1788.           TST.B     D0                 Success ?
  1789.           BLT.S     DoDEFN6            No, it's a multi-line macro
  1790.           ADDQ.L    #1,A0              Yes, skip the termination null
  1791.           BRA.S     DoDEFN10           Adjust the end pointer and return
  1792.  
  1793. DoDEFN6   MOVE.L    A0,-(A7)           Save the pointer to the macro table
  1794.  
  1795.           MOVE.B    TakLevel(A6),D1    Are we defining from a take file ?
  1796.           BLT.S     DoDEFN7            No, get next macro line from terminal
  1797.           ADD.B     #TakeFil0,D1       Yes, compute its channel number
  1798.           BSR       FlCmdIn            Get the next macro line from file
  1799.           TST.B     D0                 End of file ?
  1800.           BEQ.S     DoDEFN9            Yes, end of macro body
  1801.           SF        D2                 No, set the termination flag to false
  1802.           BNE.S     DoDEFN8            Join the common part
  1803.  
  1804. DoDEFN7   BSR       CCmdIn             Get another line of text from terminal
  1805.           TST.B     D0                 EOF on input ?
  1806.           SEQ       D2                 Set the termination flag accordingly
  1807.           BSR       NewLine            Start a new line on the terminal
  1808.  
  1809. DoDEFN8   LEA       CmdBuf(A6),A5      The macro line is here
  1810.           MOVE.L    (A7)+,A0           Restore the pointer to the macro table
  1811.           BSR       ParsTxt            Try to get it into the macro table
  1812.           MOVE.B    #Asc_CR,(A0)+      Terminate the line whit a CR
  1813.           TST.B     D0                 The line was null ?
  1814.           BLT.S     DoDEFN9            Yes, this is an end condition
  1815.           TST.B     D2                 Is the termination flag true ?
  1816.           BEQ.S     DoDEFN6            No, continue entering macro lines
  1817. DoDEFN9   CLR.B     -1(A0)             Null terminate the macro body
  1818. DoDEFN10  MOVE.L    A0,MTNxtChF(A6)    Update next byte free in macro table
  1819.           RTS
  1820.  
  1821. DoDEFN11  SUBA.L    A0,A0              No guilty
  1822.           LEA       MNstAStr(PC),A1    Error message, can't nest macros
  1823.           BSR       ParsErr            Write it
  1824.           RTS
  1825.  
  1826. *** (Local) DELETE command ***
  1827.  
  1828. DoDELETE: LEA       Argumnt1(A6),A0    File to delete specification
  1829.           BSR       ParsTxt            Get it, if any
  1830.           LEA       Argumnt1(A6),A0    Pass argument address to System
  1831.           MOVEQ     #DeletFil,D0       Delete file function wanted
  1832.           BSR       System             Call the external handler
  1833.           LEA       NoDelStr(PC),A0    This is the "on failure" error message
  1834.           BRA       CSysErr            Check cc and, on failure, give message
  1835.  
  1836. *** (Local) DIRECTORY command ***
  1837.  
  1838. DoDIR:    LEA       Argumnt1(A6),A0    File or directory specification
  1839.           BSR       ParsTxt            Get it, if any
  1840.           LEA       Argumnt1(A6),A0    Pass argument address to System
  1841.           MOVEQ     #Directry,D0       Directory function wanted
  1842.           BSR       System             Call the external handler
  1843.           LEA       NoDirStr(PC),A0    This is the "on failure" error message
  1844.           BRA       CSysErr            Check cc and, on failure, give message
  1845.  
  1846. *** ECHO command ***
  1847.  
  1848. DoECHO:   LEA       DataBuf(A6),A1     Pointer to temporary buffer
  1849.           MOVEA.L   A1,A0              Pass it to ParsTxt
  1850.           BSR       ParsTxt            Get a text string from the command line
  1851.           TST.B     D0                 Ok ?
  1852.           BLT.S     DoECHO1            No, return
  1853.           MOVEA.L   A1,A0              Reload pointer
  1854.           BSR       ConWrite           Write the string to the terminal line
  1855.           BSR       NewLine            Start a new line
  1856. DoECHO1   RTS
  1857.  
  1858. *** EXIT command ***
  1859.  
  1860. DoEXIT:   ST        Done(A6)           Set the termination flag
  1861.           RTS
  1862.  
  1863. *** FINISH command ***
  1864.  
  1865. DoFINISH: BSR       ChkLocl            Check mode
  1866.           SUBA.L    A2,A2              No arguments for SetGCmd
  1867.           MOVEQ     #'F',D0            Finish server command
  1868.           BSR       SetGCmd            Set up for generic commands
  1869.           MOVEQ     #SndGCmdS,D7
  1870.           BSR       KPSwtch            Enter the protocol automaton switcher
  1871.           RTS
  1872.  
  1873. *** GET command ***
  1874.  
  1875. DoGET:    BSR       ChkLocl            Check mode
  1876.           LEA       Argumnt1(A6),A0    Point to file name string
  1877.           BSR       ParsWrd            Try to get a file name
  1878.           TST.B     D0                 Missing file name ?
  1879.           BLT.S     DoGET1             Yes, give error message
  1880.           LEA       Argumnt2(A6),A0    Point to file as-name string
  1881.           BSR       ParsOuF            Look for a valid output file name
  1882.           LEA       CmdBuf(A6),A0      Put here the file name
  1883.           LEA       Argumnt1(A6),A1    Copy from here
  1884.           MOVEQ     #CmdBufLn,D0       Buffers length
  1885.           BSR       CopyStr            Copy now
  1886.           TST.B     Local(A6)          Are we in local mode ?
  1887.           SNE       Display(A6)        Set transaction display flag accordingly
  1888.           BSR       TrnsInit           Initialize transaction related variables
  1889.           MOVE.B    #'R',ServrCmd(A6)  Get command
  1890.           MOVEQ     #SndSrvIS,D7       Send-Server-Init is the start state
  1891.           BSR       KPSwtch            Enter protocol switcher
  1892.           RTS
  1893. DoGET1    SUBA.L    A0,A0              No guilty
  1894.           LEA       MsFSpStr(PC),A1    Point to error message
  1895.           BSR       ParsErr            Write it
  1896.           RTS
  1897.  
  1898. *** HELP command ***
  1899.  
  1900. ScrnMxLL  EQU       78
  1901. ColumnLn  EQU       12
  1902.  
  1903. DoHELP:   LEA       KerCmStr(PC),A0    Write introduction to Kermit68K commands
  1904.           BSR       ConWrite
  1905.           LEA       CmdTable(PC),A0    Point to top-level commands table start
  1906.           CLR.B     D2                 Initialize the line length counter
  1907. DoHELP1   MOVE.B    (A0)+,D0           Get a character from command table
  1908.           CMP.B     #-1,D0             End of table ?
  1909.           BEQ.S     DoHELP2            Yes, now write macro names
  1910.           BSR.S     DoHELP5            No, write the command name
  1911.           BRA.S     DoHELP1            Loop until end of table
  1912.  
  1913. DoHELP2   BSR       NewLine            Start a new line on the screen
  1914.           CLR.B     D2                 Re-initialize the line length counter
  1915.           LEA       MacroTbl(A6),A1    Load start address of macro table
  1916.           CMPA.L    MTNxtChF(A6),A1    The macro table is empty ?
  1917.           BEQ.S     DoHELP4            Yes, notify this and return
  1918.           LEA       MacCmStr(PC),A0    No, write introduction to user macros
  1919.           BSR       ConWrite
  1920. DoHELP3   MOVEA.L   A1,A0              Now A0 points to tha macro name
  1921.           BSR.S     DoHELP5            Write the macro name
  1922.           BSR       MacSkip            Skip to next macro name
  1923.           TST.B     D0                 The previous was the last macro ?
  1924.           BEQ.S     DoHELP3            No, so write this one
  1925.           BSR       NewLine            Yes, start a new line and return
  1926.           RTS
  1927.  
  1928. DoHELP4   LEA       NoMacStr(PC),A0    Say that there are no user macros
  1929.           BSR       ConWrite
  1930.           RTS
  1931.  
  1932. DoHELP5   MOVEQ     #ColumnLn,D3       Initialize the column length counter
  1933. DoHELP6   MOVE.B    (A0)+,D0           Get a character from the source string
  1934.           BEQ.S     DoHELP7            End of name, write separators
  1935.           BSR       ConOut             Output this character
  1936.           ADDQ.B    #1,D2              Count it
  1937.           SUBQ.B    #1,D3              Decrement the column length counter
  1938.           BEQ.S     DoHELP5            If zero reload it
  1939.           BRA.S     DoHELP6            Loop until end of name
  1940.  
  1941. DoHELP7   CMPI.B    #ScrnMxLL-ColumnLn,D2 There is room for another column ?
  1942.           BGT.S     DoHELP9            No, start a new line on the screen
  1943.           MOVEQ     #' ',D0            Yes, let's pad the column with blanks
  1944. DoHELP8   BSR       ConOut             Write one blank
  1945.           ADDQ.B    #1,D2              Count it
  1946.           SUBQ.B    #1,D3              At end of column ?
  1947.           BNE.S     DoHELP8            No, repeat
  1948.           RTS
  1949. DoHELP9   BSR       NewLine            Start a new line on the terminal screen
  1950.           CLR.B     D2                 Re-initialize the line length counter
  1951.           RTS
  1952.  
  1953. *** LIST command ***
  1954.  
  1955. DoLIST:   LEA       Argumnt1(A6),A0    Put here the macro name, if any
  1956.           BSR       ParsWrd            Try to get the macro name
  1957.           TST.B     D0                 Success ?
  1958.           BLT.S     DoLIST3            No, give error and return
  1959.           LEA       Argumnt1(A6),A0    Yes, point to the parsed macro name
  1960.           BSR       MacFind            Search it in the macro table
  1961.           TST.B     D0                 Found ?
  1962.           BEQ.S     DoLIST4            No, give error and return
  1963. DoLIST0   TST.B     (A0)+              Skip the macro name
  1964.           BNE.S     DoLIST0
  1965. DoLIST1   MOVE.B    (A0)+,D0           Type the macro body, get a character
  1966.           BEQ.S     DoLIST2            End of macro body, exit
  1967.           BSR       ConOut             Output the character just read
  1968.           CMPI.B    #Asc_CR,D0         It was a carriage return ?
  1969.           BNE.S     DoLIST1            No, continue
  1970.           MOVEQ     #Asc_LF,D0         Yes, output a line feed
  1971.           BSR       ConOut
  1972.           BRA.S     DoLIST1            Stay in loop
  1973. DoLIST2   BSR       NewLine            Start a new line on the terminal
  1974.           RTS
  1975. DoLIST3   SUBA.L    A0,A0              No guilty
  1976.           LEA       MsMcNStr(PC),A1    Error message, missing macro name
  1977.           BSR       ParsErr            Write it
  1978.           RTS
  1979. DoLIST4   LEA       Argumnt1(A6),A0    Here is the guilty word
  1980.           LEA       UnkMcStr(PC),A1    Error message, macro not found
  1981.           BSR       ParsErr            Write it
  1982.           RTS
  1983.  
  1984. *** PRINT command ***
  1985.  
  1986. DoPRINT:  LEA       Argumnt1(A6),A0    File to print specification
  1987.           BSR       ParsTxt            Get it, if any
  1988.           LEA       Argumnt1(A6),A0    Pass argument address to System
  1989.           MOVEQ     #PrntFile,D0       Print file function wanted
  1990.           BSR       System             Call the external handler
  1991.           LEA       NoPriStr(PC),A0    This is the "on failure" error message
  1992.           BRA       CSysErr            Check cc and, on failure, give message
  1993.  
  1994. *** RECEIVE command ***
  1995.  
  1996. DoRECVE:  LEA       Argumnt2(A6),A0    Point to file as-name string
  1997.           BSR       ParsOuF            Look for a valid output file name
  1998.           TST.B     D0                 Ok ?
  1999.           BGE.S     DoRECVE1           Yes, file must be stored under this name
  2000.           CMPI.B    #-3,D0             Missing file specification ?
  2001.           BEQ.S     DoRECVE1           Yes, no problem
  2002.           RTS                          No, some other error, return
  2003. DoRECVE1  TST.B     Local(A6)          Are we in local mode ?
  2004.           SNE       Display(A6)        Set transaction display flag accordingly
  2005.           BSR       TrnsInit           Setup transaction related variables
  2006.           MOVEQ     #RecInitS,D7       Receive-Init is the start state
  2007.           BSR       KPSwtch            Enter protocol switcher
  2008.           RTS
  2009.  
  2010. *** RENAME command ***
  2011.  
  2012. DoRENAME: LEA       Argumnt1(A6),A0    Old file name specification
  2013.           BSR       ParsWrd            Get it, if any
  2014.           LEA       Argumnt2(A6),A0    New file name specification
  2015.           BSR       ParsTxt            Get it, if any
  2016.           LEA       Argumnt1(A6),A0    Pass arguments addresses ...
  2017.           LEA       Argumnt2(A6),A1    ... to the System subroutine
  2018.           MOVEQ     #RenamFil,D0       Rename file function wanted
  2019.           BSR       System             Call the external handler
  2020.           LEA       NoRenStr(PC),A0    This is the "on failure" error message
  2021.           BRA       CSysErr            Check cc and, on failure, give message
  2022.  
  2023. *** SEND command ***
  2024.  
  2025. DoSEND:   LEA       Argumnt1(A6),A0    Point to file name string
  2026.           BSR       ParsInF            Try to get a valid input file name
  2027.           TST.B     D0                 Some error ?
  2028.           BLT.S     DoSEND1            Yes, handle it
  2029.           LEA       Argumnt2(A6),A0    Point to file as-name string
  2030.           BSR       ParsTxt            Try to get an as name for this file
  2031.           TST.B     Local(A6)          Are we in local mode ?
  2032.           SNE       Display(A6)        Set transaction display flag accordingly
  2033.           BSR       TrnsInit           Initialize transaction related variables
  2034.           MOVEQ     #SndInitS,D7       Send-Init is the start state
  2035.           BSR       KPSwtch            Enter protocol switcher
  2036.           RTS
  2037. DoSEND1   CMPI.B    #-3,D0             Missing file specification ?
  2038.           BNE.S     DoSEND2            No, error already given
  2039.           SUBA.L    A0,A0              No guilty
  2040.           LEA       MsFSpStr(PC),A1    Point to error message
  2041.           BSR       ParsErr            Write it
  2042. DoSEND2   RTS
  2043.  
  2044. *** (Local) SPACE command ***
  2045.  
  2046. DoSPACE:  LEA       Argumnt1(A6),A0    Directory or device specification
  2047.           BSR       ParsTxt            Get it, if any
  2048.           LEA       Argumnt1(A6),A0    Pass argument address to System
  2049.           MOVEQ     #SpacInfo,D0       Disk usage query function wanted
  2050.           BSR       System             Call the external handler
  2051.           LEA       NoSpaStr(PC),A0    This is the "on failure" error message
  2052.           BRA       CSysErr            Check cc and, on failure, give message
  2053.  
  2054. *** STATISTICS command ***
  2055.  
  2056. DoSTATS:  LEA       StatStr1(PC),A0    Header line and characters sent string
  2057.           MOVE.L    ChrsSent(A6),D6    Characters sent this transaction
  2058.           MOVE.L    TChsSent(A6),D7    Total characters sent
  2059.           BSR.S     DoSTATS1           Display this
  2060.           LEA       StatStr2(PC),A0    Data characters sent string
  2061.           MOVE.L    DChsSent(A6),D6    Data characters sent this transaction
  2062.           MOVE.L    TDChSent(A6),D7    Total data characters sent
  2063.           BSR.S     DoSTATS1           Display this
  2064.           LEA       StatStr3(PC),A0    NAKs received string
  2065.           MOVE.L    NAKsRecd(A6),D6    NAKs received this transaction
  2066.           MOVE.L    TNAKRecd(A6),D7    Total NAKs received
  2067.           BSR.S     DoSTATS1           Display this
  2068.           LEA       StatStr4(PC),A0    Packets sent string
  2069.           MOVE.L    PcksSent(A6),D6    Packets sent this transaction
  2070.           MOVE.L    TPckSent(A6),D7    Total packets sent
  2071.           BSR.S     DoSTATS1           Display this
  2072.           LEA       StatStr5(PC),A0    Characters received string
  2073.           MOVE.L    ChrsRecd(A6),D6    Characters received this transaction
  2074.           MOVE.L    TChsRecd(A6),D7    Total characters received
  2075.           BSR.S     DoSTATS1           Display this
  2076.           LEA       StatStr6(PC),A0    Data characters received string
  2077.           MOVE.L    DChsRecd(A6),D6    Data characters received this transaction
  2078.           MOVE.L    TDChRecd(A6),D7    Total data characters received
  2079.           BSR.S     DoSTATS1           Display this
  2080.           LEA       StatStr7(PC),A0    NAKs received string
  2081.           MOVE.L    NAKsSent(A6),D6    NAKs sent this transaction
  2082.           MOVE.L    TNAKSent(A6),D7    Total NAKs sent
  2083.           BSR.S     DoSTATS1           Display this
  2084.           LEA       StatStr8(PC),A0    Packets received string
  2085.           MOVE.L    PcksRecd(A6),D6    Packets received this transaction
  2086.           MOVE.L    TPckRecd(A6),D7    Total packets received
  2087.           BSR.S     DoSTATS1           Display this
  2088.           RTS
  2089.  
  2090. DoSTATS1  BSR       ConWrite           Write the string
  2091.           MOVE.L    D6,D0              Total for last transaction
  2092.           BSR.S     DoSTATS2           Write number
  2093.           MOVE.L    D7,D0              Total since start of Krmit68K
  2094.           BSR.S     DoSTATS2           Write number
  2095.           BSR       NewLine            Start a new line
  2096.           RTS
  2097.  
  2098. DoSTATS2  SF        D1                 Unsigned conversion wanted
  2099.           MOVEQ     #12,D2             Field length
  2100.           MOVEQ     #10,D3             Base 10
  2101.           LEA       DataBuf+34(A6),A0  Point to the end of a temporary buffer
  2102.           BSR       IntToAs            Convert the number into a string
  2103.           BSR       ConWrite           Write the obtained string
  2104.           RTS
  2105.  
  2106. *** % command (Forward the rest of line to system command processor) ***
  2107.  
  2108. DoSYSCMD: LEA       Argumnt1(A6),A0    Put here the system command
  2109.           BSR       ParsTxt            Get it, if any
  2110.           LEA       Argumnt1(A6),A0    Pass argument address to System
  2111.           MOVEQ     #SysCommd,D0       System command function wanted
  2112.           BSR       System             Call the external handler
  2113.           LEA       NoSyCStr(PC),A0    This is the "on failure" error message
  2114.           BRA       CSysErr            Check cc and, on failure, give message
  2115.  
  2116. *** TAKE command ***
  2117.  
  2118. DoTAKE:   CMPI.B    #MaxTakeF,TakLevel(A6) Take level number at our limit ?
  2119.           BEQ.S     DoTAKE1            Yes, give error and return
  2120.  
  2121.           LEA       Argumnt1(A6),A0    Point to the file name buffer
  2122.           BSR       ParsInF            Try to get a valid input file name
  2123.           TST.B     D0                 Some error ?
  2124.           BLT.S     DoTAKE2            Yes
  2125.  
  2126.           BSR       ChkWild            Check the specified file name
  2127.           TST.B     D0                 Wildcarded name ?
  2128.           BNE.S     DoTAKE4            Yes, give error and return
  2129.  
  2130.           MOVE.B    TakLevel(A6),D1    Get the take level number
  2131.           ADDQ.B    #1,D1              Increment this temporary variable
  2132.           ADD.B     #TakeFil0,D1       Compute the new file channel number
  2133.  
  2134.           MOVEQ     #ReadOp,D0         We want open the file for input
  2135.           BSR       FilOpen            Open the new take file
  2136. *
  2137. *         Warning, the cc is not checked !!!
  2138. *
  2139.           ADDQ.B    #1,TakLevel(A6)    Finally increment the take level
  2140.           RTS
  2141.  
  2142. DoTAKE1   LEA       TFNDpStr(PC),A1    Say take file nested too deeply
  2143.           SUBA.L    A0,A0              No guilty word
  2144.           BSR       ParsErr            Call the error messages routine
  2145.           RTS
  2146.  
  2147. DoTAKE2   CMPI.B    #-3,D0             Has a file name been specified ?
  2148.           BNE.S     DoTAKE3            Yes, message already given, return
  2149.           LEA       MsFSpStr(PC),A1    Give missing file specification error
  2150.           SUBA.L    A0,A0              No guilty word
  2151.           BSR       ParsErr            Write the error message
  2152. DoTAKE3   RTS
  2153.  
  2154. DoTAKE4   LEA       POuFStr1(PC),A1    Give illegal wildcard error message
  2155.           BSR       ParsErr            Call the error messages routine
  2156.           RTS
  2157.  
  2158. *** (Local) TYPE command ***
  2159.  
  2160. DoTYPE:   LEA       Argumnt1(A6),A0    File to type specification
  2161.           BSR       ParsTxt            Get it, if any
  2162.           LEA       Argumnt1(A6),A0    Pass argument address to System
  2163.           MOVEQ     #TypeFile,D0       Type file function wanted
  2164.           BSR       System             Call the external handler
  2165.           LEA       NoTypStr(PC),A0    This is the "on failure" error message
  2166. *          BRA       CSysErr            Check cc and, on failure, give message
  2167.  
  2168.  
  2169. CSysErr   TST.B     D0                 System operation failed ?
  2170.           BNE.S     CSysErr1           No, return
  2171.           BSR       ConWrite           Yes, write corresponding error message
  2172.           BSR       NewLine            Start a new line
  2173. CSysErr1  RTS
  2174.  
  2175.           ends
  2176.           END
  2177. <<< k6octb.asm >>>
  2178.           nam       Kermit68K
  2179.           ttl       Commands keywords tables module
  2180.  
  2181. *         Kermit68K: source file K68CTB
  2182. *
  2183. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  2184. * Bologna University, Physics Department, July 1987.
  2185. *
  2186. * All rights reserved to Bologna University, Italy.
  2187. *
  2188. * Permission is granted to any individual or institution
  2189. * to use, copy, or redistribute this software so long as
  2190. * it  is not  sold for  profit, provided  this copyright
  2191. * notice is retained.
  2192. *
  2193. * Modification History:
  2194. *
  2195. * Version  Date    Who              Comments
  2196. *
  2197. * 1.0.00   870701  Roberto Bagnara  First official release
  2198.  
  2199.           use       DefsFile
  2200.  
  2201. Edition   equ       0
  2202.           psect     K68CmdTables,0,0,Edition,0,0
  2203.  
  2204. * Values associated with top-level commands.
  2205.  
  2206. CmdBYE    EQU       0                  BYE
  2207. CmdCONCT  EQU       1                  CONNECT
  2208. CmdCOPY   EQU       2                  COPY
  2209. CmdCWD    EQU       3                  CWD (Change Working Directory)
  2210. CmdDEFIN  EQU       4                  DEFINE (a command macro)
  2211. CmdDELET  EQU       5                  (Local) DELETE
  2212. CmdDIR    EQU       6                  (Local) DIRECTORY
  2213. CmdECHO   EQU       7                  ECHO
  2214. CmdEXIT   EQU       8                  EXIT
  2215. CmdFINSH  EQU       9                  FINISH
  2216. CmdGET    EQU      10                  GET
  2217. CmdHELP   EQU      11                  HELP
  2218. CmdLIST   EQU      12                  LIST
  2219. CmdPRINT  EQU      13                  (Local) PRINT
  2220. CmdRCEIV  EQU      14                  RECEIVE
  2221. CmdREMOT  EQU      15                  REMOTE
  2222. CmdRENAM  EQU      16                  (Local) RENAME
  2223. CmdSEND   EQU      17                  SEND
  2224. CmdSET    EQU      18                  SET
  2225. CmdSHOW   EQU      19                  SHOW
  2226. CmdSPACE  EQU      20                  (Local) SPACE
  2227. CmdSTATS  EQU      21                  STATISTICS
  2228. CmdTAKE   EQU      22                  TAKE
  2229. CmdTYPE   EQU      23                  (Local) TYPE
  2230. CmdCOMMN  EQU      24                  Comment
  2231. CmdSYSC   EQU      25                  System command
  2232.  
  2233. * Top-level commands string table.
  2234.  
  2235. CmdTable: DC.B      CmdBYE,"BYE",Asc_Nul
  2236.           DC.B      CmdCONCT,"C",Asc_Nul
  2237.           DC.B      CmdCONCT,"CONNECT",Asc_Nul
  2238.           DC.B      CmdCOPY,"COPY",Asc_Nul
  2239.           DC.B      CmdCWD,"CWD",Asc_Nul
  2240.           DC.B      CmdDEFIN,"DEFINE",Asc_Nul
  2241.           DC.B      CmdDELET,"DELETE",Asc_Nul
  2242.           DC.B      CmdDIR,"DIRECTORY",Asc_Nul
  2243.           DC.B      CmdECHO,"ECHO",Asc_Nul
  2244.           DC.B      CmdEXIT,"EXIT",Asc_Nul
  2245.           DC.B      CmdFINSH,"FINISH",Asc_Nul
  2246.           DC.B      CmdGET,"GET",Asc_Nul
  2247.           DC.B      CmdHELP,"HELP",Asc_Nul
  2248.           DC.B      CmdLIST,"LIST",Asc_Nul
  2249.           DC.B      CmdPRINT,"PRINT",Asc_Nul
  2250.           DC.B      CmdEXIT,"QUIT",Asc_Nul
  2251.           DC.B      CmdRCEIV,"R",Asc_Nul
  2252.           DC.B      CmdRCEIV,"RECEIVE",Asc_Nul
  2253.           DC.B      CmdREMOT,"REMOTE",Asc_Nul
  2254.           DC.B      CmdRENAM,"RENAME",Asc_Nul
  2255.           DC.B      CmdSEND,"S",Asc_Nul
  2256.           DC.B      CmdSEND,"SEND",Asc_Nul
  2257.           DC.B      CmdSET,"SET",Asc_Nul
  2258.           DC.B      CmdSHOW,"SHOW",Asc_Nul
  2259.           DC.B      CmdSPACE,"SPACE",Asc_Nul
  2260.           DC.B      CmdSTATS,"STATISTICS",Asc_Nul
  2261.           DC.B      CmdTAKE,"TAKE",Asc_Nul
  2262.           DC.B      CmdTYPE,"TYPE",Asc_Nul
  2263.           DC.B      CmdCOMMN,"%",Asc_Nul
  2264.           DC.B      CmdSYSC,"!",Asc_Nul
  2265.           DC.B      -1
  2266.           DC.B      "command verb",Asc_Nul
  2267.  
  2268. * Top-level commands jump table.
  2269.  
  2270. DoCmdTab: DC.W      DoBYE-DoCmdTab     CmdBYE
  2271.           DC.W      DoCONN-DoCmdTab    CmdCONCT
  2272.           DC.W      DoCOPY-DoCmdTab    CmdCOPY
  2273.           DC.W      DoCWD-DoCmdTab     CmdCWD
  2274.           DC.W      DoDEFN-DoCmdTab   CmdDEFIN
  2275.           DC.W      DoDELETE-DoCmdTab  CmdDELET
  2276.           DC.W      DoDIR-DoCmdTab     CmdDIR
  2277.           DC.W      DoECHO-DoCmdTab    CmdECHO
  2278.           DC.W      DoEXIT-DoCmdTab    CmdEXIT
  2279.           DC.W      DoFINISH-DoCmdTab  CmdFINSH
  2280.           DC.W      DoGET-DoCmdTab     CmdGET
  2281.           DC.W      DoHELP-DoCmdTab    CmdHELP
  2282.           DC.W      DoLIST-DoCmdTab    CmdLIST
  2283.           DC.W      DoPRINT-DoCmdTab   CmdPRINT
  2284.           DC.W      DoRECVE-DoCmdTab   CmdRCEIV
  2285.           DC.W      DoREMOT-DoCmdTab   CmdREMOT
  2286.           DC.W      DoRENAME-DoCmdTab  CmdRENAM
  2287.           DC.W      DoSEND-DoCmdTab    CmdSEND
  2288.           DC.W      DoSET-DoCmdTab     CmdSET
  2289.           DC.W      DoSHOW-DoCmdTab    CmdSHOW
  2290.           DC.W      DoSPACE-DoCmdTab   CmdSPACE
  2291.           DC.W      DoSTATS-DoCmdTab   CmdSTATS
  2292.           DC.W      DoTAKE-DoCmdTab    CmdTAKE
  2293.           DC.W      DoTYPE-DoCmdTab    CmdTYPE
  2294.           DC.W      DoCOMMNT-DoCmdTab  CmdCOMMN
  2295.           DC.W      DoSYSCMD-DoCmdTab  CmdSYSC
  2296.  
  2297. * Values associated with SET command qualifiers.
  2298.  
  2299. SetBCHKT  EQU       0                  Block check type
  2300. SetDELAY  EQU       1                  Delay
  2301. SetDUPLX  EQU       2                  Duplex
  2302. SetESCAP  EQU       3                  Escape character
  2303. SetFILE   EQU       4                  File Parameters
  2304. SetFLOW   EQU       5                  Flow Control
  2305. SetHNDSH  EQU       6                  Handshake
  2306. SetINCFD  EQU       7                  Incomplete File Disposition
  2307. SetLINE   EQU       8                  Communication line to use
  2308. SetPRITY  EQU       9                  Parity
  2309. SetPRMPT  EQU      10                  Program prompt string
  2310. SetRETRY  EQU      11                  Retry limits
  2311. SetSPEED  EQU      12                  Line speed (baud rate)
  2312. SetSEND   EQU      13                  SEND parameters
  2313. SetRCEIV  EQU      14                  RECEIVE parameters
  2314.  
  2315. * SET command qualifiers string table.
  2316.  
  2317. SETTable: DC.B      SetSPEED,"BAUD",Asc_Nul
  2318.           DC.B      SetBCHKT,"BLOCK_CHECK_TYPE",Asc_Nul
  2319.           DC.B      SetDELAY,"DELAY",Asc_Nul
  2320.           DC.B      SetDUPLX,"DUPLEX",Asc_Nul
  2321.           DC.B      SetESCAP,"ESCAPE_CHARACTER",Asc_Nul
  2322.           DC.B      SetFILE,"FILE",Asc_Nul
  2323.           DC.B      SetFLOW,"FLOW_CONTROL",Asc_Nul
  2324.           DC.B      SetHNDSH,"HANDSHAKE",Asc_Nul
  2325.           DC.B      SetINCFD,"INCOMPLETE_FILE_DISPOSITION",Asc_Nul
  2326.           DC.B      SetLINE,"LINE",Asc_Nul
  2327.           DC.B      SetPRITY,"PARITY",Asc_Nul
  2328.           DC.B      SetPRMPT,"PROMPT",Asc_Nul
  2329.           DC.B      SetRCEIV,"RECEIVE",Asc_Nul
  2330.           DC.B      SetRETRY,"RETRY",Asc_Nul
  2331.           DC.B      SetSEND,"SEND",Asc_Nul
  2332.           DC.B      SetSPEED,"SPEED",Asc_Nul
  2333.           DC.B      -1
  2334.           DC.B      "SET option or parameter",Asc_Nul
  2335.  
  2336. * SET command qualifiers jump table.
  2337.  
  2338. DoSetTab: DC.W      DoStBCT-DoSetTab   SetBCHKT
  2339.           DC.W      DoStDLAY-DoSetTab  SetDELAY
  2340.           DC.W      DoStDUP-DoSetTab   SetDUPLX
  2341.           DC.W      DoSetESC-DoSetTab  SetESCAP
  2342.           DC.W      DoSFILE-DoSetTab   SetFILE
  2343.           DC.W      DoStFLW-DoSetTab   SetFLOW
  2344.           DC.W      DoStHND-DoSetTab   SetHNDSH
  2345.           DC.W      DoStIFD-DoSetTab   SetINCFD
  2346.           DC.W      DoStLIN-DoSetTab   SetLINE
  2347.           DC.W      DoStPAR-DoSetTab   SetPRITY
  2348.           DC.W      DoStPRM-DoSetTab   SetPRMPT
  2349.           DC.W      DoSRTRY-DoSetTab   SetRETRY
  2350.           DC.W      DoStSPE-DoSetTab   SetSPEED
  2351.           DC.W      DoSSEND-DoSetTab   SetSEND
  2352.           DC.W      DoSRECV-DoSetTab   SetRCEIV
  2353.  
  2354. * Values associated with SET SEND/RECEIVE parameters.
  2355.  
  2356. SetEOL    EQU       0                  End-Of-Line (packet terminator)
  2357. SetMARKR  EQU       1                  Start of Packet marker
  2358. SetMXPLN  EQU       2                  Maximum packet length to send
  2359. SetNPAD   EQU       3                  Amount of padding
  2360. SetPDCHR  EQU       4                  Pad character
  2361. SetTMOUT  EQU       5                  Timeout interval
  2362.  
  2363. * SET SEND/RECEIVE parameters string table.
  2364.  
  2365. SSRTable: DC.B      SetEOL,"END_OF_LINE",Asc_Nul
  2366.           DC.B      SetMARKR,"MARKER",Asc_Nul
  2367.           DC.B      SetMXPLN,"PACKET_LENGTH",Asc_Nul
  2368.           DC.B      SetNPAD,"PADDING",Asc_Nul
  2369.           DC.B      SetPDCHR,"PAD_CHARACTER",Asc_Nul
  2370.           DC.B      SetTMOUT,"TIMEOUT",Asc_Nul
  2371.           DC.B      -1
  2372.           DC.B      "SET SEND/RECEIVE parameter",Asc_Nul
  2373.  
  2374. * SET SEND parameters jump table.
  2375.  
  2376. DoSetSTb: DC.W      DoStSEOL-DoSetSTb  SetEOL
  2377.           DC.W      DoStSMrk-DoSetSTb  SetMARKR
  2378.           DC.W      DoStSMPS-DoSetSTb  SetMXPLN
  2379.           DC.W      DoStSPdN-DoSetSTb  SetNPAD
  2380.           DC.W      DoStSPdC-DoSetSTb  SetPDCHR
  2381.           DC.W      DoStSTIM-DoSetSTb  SetTMOUT
  2382.  
  2383. * SET RECEIVE parameters jump table.
  2384.  
  2385. DoSetRTb: DC.W      DoStREOL-DoSetRTb  SetEOL
  2386.           DC.W      DoStRMrk-DoSetRTb  SetMARKR
  2387.           DC.W      DoStRMPS-DoSetRTb  SetMXPLN
  2388.           DC.W      DoStRPdN-DoSetRTb  SetNPAD
  2389.           DC.W      DoStRPdC-DoSetRTb  SetPDCHR
  2390.           DC.W      DoStRTIM-DoSetRTb  SetTMOUT
  2391.  
  2392. * Values associated with REMOTE command qualifiers.
  2393.  
  2394. RemCOPY   EQU       0                  Copy
  2395. RemCWD    EQU       1                  Change Working Directory
  2396. RemDELET  EQU       2                  Delete
  2397. RemDIR    EQU       3                  Directory
  2398. RemHELP   EQU       4                  Help
  2399. RemHOST   EQU       5                  Host
  2400. RemKRMIT  EQU       6                  Kermit
  2401. RemPRINT  EQU       7                  Print
  2402. RemRENAM  EQU       8                  Rename
  2403. RemSET    EQU       9                  SET
  2404. RemSPACE  EQU      10                  Space
  2405. RemSUBMT  EQU      11                  Submit
  2406. RemTYPE   EQU      12                  Type
  2407. RemWHO    EQU      13                  Who
  2408.  
  2409. * REMOTE command qualifiers string table.
  2410.  
  2411. REMTable: DC.B      RemCOPY,"COPY",Asc_Nul
  2412.           DC.B      RemCWD,"CWD",Asc_Nul
  2413.           DC.B      RemDELET,"DELETE",Asc_Nul
  2414.           DC.B      RemDIR,"DIRECTORY",Asc_Nul
  2415.           DC.B      RemHELP,"HELP",Asc_Nul
  2416.           DC.B      RemHOST,"HOST",Asc_Nul
  2417.           DC.B      RemKRMIT,"KERMIT",Asc_Nul
  2418.           DC.B      RemPRINT,"PRINT",Asc_Nul
  2419.           DC.B      RemRENAM,"RENAME",Asc_Nul
  2420.           DC.B      RemSET,"SET",Asc_Nul
  2421.           DC.B      RemSPACE,"SPACE",Asc_Nul
  2422.           DC.B      RemSUBMT,"SUBMIT",Asc_Nul
  2423.           DC.B      RemTYPE,"TYPE",Asc_Nul
  2424.           DC.B      RemWHO,"WHO",Asc_Nul
  2425.           DC.B      -1
  2426.           DC.B      "REMOTE Kermit server command",Asc_Nul
  2427.  
  2428. * REMOTE command qualifiers jump table.
  2429.  
  2430. DoRemTab: DC.W      DoRemCOP-DoRemTab  RemCOPY
  2431.           DC.W      DoRmCWD-DoRemTab   RemCWD
  2432.           DC.W      DoRemDEL-DoRemTab  RemDELET
  2433.           DC.W      DoRmDIR-DoRemTab   RemDIR
  2434.           DC.W      DoRmHELP-DoRemTab  RemHELP
  2435.           DC.W      DoRemHOS-DoRemTab  RemHOST
  2436.           DC.W      DoRemKER-DoRemTab  RemKRMIT
  2437.           DC.W      DoRemPRI-DoRemTab  RemPRINT
  2438.           DC.W      DoRemREN-DoRemTab  RemRENAM
  2439.           DC.W      DoRemSET-DoRemTab  RemSET
  2440.           DC.W      DoRmSPA-DoRemTab   RemSPACE
  2441.           DC.W      DoRemSUB-DoRemTab  RemSUBMT
  2442.           DC.W      DoRemTYP-DoRemTab  RemTYPE
  2443.           DC.W      DoRmWHO-DoRemTab   RemWHO
  2444.  
  2445. * Values associated with SHOW command qualifiers.
  2446.  
  2447. ShoPARAM  EQU       0                  Parameters
  2448. ShoVERS   EQU       1                  Version
  2449.  
  2450. * SHOW command qualifiers table.
  2451.  
  2452. SHOWTabl: DC.B      ShoPARAM,"PARAMETERS",Asc_Nul
  2453.           DC.B      ShoVERS,"VERSION",Asc_Nul
  2454.           DC.B      -1
  2455.           DC.B      "SHOW option",Asc_Nul
  2456.  
  2457. * SHOW command options jump table.
  2458.  
  2459. DoShoTab: DC.W      DoShoP-DoShoTab    ShoPARAM
  2460.           DC.W      DoShoVer-DoShoTab  ShoVERS
  2461.  
  2462. * Values associated with SET FILE command parameters.
  2463.  
  2464. SetFDISP  EQU       0                  File display
  2465. SetFNAME  EQU       1                  File naming
  2466. SetFTYPE  EQU       2                  File type
  2467. SetFWARN  EQU       3                  File warning
  2468.  
  2469. * SET FILE command parameters table.
  2470.  
  2471. SFILTabl: DC.B      SetFDISP,"DISPLAY",Asc_Nul
  2472.           DC.B      SetFNAME,"NAMES",Asc_Nul
  2473.           DC.B      SetFTYPE,"TYPE",Asc_Nul
  2474.           DC.B      SetFWARN,"WARNING",Asc_Nul
  2475.           DC.B      -1
  2476.           DC.B      "file parameter",Asc_Nul
  2477.  
  2478. * SET FILE command parameters jump table.
  2479.  
  2480. DoSFlTab: DC.W      DoStFDs-DoSFlTab   SetFDISP
  2481.           DC.W      DoStFNm-DoSFlTab   SetFNAME
  2482.           DC.W      DoStFTp-DoSFlTab   SetFTYPE
  2483.           DC.W      DoStFWn-DoSFlTab   SetFWARN
  2484.  
  2485. * Values associated with SET RETRY command parameters.
  2486.  
  2487. SetRtINI  EQU       0                  Set retry initial connection packet
  2488. SetRtPAK  EQU       1                  Set retry normal packet
  2489.  
  2490. * SET RETRY command parameters table.
  2491.  
  2492. SRETTabl: DC.B      SetRtINI,"INITIAL_CONNECTION",Asc_Nul
  2493.           DC.B      SetRtPAK,"PACKET",Asc_Nul
  2494.           DC.B      -1
  2495.           DC.B      "retry parameter",Asc_Nul
  2496.  
  2497. * SET RETRY command parameters jump table.
  2498.  
  2499. DoSRtTab: DC.W      DoSetRtI-DoSRtTab  SetRtINI
  2500.           DC.W      DoSetRtP-DoSRtTab  SetRtPAK
  2501.  
  2502. * On/Off specification keyword table.
  2503.  
  2504. OnOfTabl: DC.B      0,"FALSE",Asc_Nul
  2505.           DC.B      0,"OFF",Asc_Nul
  2506.           DC.B      0,"NO",Asc_Nul
  2507.           DC.B      0,"0",Asc_Nul
  2508.           DC.B      1,"TRUE",Asc_Nul
  2509.           DC.B      1,"ON",Asc_Nul
  2510.           DC.B      1,"YES",Asc_Nul
  2511.           DC.B      1,"1",Asc_Nul
  2512.           DC.B      -1
  2513.           DC.B      "on/off specification",Asc_Nul
  2514.  
  2515. * Block check specification keyword table.
  2516.  
  2517. BlCkTabl: DC.B      1,"1",Asc_Nul
  2518.           DC.B      1,"ONE",Asc_Nul
  2519.           DC.B      2,"2",Asc_Nul
  2520.           DC.B      2,"TWO",Asc_Nul
  2521.           DC.B      3,"3",Asc_Nul
  2522.           DC.B      3,"THREE",Asc_Nul
  2523.           DC.B      -1
  2524.           DC.B      "block check type specification",Asc_Nul
  2525.  
  2526. * Parity specification keyword table.
  2527.  
  2528. ParTable: DC.B      0,"NONE",Asc_Nul
  2529.           DC.B      "O","ODD",Asc_Nul
  2530.           DC.B      "E","EVEN",Asc_Nul
  2531.           DC.B      "M","MARK",Asc_Nul
  2532.           DC.B      "S","SPACE",Asc_Nul
  2533.           DC.B      -1
  2534.           DC.B      "parity specification",Asc_Nul
  2535.  
  2536. * Incomplete file disposition keyword table.
  2537.  
  2538. IFlDTabl: DC.B      0,"DISCARD",Asc_Nul
  2539.           DC.B      1,"KEEP",Asc_Nul
  2540.           DC.B      -1
  2541.           DC.B      "incomplete file disposition",Asc_Nul
  2542.  
  2543. * File type specification keyword table.
  2544.  
  2545. FTypTabl: DC.B      0,"TEXT",Asc_Nul
  2546.           DC.B      1,"BINARY",Asc_Nul
  2547.           DC.B      -1
  2548.           DC.B      "file type specification",Asc_Nul
  2549.  
  2550. * File naming specification keyword table.
  2551.  
  2552. FNamTabl: DC.B      0,"LITERAL",Asc_Nul
  2553.           DC.B      1,"CONVERTED",Asc_Nul
  2554.           DC.B      -1
  2555.           DC.B      "file naming specification",Asc_Nul
  2556.  
  2557. * Flow control specification keyword table.
  2558.  
  2559. FlowTabl: DC.B      0,"NONE",Asc_Nul
  2560.           DC.B      1,"XON/XOFF",Asc_Nul
  2561.           DC.B      -1
  2562.           DC.B      "flow control specification",Asc_Nul
  2563.  
  2564. * Duplex specification keyword table.
  2565.  
  2566. DuplTabl: DC.B      0,"FULL",Asc_Nul
  2567.           DC.B      1,"HALF",Asc_Nul
  2568.           DC.B      -1
  2569.           DC.B      "duplex specification",Asc_Nul
  2570.  
  2571. * Handshake characters specification keyword table.
  2572.  
  2573. HandTabl: DC.B      0,"NONE",Asc_Nul
  2574.           DC.B      Asc_Bel,"BELL",Asc_Nul
  2575.           DC.B      Asc_LF,"LF",Asc_Nul
  2576.           DC.B      Asc_CR,"CR",Asc_Nul
  2577.           DC.B      Asc_DC1,"XON",Asc_Nul
  2578.           DC.B      Asc_DC3,"XOFF",Asc_Nul
  2579.           DC.B      Asc_Esc,"ESC",Asc_Nul
  2580.           DC.B      -1
  2581.           DC.B      "handshake character specification",Asc_Nul
  2582.  
  2583.           align                        Following code aligned on word boundary
  2584.           ends
  2585.           END
  2586. <<< k6odef.asm >>>
  2587. *         Kermit68K: source file K68DEF
  2588. *
  2589. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  2590. * Bologna University, Physics Department, July 1987.
  2591. *
  2592. * All rights reserved to Bologna University, Italy.
  2593. *
  2594. * Permission is granted to any individual or institution
  2595. * to use, copy, or redistribute this software so long as
  2596. * it  is not  sold for  profit, provided  this copyright
  2597. * notice is retained.
  2598. *
  2599. * Modification History:
  2600. *
  2601. * Version  Date    Who              Comments
  2602. *
  2603. * 1.0.00   870701  Roberto Bagnara  First official release
  2604. * ??????   ??????  Steve Williams   Modified for OS9 (see below)
  2605.  
  2606. *  This file is adapted in a very straightforward manner from the original
  2607. *  k68def.src file.
  2608. *
  2609. *  Since the OS-9 assembler will not allow the declaration of labels inside
  2610. *  a macro definition (ala the'\3 equ VarIndex' used previously) the do.b,
  2611. *  do.w, and do.l pseudo instructions are used instead.  These perform a
  2612. *  very similiar offset definition function.
  2613. *
  2614. *  This file has been converted to its own psect for the following reasons:
  2615. *
  2616. *  1.  It makes defining the dependencies in the make utility makefile much
  2617. *      easier, since each object file depends on only one source file.
  2618. *
  2619. *  2.  It greatly decreases the development cycle time by reducing the disk
  2620. *      accesses needed during reassembly.
  2621. *
  2622. *  3.  The OS-9 symobolic debugger needs global symbols in order to provide
  2623. *      meaningful interpretation of programs being debugged.
  2624.  
  2625. Edition   set       1
  2626.           psect     K68Definitions,0,0,Edition,0,0
  2627.  
  2628. *         Truth values
  2629.  
  2630. True:     EQU      -1                  True value, in the sense of Scc opcode
  2631. False:    EQU       0                  False value, in the sense of Scc opcode
  2632.  
  2633. *         ASCII control characters
  2634.  
  2635. Asc_Nul:  EQU       0                  Nul or tape feed
  2636. Asc_SOH:  EQU       1                  Start of heading
  2637. Asc_STx:  EQU       2                  Start of text
  2638. Asc_ETx:  EQU       3                  End of text
  2639. Asc_EOT:  EQU       4                  End of transmission
  2640. Asc_Enq:  EQU       5                  Enquire
  2641. Asc_Ack:  EQU       6                  Acknowledge
  2642. Asc_Bel:  EQU       7                  Bell
  2643. Asc_BS:   EQU       8                  Backspace
  2644. Asc_HT:   EQU       9                  Horizontal tab
  2645. Asc_LF:   EQU      10                  Line feed
  2646. Asc_VT:   EQU      11                  Vertical tab
  2647. Asc_FF:   EQU      12                  Form feed
  2648. Asc_CR:   EQU      13                  Carriage return
  2649. Asc_SO:   EQU      14                  Shift out
  2650. Asc_SI:   EQU      15                  Shift in
  2651. Asc_DLE:  EQU      16                  Data link escape
  2652. Asc_DC1:  EQU      17                  Device control 1
  2653. Asc_DC2:  EQU      18                  Device control 2
  2654. Asc_DC3:  EQU      19                  Device control 3
  2655. Asc_DC4:  EQU      20                  Device control 4
  2656. Asc_NAk:  EQU      21                  Negative acknowledge
  2657. Asc_Syn:  EQU      22                  Synchronous idle
  2658. Asc_ETB:  EQU      23                  End of transmission block
  2659. Asc_Can:  EQU      24                  Cancel
  2660. Asc_EM:   EQU      25                  End of medium
  2661. Asc_Sub:  EQU      26                  Substitute
  2662. Asc_Esc:  EQU      27                  Escape, prefix
  2663. Asc_FS:   EQU      28                  File separator
  2664. Asc_GS:   EQU      29                  Group separator
  2665. Asc_RS:   EQU      30                  Record separator
  2666. Asc_US:   EQU      31                  Unit separator
  2667. Asc_Del:  EQU     127                  Delete
  2668.  
  2669. *          Buffers and strings sizes
  2670.  
  2671. StkMDpth: EQU     512                  Max stack depth (long words)
  2672. McrTblLn: equ    2000                  Mcaro table length
  2673. RBufLen:  EQU     200                  Receive buffer length
  2674. CmdBufLn: EQU     200                  Command buffer length
  2675. PromptML: EQU      32                  Prompt string max length
  2676. LinNamML: EQU      32                  Line name string max length
  2677. FilNamML: EQU      28                  File names max length (for OS9--was 40)
  2678. MxPckSiz: EQU      94                  Maximum packet size
  2679. MaxTakeF: EQU      20                  Maximum number of nested take files
  2680.  
  2681. *         Kermit protocol automaton states
  2682.  
  2683. SndInitS: EQU       0                  Send-Init
  2684. OpnFileS: EQU       1                  Open-File
  2685. SndFileS: EQU       2                  Send-File
  2686. SndDataS: EQU       3                  Send-Data
  2687. SendEOFS: EQU       4                  Send-End-Of-File
  2688. SendEOTS: EQU       5                  Send-Break
  2689. RecInitS: EQU       6                  Receive-Init
  2690. RecFileS: EQU       7                  Receive-File
  2691. RecDataS: EQU       8                  Receive-Data
  2692. SndSrvIS: EQU       9                  Send-Server-Init
  2693. SndGCmdS: EQU      10                  Send-Generic-Command
  2694. CompletS: EQU      11                  Complete
  2695. AbortS:   EQU      12                  Abort
  2696.  
  2697. *         Logical channels
  2698.  
  2699. Null:     EQU       0                  Null logical channel number
  2700. Terminal: EQU       1                  Terminal line logical channel number
  2701. HostLine: EQU       2                  Host line logical channel number
  2702. IOFile:   EQU       3                  I/O file logical channel number
  2703. TakeFil0: EQU       4                  Outer level take file ...
  2704. TakeFil1: EQU       5                  ... and so on
  2705.  
  2706. *         System I/O routines InpChar, OutChar and ChanCtrl completion codes
  2707.  
  2708. AllOk:    EQU       0                  No errors
  2709. BadChan:  EQU       1                  Inexistent channel
  2710. ResChan:  EQU       2                  Access reserved, permission denied
  2711. DevNotRd: EQU       3                  Device not ready (e.g. unmounted)
  2712. NotInpCh: EQU       4                  Input impossible on this channel
  2713. NotOutCh: EQU       5                  Output impossible on this channel
  2714. NotOpRd:  EQU       6                  File not open for read
  2715. NotOpWr:  EQU       7                  File not open for write
  2716. UnrInpF:  EQU       8                  Unrecoverable failure during input
  2717. UnrOutF:  EQU       9                  Unrecoverable failure during output
  2718. InChLost: EQU      10                  Input character lost
  2719. InpBreak: EQU      11                  Break received on input
  2720. BufEmpty: EQU      12                  Input buffer empty
  2721. BufOvflw: EQU      13                  Input buffer overflow
  2722. EndOfFil: EQU      14                  End of file reached on input
  2723. DevFull:  EQU      15                  Device full, not enough space
  2724. BadCtReq: EQU      16                  I/O control request code invalid
  2725.  
  2726. *         FilOpen function request codes
  2727.  
  2728. RdWrOp:   EQU       0                  Open for read/write
  2729. ReadOp:   EQU       1                  Open for read
  2730. WriteOp:  EQU       2                  Open for write
  2731. AppendOp: EQU       3                  Open for append
  2732.  
  2733. *         I/O channel control requests
  2734.  
  2735. SetBaud:  EQU       0                  Set baud rate on port
  2736. RawMode:  EQU       1                  Enable raw mode
  2737. TextMode: EQU       2                  Enable text mode
  2738. DoXCntrl: EQU       3                  Enable XON/XOFF protocol
  2739. NoXCntrl: EQU       4                  Disable XON/XOFF protocol
  2740. SndBreak: EQU       5                  Send a break over RS 232 C line
  2741. ClrInpBf: EQU       6                  Clear input buffer
  2742. ClrOutBf: EQU       7                  Clear output buffer
  2743.  
  2744. *         System function request codes
  2745.  
  2746. SysCommd: equ       0                  Forward a command to system
  2747. Directry: EQU       1                  Display a directory listing
  2748. SpacInfo: EQU       2                  Display informations about disk usage
  2749. DeletFil: EQU       3                  Delete file(s)
  2750. CopyFile: EQU       4                  Copy file(s)
  2751. ChangDir: EQU       5                  Change the default directory
  2752. PrntFile: EQU       6                  Print file(s)
  2753. RenamFil: EQU       7                  Rename file(s)
  2754. TypeFile: EQU       8                  Type file(s)
  2755.  
  2756. *         Screen request codes
  2757.  
  2758. SFilName: EQU       0                  Outgoing file name
  2759. RFilName: EQU       1                  Inbound file name
  2760. FlAsName: EQU       2                  File as-name
  2761. XPckData: EQU       3                  X packet data
  2762. FlTranOk: EQU       4                  File transfer ok
  2763. FlDiscrd: EQU       5                  File discarded
  2764. FlIntrrp: EQU       6                  File interrupted
  2765. FlSkippd: EQU       7                  File skipped
  2766. PackType: EQU       8                  Packet type
  2767. TranCmpl: EQU       9                  Transaction complete
  2768. ErrMessg: EQU      10                  Error message
  2769. WarnMess: EQU      11                  Warning message
  2770. UndelTxt: EQU      12                  Undelimited text
  2771. TxtDlBeg: EQU      13                  Text delimited at the beginning
  2772. TxtDlEnd: EQU      14                  Text delimited at the end
  2773. ScrnMxRq: EQU      14                  Screen function max request code
  2774.  
  2775. *         Program variables defaults
  2776.  
  2777. DefDuplx: equ       False              Default duplex
  2778. DefPrity: EQU       0                  Default parity
  2779. DefEscap: EQU       5                  Default escape character for connect
  2780. DefFlow:  EQU       1                  Default line flow control
  2781. DefLocal: EQU       True               Default mode, local or remote
  2782. DefSpeed: EQU    9600                  Default line speed
  2783. DefDelay: EQU       5                  Default initial delay before sending
  2784. DefRetIn: EQU      16                  Defaulut retry limit initial connection
  2785. DefRetPk: EQU      10                  Defaulut retry limit normal packets
  2786.  
  2787. *         Send Init parameters
  2788.  
  2789. MyMxPSiz: EQU      90                  Biggest packet I want receive
  2790. MyTimOut: EQU      10                  When I want to be timed out
  2791. MyPad:    EQU       0                  How much padding I need
  2792. MyPadChr: EQU       Asc_Nul            Padding character I want
  2793. MyEOL:    EQU       Asc_CR             End-Of-Line character I want
  2794. MyCtlQot: EQU       '#'                Control-Quote character I send
  2795. MyRptQot: EQU       $7E                Repeat-Quote character I send
  2796. My8BQuot: EQU       '&'                8th-Bit prefix char I will use
  2797.  
  2798. *         Receive Init default parameters
  2799.  
  2800. DefMxPSz: EQU      80                  Default biggest packet you can receive
  2801. DefTmOut: EQU      10                  Default when you want to be timed out
  2802. DefPadNm: EQU       0                  Default how much padding you need
  2803. DefPadCr: EQU       Asc_Nul            Default padding character you want
  2804. DefEOL:   EQU       Asc_CR             Default End-Of-Line character you want
  2805. DefCtlQt: EQU       '#'                Default Control-Quote character you send
  2806.  
  2807. *    System variables
  2808. *    OS-9 will not accept a macro argument as a label, so the variable
  2809. *    declarations have been done in another way.  The do.s directive keeps
  2810. *    a running offset location counter (separate from the code counter) that
  2811. *    can be reset at any time using the org directive.
  2812.  
  2813.           org       0
  2814.  
  2815. *    Packet related variables
  2816.  
  2817. PackNum:  do.b      1                  Packet number
  2818. PrevPckN: do.b      1                  Previous packet number
  2819. NextPckN: do.b      1                  Next packet number
  2820. SendType: do.b      1                  Packet type just sent
  2821. IStPckCh: do.b      1                  Incoming packet start character
  2822. OStPckCh: do.b      1                  Outbound packet start character
  2823. Size:     do.b      1                  Current output data packet size
  2824. OldSize:  do.b      1                  Previous output data packet size
  2825. First:    do.b      1                  Flag for first character from input
  2826. Current:  do.b      1                  Current character from input
  2827. Next:     do.b      1                  Next character from input
  2828.  
  2829. *    Communication line variables
  2830.  
  2831. Speed:    do.l      1                  Line speed, -1 if unknown
  2832. Parity:   do.b      1                  Parity specified, 0, 'E', 'O', 'M', 'S'
  2833. Flow:     do.b      1                  Flow control, 1 for xon/xoff
  2834. TurnFlag: do.b      1                  Line turnaround handshake flag
  2835. TurnChar: do.b      1                  Line turnaround character
  2836. Delay:    do.b      1                  Initial delay before sending
  2837. Duplex:   do.b      1                  Duplex, full by default
  2838. Escape:   do.b      1                  Escape character for connect
  2839.  
  2840. *    Program variables
  2841.  
  2842. CmdBfPnt: do.b      1                  Relative pointer to command buffer
  2843. ServrCmd: do.b      1                  Server command to send
  2844. Retry:    do.b      1                  Retry limit currently in use
  2845. RtryInit: do.b      1                  Retry limit initial connection packets
  2846. RtryPack: do.b      1                  Retry limit for normal packets
  2847. TakLevel: do.b      1                  Take file level
  2848.  
  2849. LFSave:   do.b      1                  This is for newline processing
  2850.  
  2851. * If the system uses a single character for text file line delimitation,
  2852. * assign to NewLinCh the ASCII value of that character.  For text files,
  2853. * that character will be converted to CRLF upon output, and CRLF will be
  2854. * converted to that character on input.
  2855.  
  2856. NewLinCh: EQU       Asc_CR             Line delimiter for text files
  2857.  
  2858. *    Variables for Send-Init parameters
  2859.  
  2860. ICtlQuot: do.b      1                  Control prefix in incoming data
  2861. OCtlQuot: do.b      1                  Control prefix in outgoing data
  2862. IEOL:     do.b      1                  End-Of-Line character to look for
  2863. OEOL:     do.b      1                  End-Of-Line character to send
  2864. IPadNumb: do.b      1                  How much padding to ask for
  2865. OPadNumb: do.b      1                  How much padding to send
  2866. IPadChar: do.b      1                  Padding character to ask for
  2867. OPadChar: do.b      1                  Padding character to send
  2868. ITimInt:  do.b      1                  Timeout interval I use
  2869. OTimInt:  do.b      1                  Timeout interval I want you to use
  2870. IMPckSiz: do.b      1                  Biggest packet size I want to receive
  2871. OMPckSiz: do.b      1                  Biggest packet size I can send
  2872. BlChkUs:  do.b      1                  Block check type used
  2873. BlChkRq:  do.b      1                  Block check type requested
  2874. ReptCnt:  do.b      1                  Repeat count
  2875. ReptQuot: do.b      1                  Repeat prefix
  2876. ReptFlag: do.b      1                  Repeat processing flag
  2877. Bit8Quot: do.b      1                  8th bit prefix
  2878. Bit8Flag: do.b      1                  8th bit quoting flag
  2879. TimInFlg: do.b      1                  Flag to override the timeout requested
  2880. SndPSFlg: do.b      1                  Flag to override the size requested
  2881.  
  2882. *    Flags
  2883.  
  2884. MStrFlag: do.b      1                  Flag for input from memory string
  2885. TermOut:  do.b      1                  Flag for output to the terminal channel
  2886. CtlXSeen: do.b      1                  Flag for cancelling a file
  2887. CtlZSeen: do.b      1                  Flag for cancelling a file group
  2888. Binary:   do.b      1                  Flag for binary file
  2889. FNameCnv: do.b      1                  Flag for converting file names
  2890. Keep:     do.b      1                  Flag for incomplete file disposition
  2891. Warning:  do.b      1                  Flag for file warning
  2892. Display:  do.b      1                  Flag for file transfer display
  2893. Quiet:    do.b      1                  Be quiet during file transfer
  2894. Local:    do.b      1                  Flag for running in local mode
  2895. IntMacro: do.b      1                  Flag for interpreting macros
  2896. Done:     do.b      1                  Flag for exiting the command parser
  2897.  
  2898. *    String and buffer variables
  2899.  
  2900. LeftOver: do.b      6                  Small buffer for optimal packet filling
  2901. Prompt:   do.b      PromptML           Prompt string
  2902. LineName: do.b      LinNamML           Communication line name
  2903. FilName:  do.b      FilNamML           Current file name
  2904. Argumnt1: do.b      CmdBufLn           First command argument
  2905. Argumnt2: do.b      CmdBufLn           Second command argument
  2906. DataBuf:  do.b      MxPckSiz+4         Packet data buffer
  2907. SendBuf:  do.b      MxPckSiz+4         Send packet buffer
  2908. RecBuf:   do.b      RBufLen            Receive packet buffer
  2909. CmdBuf:   do.b      CmdBufLn           Buffer for command interpretation
  2910. MacroTbl: do.b      McrTblLn           Macro definitions table
  2911.  
  2912. *    Statistic variables
  2913.  
  2914. ChrsSent: do.l      1                  Chars sent last transaction
  2915. TChsSent: do.l      1                  Total characters sent
  2916. ChrsRecd: do.l      1                  Chars received last transaction
  2917. TChsRecd: do.l      1                  Total characters received
  2918. DChsSent: do.l      1                  Data chars sent last transaction
  2919. TDChSent: do.l      1                  Total data characters sent
  2920. DChsRecd: do.l      1                  Data chars received last transaction
  2921. TDChRecd: do.l      1                  Total data characters received
  2922. PcksSent: do.l      1                  Packets sent last transaction
  2923. TPckSent: do.l      1                  Total packet sent
  2924. PcksRecd: do.l      1                  Packets received last transaction
  2925. TPckRecd: do.l      1                  Total packet received
  2926. NAKsSent: do.l      1                  NAKs sent last transaction
  2927. TNAKSent: do.l      1                  Total NAKs sent
  2928. NAKsRecd: do.l      1                  NAKs received last transaction
  2929. TNAKRecd: do.l      1                  Total NAKs received
  2930.  
  2931. *    Pointers
  2932.  
  2933. MStrgPnt: do.l      1                  Pointer for input from memory string
  2934. MacroPnt: do.l      1                  Pointer for macro interpretation
  2935. MTNxtChF: do.l      1                  Pointer to the end of the macro table
  2936.  
  2937. *    System dependent routines variables
  2938.  
  2939. LinLngth: do.b      1                  For the dumb terminal Screen routine
  2940. MyFNBuff: do.b      FilNamML           This is for tests on my system
  2941.  
  2942. *    OS-9/68000 specific variables
  2943.  
  2944. CR_Last:  do.b      1                  Flag for CR/LF stripping on terminal
  2945. TermFlag: do.b      1                  Flag used in OutChar for terminal.
  2946. Pathnums: do.w     20                  OS-9 path numbers for logical channels
  2947. NumFiles: do.l      1                  Number of files left to process
  2948. NextFile: do.l      1                  Pointer to next file name
  2949. CmdLinPt: do.l      1                  Pointer to the OS-9 command arguments
  2950. FNBuffer: do.b     50*FilNamML         File names buffer for ExpandFN
  2951.  
  2952. ShellCmd: do.b    128                  Buffer for constructing shell commands
  2953.  
  2954. OptBuff:  do.b    128                  Save area for terminal input PD options
  2955.  
  2956. *  Must set the VarIndex variable to the current offset location counter
  2957. *  so that the variable section can be set up properly
  2958.  
  2959. VarIndex: do.w      1                  Seems reasonable to be word aligned
  2960.  
  2961.           vsect
  2962. VarArea:  ds.b      VarIndex           Storage definition for the variables area
  2963.           ends
  2964.           ends
  2965.           end
  2966. <<< k6oiof.asm >>>
  2967.           nam       Kermit68K
  2968.           ttl       IO subroutines module
  2969.  
  2970. *         Kermit68K: source file K68IOF
  2971. *
  2972. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  2973. * Bologna University, Physics Department, July 1987.
  2974. *
  2975. * All rights reserved to Bologna University, Italy.
  2976. *
  2977. * Permission is granted to any individual or institution
  2978. * to use, copy, or redistribute this software so long as
  2979. * it  is not  sold for  profit, provided  this copyright
  2980. * notice is retained.
  2981. *
  2982. * Modification History:
  2983. *
  2984. * Version  Date    Who              Comments
  2985. *
  2986. * 1.0.00   870701  Roberto Bagnara  First official release
  2987.  
  2988.           use       DefsFile
  2989.  
  2990. Edition   equ       0
  2991.           psect     K68IOFunctions,0,0,Edition,0,0
  2992.  
  2993. ********************************* ConInp ******************************ok
  2994. *                                                                     *
  2995. *  Expect a character from the terminal line.                         *
  2996. *                                                                     *
  2997. *         Entry conditions : none                                     *
  2998. *                                                                     *
  2999. *         Exit  conditions : D0.B character received                  *
  3000. *                            D1.B AllOk completion code               *
  3001. *                                                                     *
  3002. ***********************************************************************
  3003. ConInp:   MOVEQ     #Terminal,D1       Terminal line I/O channel
  3004.           BSR       InpChar            Try to read a character
  3005.           TST.B     D1                 All ok ?
  3006.           BNE.S     ConInp             No, assume not ready for input, wait
  3007.           RTS                          Yes, return
  3008.  
  3009. ********************************* ConOut ******************************ok
  3010. *                                                                     *
  3011. *  Send a character to the terminal line.                             *
  3012. *                                                                     *
  3013. *         Entry conditions : D0.B character to send                   *
  3014. *                                                                     *
  3015. *         Exit  conditions : D0.B character just sent                 *
  3016. *                            D1.B completion code                     *
  3017. *                                                                     *
  3018. ***********************************************************************
  3019. ConOut:   MOVEQ     #Terminal,D1       Terminal line I/O channel
  3020.           BSR       OutChar            Try to send the character
  3021.           RTS                          Return completion code from OutChar
  3022.  
  3023. ********************************* HostOut *****************************ok
  3024. *                                                                     *
  3025. *  Send a character to the host line adding a parity bit.             *
  3026. *                                                                     *
  3027. *         Entry conditions : D0.B character to send                   *
  3028. *                                                                     *
  3029. *         Exit  conditions : D0.B character just sent                 *
  3030. *                            D1.B completion code                     *
  3031. *                                                                     *
  3032. ***********************************************************************
  3033. HostOut:  BSR       DoPrity            Add an appropriate parity bit
  3034.           MOVEQ     #HostLine,D1       Terminal line I/O channel
  3035.           BSR       OutChar            Try to send the character
  3036.           RTS                          Return completion code from OutChar
  3037.  
  3038. ********************************* FileOut *****************************ok
  3039. *                                                                     *
  3040. *  Write a character to the current I/O file. If an error occurs      *
  3041. *  during output then set an interruption flag to stop the file       *
  3042. *  transfer.                                                          *
  3043. *                                                                     *
  3044. *         Entry conditions : D0.B character to send                   *
  3045. *                                                                     *
  3046. *         Exit  conditions : D0.B character just sent                 *
  3047. *                            D1.B completion code                     *
  3048. *                                                                     *
  3049. ***********************************************************************
  3050. FileOut:  MOVEQ     #IOFile,D1         Current file I/O channel
  3051.           BSR       OutChar            Output the character to it
  3052.           TST.B     D1                 Some error ?
  3053.           BEQ.S     FileOut1           No, return
  3054.           ST        CtlZSeen(A6)       Yes, interrupt the file transfer
  3055. FileOut1  RTS
  3056.  
  3057. ******************************* ConWrite ******************************ok
  3058. *                                                                     *
  3059. *  Write a null terminated string on the terminal line.               *
  3060. *                                                                     *
  3061. *         Entry conditions : A0.L pointer to string buffer            *
  3062. *                                                                     *
  3063. *         Exit  conditions : D1.L destroyed                           *
  3064. *                                                                     *
  3065. ***********************************************************************
  3066. ConWrite: MOVEQ     #Terminal,D1       Terminal line I/O channel
  3067.           BSR.S     Write              Write now
  3068.           RTS
  3069.  
  3070. ******************************* TypeUNum ******************************ok
  3071. *                                                                     *
  3072. *  Write a decimal unsigned number to the terminal line.              *
  3073. *                                                                     *
  3074. *         Entry conditions : D0.L number to be typed                  *
  3075. *                                                                     *
  3076. *         Exit  conditions : none                                     *
  3077. *                                                                     *
  3078. ***********************************************************************
  3079. TypeUNum: MOVEM.L   D1-D3,-(A7)        Save working registers
  3080.           SF        D1                 Unsigned conversion wanted
  3081.           MOVEQ     #0,D2              Null field
  3082.           MOVEQ     #10,D3             Base 10
  3083.           LEA       DataBuf+34(A6),A0  Point to the end of a temporary buffer
  3084.           BSR       IntToAs            Convert the number into a string
  3085.           BSR       ConWrite           Write the obtained string
  3086.           MOVEM.L   (A7)+,D1-D3        Restore working registers
  3087.           RTS
  3088.  
  3089. ********************************* Write *******************************ok
  3090. *                                                                     *
  3091. *  Write a null terminated string on a logical channel.               *
  3092. *                                                                     *
  3093. *         Entry conditions : D1.B channel number                      *
  3094. *                            A0.L pointer to string buffer            *
  3095. *                                                                     *
  3096. *         Exit  conditions : D1.B channel number                      *
  3097. *                                                                     *
  3098. ***********************************************************************
  3099. Write:    MOVE.W    D2,-(A7)           Save working register
  3100.           MOVE.B    D1,D2              Save channel number
  3101. Write1    MOVE.B    (A0)+,D0           Get a character
  3102.           BEQ.S     Write2             Leave if end of string reached
  3103.           BSR       OutChar            Send the character, assume no errors
  3104.           MOVE.B    D2,D1              Restore channel number
  3105.           BRA.S     Write1             Repeat until end of string
  3106. Write2    MOVE.W    (A7)+,D2           Restore working register
  3107.           RTS
  3108.  
  3109. ********************************* NewLine *****************************ok
  3110. *                                                                     *
  3111. *  Send a newline sequence (CR+LF) to the terminal line.              *
  3112. *                                                                     *
  3113. *         Entry conditions : none                                     *
  3114. *                                                                     *
  3115. *         Exit  conditions : D0.L destroyed                           *
  3116. *                                                                     *
  3117. ***********************************************************************
  3118. NewLine:  MOVE.L    D1,-(A7)           Save this register, destroyed by ConOut
  3119.           MOVEQ     #Asc_CR,D0         Send a CR
  3120.           BSR       ConOut
  3121.           MOVEQ     #Asc_LF,D0         And then a LF
  3122.           BSR       ConOut
  3123.           MOVE.L    (A7)+,D1           Restore working register
  3124.           RTS
  3125.  
  3126. ********************************* CCmdIn ******************************ok
  3127. *                                                                     *
  3128. *  Input a command line from the terminal line, store it to CmdBuf.   *
  3129. *                                                                     *
  3130. *         Entry conditions : none                                     *
  3131. *                                                                     *
  3132. *         Exit  conditions : D0.B completion code, false on EOF       *
  3133. *                                                                     *
  3134. ***********************************************************************
  3135. CCmdIn:   MOVEM.L   A0-A1/D1-D3,-(A7)  Save working registers
  3136.           LEA       CmdBuf(A6),A0      Start address
  3137.           MOVEA.L   A0,A1              Save start address
  3138. CCmdIn1   BSR       ConInp             Get a character
  3139.           CMPI.B    #Asc_Sub,D0        EOF character ?
  3140.           BEQ.S     CCmdIn10           Yes
  3141.           CMPI.B    #Asc_CR,D0         CR ?
  3142.           BEQ.S     CCmdIn8            Yes
  3143.           CMPI.B    #Asc_LF,D0         CR ?
  3144.           BEQ.S     CCmdIn8            Yes
  3145.           CMPI.B    #Asc_FF,D0         CR ?
  3146.           BEQ.S     CCmdIn8            Yes
  3147.           CMPI.B    #Asc_Del,D0        Delete ?
  3148.           BEQ.S     CCmdIn2            Yes
  3149.           CMPI.B    #Asc_BS,D0         Backspace ?
  3150.           BNE.S     CCmdIn3            No
  3151. CCmdIn2   CMPA.L    A1,A0              At line begin ?
  3152.           BEQ.S     CCmdIn1            Yes, no action
  3153.           BSR.S     CCmdIn11           No, delete last character
  3154.           BRA.S     CCmdIn1            Another character please !
  3155. CCmdIn3   CMPI.B    #Asc_Can,D0        Ctrl X ?
  3156.           BNE.S     CCmdIn5            No
  3157. CCmdIn4   CMPA.L    A1,A0              At line begin ?
  3158.           BEQ.S     CCmdIn1            Yes, exit
  3159.           BSR.S     CCmdIn11           No, delete last character
  3160.           BRA.S     CCmdIn4            Repeat until the whole line is deleted
  3161. CCmdIn5   MOVE.B    D0,(A0)+           Store the character
  3162.           CMPI.B    #' ',D0            Printable character ?
  3163.           BGE.S     CCmdIn6            Yes, print it out
  3164.           CMPI.B    #Asc_HT,D0         Horizontal tab ?
  3165.           BEQ.S     CCmdIn6            Yes, print it out
  3166.           ADDI.B    #64,D0             Make it printable
  3167.           MOVEQ     #'^',D2            Prefix character for control
  3168.           EXG       D0,D2              Exchange
  3169.           BSR       ConOut             Output prefix
  3170.           EXG       D0,D2              Exchange
  3171. CCmdIn6   BSR       ConOut             Output character
  3172. CCmdIn7   MOVE.L    A0,D3              Other characters to read ?
  3173.           SUB.L     A1,D3
  3174.           CMPI.W    #CmdBufLn,D3
  3175.           BLT.S     CCmdIn1            Yes, again please !!!
  3176. CCmdIn8   ST        D0                 Return a positive completion code
  3177. CCmdIn9   CLR.B     (A0)+              Null as terminator
  3178.           MOVEM.L   (A7)+,A0-A1/D1-D3  Restore working registers
  3179.           RTS
  3180. CCmdIn10  SF        D0                 Return a negative cc, EOF on input
  3181.           BRA.S     CCmdIn9            Join common part
  3182. CCmdIn11  MOVE.B    -(A0),D0           Back off
  3183.           CMPI.B    #' ',D0            Printable character ?
  3184.           BGE.S     CCmdIn12           Yes, only one character to delete
  3185.           BSR.S     CCmdIn13           No, delete the prefix
  3186. CCmdIn12  BSR.S     CCmdIn13           Delete character
  3187.           RTS
  3188. CCmdIn13  MOVEQ     #Asc_BS,D0         Delete the last character
  3189.           BSR       ConOut
  3190.           MOVEQ     #' ',D0
  3191.           BSR       ConOut
  3192.           MOVEQ     #Asc_BS,D0
  3193.           BSR       ConOut
  3194.           RTS
  3195.  
  3196. ********************************* FlCmdIn *****************************ok
  3197. *                                                                     *
  3198. *  Input a command line from a take file, store it to CmdBuf.         *
  3199. *                                                                     *
  3200. *         Entry conditions : D1.B take file channel number            *
  3201. *                                                                     *
  3202. *         Exit  conditions : D0.B completion code                     *
  3203. *                            D1.B destroyed                           *
  3204. *                            D2.B destroyed                           *
  3205. *                            A0.L destroyed                           *
  3206. *                                                                     *
  3207. ***********************************************************************
  3208. FlCmdIn:  LEA      CmdBuf(A6),A0       Pointer to target buffer
  3209.           MOVE.B   D1,D2               Save the channel number
  3210. FlCmdIn1  BSR      InpChar             Try to get a character
  3211.           CMP.B    #AllOk,D1           Ok ?
  3212.           BEQ.S    FlCmdIn3            Yes
  3213.           CMP.B    #EndOfFil,D1        End of file ?
  3214.           BEQ.S    FlCmdIn2            Yes, return the proper completion code
  3215.           LEA      FlCmdStr(PC),A0     No, some error during read
  3216.           BSR      ConWrite            Give this message
  3217. FlCmdIn2  SF       D0
  3218.           RTS
  3219. FlCmdIn3  CMPI.B   #NewLinCh,D0        End of line ?
  3220.           BEQ.S    FlCmdIn4            Yes, exit loop
  3221.           MOVE.B   D0,(A0)+            No, store the character just read
  3222.           MOVE.B   D2,D1               Reload channel number for the next read
  3223.           BRA.S    FlCmdIn1            Stay in loop
  3224. FlCmdIn4  CLR.B    (A0)                Terminate the command buffer
  3225.           ST       D0                  Return a positive completion code
  3226.           RTS
  3227.  
  3228. ********************************* McCmdIn *****************************ok
  3229. *                                                                     *
  3230. *  Input a command line from a macro, store it to CmdBuf.             *
  3231. *                                                                     *
  3232. *         Entry conditions : none                                     *
  3233. *                                                                     *
  3234. *         Exit  conditions : D0.B completion code                     *
  3235. *                            A0.L destroyed                           *
  3236. *                            A1.L destroyed                           *
  3237. *                                                                     *
  3238. ***********************************************************************
  3239. McCmdIn:  LEA      CmdBuf(A6),A0       Pointer to target buffer
  3240.           MOVEA.L  MacroPnt(A6),A1     Pointer to source buffer
  3241.           TST.B    (A1)                Are we at the end of the macro body ?
  3242.           BEQ.S    McCmdIn4            Yes, end of macro, return false
  3243. McCmdIn1  MOVE.B   (A1)+,D0            Get a character
  3244.           BEQ.S    McCmdIn2            If null, this is the last line
  3245.           CMPI.B   #Asc_CR,D0          End of line ?
  3246.           BEQ.S    McCmdIn3            Yes, ...
  3247.           MOVE.B   D0,(A0)+            Store the character in target buffer
  3248.           BRA.S    McCmdIn1            Loop until end of line
  3249. McCmdIn2  SUBQ.L   #1,A1               Still point to the null, next time ...
  3250. McCmdIn3  MOVE.L   A1,MacroPnt(A6)     Save the pointer to next macro line
  3251.           CLR.B    (A0)                Terminate the command buffer
  3252.           ST       D0                  Return a positive completion code
  3253.           RTS
  3254. McCmdIn4  SF       D0                  End of macro, return a negative cc
  3255.           RTS
  3256.  
  3257. ********************************* SendPad *****************************ok
  3258. *                                                                     *
  3259. *  Send padding characters to the communication line.                 *
  3260. *                                                                     *
  3261. *         Entry conditions : none                                     *
  3262. *                                                                     *
  3263. *         Exit  conditions : D0.B destroyed                           *
  3264. *                                                                     *
  3265. ***********************************************************************
  3266. SendPad:  MOVEM.L   D1-D2,-(A7)        Save working registers
  3267.           CLR.W     D2                 Clear counter register
  3268.           MOVE.B    OPadNumb(A6),D2    Number of padding char to send
  3269.           BRA.S     SendPad2           Enter loop
  3270. SendPad1  MOVE.B    OPadChar(A6),D0    Padding character to send
  3271.           BSR       HostOut            Send padding character to host line
  3272. SendPad2  DBF       D2,SendPad1        Repeat
  3273.           MOVEM.L   (A7)+,D1-D2        Restore working registers
  3274.           RTS
  3275.  
  3276. ********************************* TxPackt *****************************ok
  3277. *                                                                     *
  3278. *  Send the packet stored in SendBuf to the host line.                *
  3279. *                                                                     *
  3280. *         Entry conditions : none                                     *
  3281. *                                                                     *
  3282. *         Exit  conditions : none                                     *
  3283. *                                                                     *
  3284. ***********************************************************************
  3285. TxPackt:  MOVEM.L   D1/A0,-(A7)        Save working registers
  3286.           BSR       SendPad            Do any requested padding
  3287.           LEA       SendBuf(A6),A0     Packet buffer start
  3288. TxPackt1  MOVE.B    (A0)+,D0           Get a character
  3289.           BEQ.S     TxPackt2           Leave if end of string reached
  3290.           BSR       HostOut            Send the character
  3291.           ADDQ.L    #1,ChrsSent(A6)    Increment chars sent this transaction
  3292.           ADDQ.L    #1,TChsSent(A6)    Increment total characters sent
  3293.           BRA.S     TxPackt1           Repeat until end of string
  3294. TxPackt2  ADDQ.L    #1,PcksSent(A6)    Increment packets sent this trans
  3295.           ADDQ.L    #1,TPckSent(A6)    Increment total packets sent
  3296.           MOVEM.L   (A7)+,D1/A0        Restore working registers
  3297.           RTS
  3298.  
  3299. ******************************** InpLine ******************************ok
  3300. *                                                                     *
  3301. *  Input a line (up to the break char) from the communication line.   *
  3302. *                                                                     *
  3303. *         Entry conditions : none                                     *
  3304. *                                                                     *
  3305. *         Exit  conditions : D0.L number of characters received       *
  3306. *                            D1.B completion code                     *
  3307. *                            A0.L destroyed                           *
  3308. *                            D2.L destroyed                           *
  3309. *                            D3.W destroyed                           *
  3310. *                            D4.B destroyed                           *
  3311. *                                                                     *
  3312. ***********************************************************************
  3313. InpLine:  LEA       RecBuf(A6),A0      Point to receive buffer
  3314.           CLR.L     D2                 Clear the character counter
  3315.           CLR.W     D3                 Clear the timeout counter
  3316.           TST.B     TurnFlag(A6)       Is the turnaround handshake flag on ?
  3317.           BEQ.S     InpLine0           No, look for Input EOL as terminator
  3318.           MOVE.B    TurnChar(A6),D4    Yes, turnaround character as terminator
  3319.           BRA.S     InpLine1
  3320. InpLine0  MOVE.B    IEOL(A6),D4        Load the Input End Of Line character
  3321. InpLine1  MOVE.B    ITimInt(A6),D3     Preset the timeout counter
  3322. InpLine2  BSR       RdChrTO            Get a character
  3323.           TST.B     D1                 Timed out ?
  3324.           BNE.S     InpLine3           No, continue
  3325.           DBF       D3,InpLine2        Yes, repeat unless timeout limit reached
  3326.           SF        D1                 Provide a negative completion code
  3327.           RTS
  3328.  
  3329. InpLine3  CMP.B     D4,D0              End Of Line or turnaround character ?
  3330.           BEQ.S     InpLine4           Yes
  3331.           MOVE.B    D0,(A0)+           No, got a character, save it
  3332.           ADDQ.L    #1,D2              Increment the character counter
  3333.           CMPI.B    #RBufLen,D2        Receive buffer full ?
  3334.           BNE.S     InpLine1           No, again please !
  3335. InpLine4  CLR.B     (A0)               Mark the end of buffer
  3336.           ADD.L     D2,ChrsRecd(A6)    Increment chars received this transaction
  3337.           ADD.L     D2,TChsRecd(A6)    Increment total characters received
  3338.           MOVE.L    D2,D0              Return number of characters received
  3339.           ST        D1                 Return a positive completion code
  3340.           RTS
  3341.  
  3342. ******************************** RdChrTO ******************************ok
  3343. *                                                                     *
  3344. *  Called only by InpLine, read a character from the host line with   *
  3345. *  1 second software timeout limit. Warning, this routine is          *
  3346. *  absolutely provisory.                                              *
  3347. *                                                                     *
  3348. *         Entry conditions : none                                     *
  3349. *                                                                     *
  3350. *         Exit  conditions : D0.B character received                  *
  3351. *                            D1.B completion code                     *
  3352. *                                                                     *
  3353. ***********************************************************************
  3354. MaxIter   SET       10000              To set the timeout value
  3355. *
  3356. RdChrTO   MOVE.W    D2,-(A7)           Save the counter register
  3357.           MOVE.W    #MaxIter,D2        Set up the timeout counter
  3358. RdChrTO1  MOVEQ     #HostLine,D1       Try to read the host line
  3359.           BSR       InpChar
  3360.           TST.B     D1                 Check completion code
  3361.           BEQ.S     RdChrTO2           Character received, handle 8th bit
  3362.           DBF       D2,RdChrTO1        Timeout period expired ?
  3363.           SF        D1                 Yes, return negative completion code
  3364.           MOVE.W    (A7)+,D2           Restore the counter register
  3365.           RTS
  3366. RdChrTO2  BSR       HndlPar            Handle the parity bit
  3367.           ST        D1                 Return positive completion code
  3368.           MOVE.W    (A7)+,D2           Restore the counter register
  3369.           RTS
  3370.  
  3371. ********************************* ChkInpF *****************************ok
  3372. *                                                                     *
  3373. *  Check if an input file exists and is readable.                     *
  3374. *                                                                     *
  3375. *         Entry conditions : none                                     *
  3376. *                                                                     *
  3377. *         Exit  conditions : D0.B completion code                     *
  3378. *                                                                     *
  3379. *                            -3 file exists but protected from read   *
  3380. *                            -2 file exists but is not readable       *
  3381. *                            -1 inexistent or inaccessable file       *
  3382. *                             0 all ok                                *
  3383. *                                                                     *
  3384. *                            D1.L destroyed                           *
  3385. *                            D2.B destroyed                           *
  3386. *                                                                     *
  3387. ***********************************************************************
  3388. ChkInpF:  MOVEQ     #ReadOp,D0         Try to open for read the input file
  3389.           MOVEQ     #IOFile,D1         Assign it to this channel number
  3390.           BSR       FilOpen            Open now
  3391.           TST.B     D0                 Some failure ?
  3392.           BEQ.S     ChkInpF1           Yes, return this bad completion code
  3393.           MOVEQ     #IOFile,D1         No, try to read a character
  3394.           BSR       InpChar
  3395.           MOVE.B    D1,D2              Save the returned completion code
  3396.           MOVEQ     #IOFile,D1         Close the file just opened
  3397.           BSR       FilClose
  3398.           TST.B     D2                 The read was successful ?
  3399.           BEQ.S     ChkInpF0           Yes, all ok
  3400.           CMPI.B    #EndOfFil,D2       No, end of file ?
  3401.           BEQ.S     ChkInpF0           Yes, the file is null, but ok
  3402.           CMPI.B    #ResChan,D2        No privilege to read this file ?
  3403.           BEQ.S     ChkInpF2           Yes, return this bad completion code
  3404.           MOVEQ     #-2,D0             No, some other error, unreadable file cc
  3405.           RTS
  3406. ChkInpF0  MOVEQ     #0,D0              Return all ok
  3407.           RTS
  3408. ChkInpF1  MOVEQ     #-1,D0             Return inexistent file cc
  3409.           RTS
  3410. ChkInpF2  MOVEQ     #-3,D0             Return protected file cc
  3411.           RTS
  3412.  
  3413. ********************************* ChkOutF *****************************ok
  3414. *                                                                     *
  3415. *  Check if an output file can be created.                            *
  3416. *                                                                     *
  3417. *         Entry conditions : none                                     *
  3418. *                                                                     *
  3419. *         Exit  conditions : D0.B completion code                     *
  3420. *                                                                     *
  3421. *                            -1 permission denied                     *
  3422. *                             0 all ok                                *
  3423. *                                                                     *
  3424. ***********************************************************************
  3425. ChkOutF:  MOVEQ     #0,D0              Always succeeds for now
  3426.           RTS
  3427.  
  3428. ********************************* OpnInpF *****************************ok
  3429. *                                                                     *
  3430. *  Try to open an existing file for input.                            *
  3431. *                                                                     *
  3432. *         Entry conditions : A0.L pointer to the file name            *
  3433. *                                                                     *
  3434. *         Exit  conditions : A0.L pointer to the file name            *
  3435. *                            D0.B completion code                     *
  3436. *                            D1.L destroyed                           *
  3437. *                                                                     *
  3438. ***********************************************************************
  3439. OpnInpF:  MOVE.B    MStrFlag(A6),D0    Input from memory string ?
  3440.           BNE.S     OpnInpF1           Yes, return a positive cc
  3441.           MOVEQ     #ReadOp,D0         Try to open the input file
  3442.           MOVEQ     #IOFile,D1
  3443.           BSR       FilOpen
  3444.           TST.B     D0                 Open succeed ?
  3445.           BEQ.S     OpnInpF1           Yes, return this completion code
  3446.           BSR       CRemTLoc           No, convert name to local form
  3447.           MOVEQ     #ReadOp,D0         Try again to open the input file
  3448.           MOVEQ     #IOFile,D1
  3449.           BSR       FilOpen
  3450. OpnInpF1  RTS                          Return cc from FilOpen
  3451.  
  3452. ********************************* OpnOutF *****************************ok
  3453. *                                                                     *
  3454. *  Try to open an existing file for output.                           *
  3455. *                                                                     *
  3456. *         Entry conditions : A0.L pointer to the file name            *
  3457. *                            A1.L pointer to the file name            *
  3458. *                                 target buffer                       *
  3459. *                                                                     *
  3460. *         Exit  conditions : A0.L pointer to the file name target     *
  3461. *                                 buffer containing the file name     *
  3462. *                                 under wich the file was opened      *
  3463. *                            D0.B completion code                     *
  3464. *                            D1.L destroyed                           *
  3465. *                                                                     *
  3466. ***********************************************************************
  3467. OpnOutF:  MOVE.B    TermOut(A6),D0     Terminal output wanted ?
  3468.           BNE.S     OpnOutF3           Yes, return a positive cc
  3469.           MOVE.B    CtlXSeen(A6),D0    Some interruption ?
  3470.           OR.B      CtlZSeen(A6),D0
  3471.           BNE.S     OpnOutF3           Yes, don't destroy existing file
  3472.           EXG       A0,A1              Exchange buffers pointers
  3473.           MOVEQ     #FilNamML,D0       Load buffers length
  3474.           BSR       CopyStr            Fill target buffer, copy from source
  3475.           TST.B     FNameCnv(A6)       File names conversion ?
  3476.           BEQ.S     OpnOutF1           No, proceed
  3477.           BSR       CRemTLoc           Yes, convert file name to local form
  3478. OpnOutF1  TST.B     Warning(A6)        File collision avoidance ?
  3479.           BEQ.S     OpnOutF2           No, proceed
  3480.           BSR       ChkInpF            Yes, check if file exists
  3481.           CMPI.B    #-1,D0             File exists ?
  3482.           BEQ.S     OpnOutF2           No, proceed
  3483.           BSR       NewName            Yes, make a new name
  3484. OpnOutF2  MOVEQ     #WriteOp,D0        Finally open the file for output
  3485.           MOVEQ     #IOFile,D1
  3486.           BSR       FilOpen
  3487. OpnOutF3  RTS                          Return the completion code
  3488.  
  3489. ********************************* ClsInpF *****************************ok
  3490. *                                                                     *
  3491. *  Close the current input file.                                      *
  3492. *                                                                     *
  3493. *         Entry conditions : none                                     *
  3494. *                                                                     *
  3495. *         Exit  conditions : D0.L destroyed                           *
  3496. *                            D1.L destroyed                           *
  3497. *                                                                     *
  3498. ***********************************************************************
  3499. ClsInpF:  TST.B     MStrFlag(A6)       Input from memory string ?
  3500.           BEQ.S     ClsInpF1           No, close the input file
  3501.           SF        MStrFlag(A6)       Yes, reset flag
  3502.           BRA.S     ClsInpF2
  3503. ClsInpF1  MOVEQ     #IOFile,D1         Close the output file
  3504.           BSR       FilClose
  3505. ClsInpF2  MOVE.B    CtlXSeen(A6),D0    File interrupt ...
  3506.           OR.B      CtlZSeen(A6),D0    ... or file group interrupt ?
  3507.           BNE.S     ClsInpF3           Yes, give discard message
  3508.           MOVEQ     #FlTranOk,D0       No, give comforting messages
  3509.           BSR       Screen
  3510.           BRA.S     ClsInpF4
  3511. ClsInpF3  MOVEQ     #FlDiscrd,D0       Give discard message
  3512.           BSR       Screen
  3513. ClsInpF4  SF        CtlXSeen(A6)       Reset file interrupt flag
  3514.           CLR.B     FilName(A6)        Nullify current file name
  3515.           RTS
  3516.  
  3517. ********************************* ClsOutF *****************************ok
  3518. *                                                                     *
  3519. *  Close the current output file.                                     *
  3520. *                                                                     *
  3521. *         Entry conditions : none                                     *
  3522. *                                                                     *
  3523. *         Exit  conditions : D0.L destroyed                           *
  3524. *                            D1.L destroyed                           *
  3525. *                            A0.L destroyed                           *
  3526. *                                                                     *
  3527. ***********************************************************************
  3528. ClsOutF:  TST.B     TermOut(A6)        Output to the terminal line ?
  3529.           BNE.S     ClsOutF3           Yes, just reset flag and return
  3530.           LEA       FilName(A6),A0     No, point to current file name
  3531.           TST.B     (A0)               File open ?
  3532.           BEQ.S     ClsOutF1           No
  3533.           MOVEQ     #IOFile,D1         Yes, close the output file
  3534.           BSR       FilClose
  3535.           MOVE.B    CtlXSeen(A6),D0    File interrupt ...
  3536.           OR.B      CtlZSeen(A6),D0    ... or file group interrupt ?
  3537.           BEQ.S     ClsOutF1           No, just keep it
  3538.           TST.B     Keep(A6)           Yes, keeping incomplete files ?
  3539.           BNE.S     ClsOutF1           Yes
  3540.           BSR       FilDelet           No, discard it
  3541.           MOVEQ     #FlDiscrd,D0       Give discard message
  3542.           BSR       Screen
  3543.           BRA.S     ClsOutF2           Nullify file name and return
  3544. ClsOutF1  MOVEQ     #FlTranOk,D0       Give comforting messages
  3545.           BSR       Screen
  3546. ClsOutF2  CLR.B     (A0)               Nullify current file name
  3547.           RTS
  3548. ClsOutF3  SF        TermOut(A6)        Clear the terminal output flag
  3549.           RTS
  3550.  
  3551. ********************************* ChekInt *****************************ok
  3552. *                                                                     *
  3553. *  Terminal interrupts handler.                                       *
  3554. *                                                                     *
  3555. *         Entry conditions : none                                     *
  3556. *                                                                     *
  3557. *         Exit  conditions : D0.L destroyed                           *
  3558. *                            D1.L destroyed                           *
  3559. *                            A1.L destroyed                           *
  3560. *                                                                     *
  3561. ***********************************************************************
  3562. ChekInt:  TST.B     Local(A6)          Are we running in local mode ?
  3563.           BEQ.S     ChekInt1           No, return
  3564.           TST.B     Quiet(A6)          Quiet requested ?
  3565.           BNE.S     ChekInt1           Yes, return
  3566.           MOVEQ     #Terminal,D1       Try to get a character from terminal
  3567.           BSR       InpChar
  3568.           TST.B     D1                 Success ?
  3569.           BNE.S     ChekInt1           No, return
  3570.           CMPI.B    #Asc_Sub,D0        Control Z ?
  3571.           BEQ.S     ChekInt2           Yes
  3572.           CMPI.B    #Asc_Can,D0        Control X ?
  3573.           BEQ.S     ChekInt3           Yes, set the file interrupt flag
  3574.           CMPI.B    #Asc_DC2,D0        Control R ?
  3575.           BEQ.S     ChekInt4           Yes, resend the last packet
  3576.           MOVEQ     #Asc_Bel,D0        No, ignore, ring the bell
  3577.           BSR       ConOut
  3578. ChekInt1  RTS
  3579.  
  3580. ChekInt2  LEA       CnBchStr(PC),A1    Cancel batch
  3581.           MOVEQ     #TxtDlBeg,D0       Give message
  3582.           BSR       Screen
  3583.           ST        CtlZSeen(A6)       Set the file batch interrupt flag
  3584.           RTS
  3585.  
  3586. ChekInt3  LEA       CnFilStr(PC),A1    Cancel file
  3587.           MOVEQ     #TxtDlBeg,D0       Give message
  3588.           BSR       Screen
  3589.           ST        CtlXSeen(A6)       Set the file interrupt flag
  3590.           RTS
  3591.  
  3592. ChekInt4  LEA       ReSndStr(PC),A1    Resend packet
  3593.           MOVEQ     #TxtDlBeg,D0       Give message
  3594.           BSR       Screen
  3595.           BSR       Resend             Resend the last packet
  3596.           RTS
  3597.  
  3598. ********************************** Screen *****************************ok
  3599. *                                                                     *
  3600. *  Screen diplay routine.                                             *
  3601. *                                                                     *
  3602. *         Entry conditions : D0.B request code                        *
  3603. *                            D1.B packet type or pseudotype           *
  3604. *                            D2.B packet number                       *
  3605. *                            D3.B packet length                       *
  3606. *                            A1.L pointer to a string to write        *
  3607. *                                                                     *
  3608. *         Exit  conditions : none                                     *
  3609. *                                                                     *
  3610. ***********************************************************************
  3611. ScrnMxLL  EQU       78                 Maximum line length
  3612.  
  3613. Screen:   TST.B     Display(A6)        The display flag is off ?
  3614.           BEQ.S     Screen1            Yes, no update
  3615.           TST.B     Quiet(A6)          Are we requested to be quiet ?
  3616.           BEQ.S     Screen2            No, update the screen
  3617. Screen1   RTS
  3618.  
  3619. Screen2   MOVEM.L   A0-A1/D1-D7,-(A7)  Save some registers
  3620.           MOVE.B    LinLngth(A6),D6    Length of the current screen line
  3621.           CLR.W     D4                 Compute the length of the passed string
  3622. Screen3   TST.B     (A1,D4.W)          End of line ?
  3623.           BEQ.S     Screen4            Yes, continue
  3624.           ADDQ.B    #1,D4              No, count
  3625.           BRA.S     Screen3            Repeat until end of line
  3626.  
  3627. Screen4   MOVEQ     #ScrnMxRq,D5       Maximum request code
  3628.           CMP.W     D5,D0              Request code out of range ?
  3629.           BHI       Screen30           Yes, return
  3630.           ADD.W     D0,D0              No, scale it
  3631.           MOVE.W    Screen5(PC,D0.W),D0 Relative address of the service routine
  3632.           JMP       Screen5(PC,D0.W)   Jump to it
  3633.  
  3634. Screen5   DC.W      Screen6-Screen5    SFilName
  3635.           DC.W      Screen7-Screen5    RFilName
  3636.           DC.W      Screen9-Screen5    FlAsName
  3637.           DC.W      Screen11-Screen5   XPckData
  3638.           DC.W      Screen12-Screen5   FlTranOk
  3639.           DC.W      Screen14-Screen5   FlDiscrd
  3640.           DC.W      Screen16-Screen5   FlIntrrp
  3641.           DC.W      Screen18-Screen5   FlSkippd
  3642.           DC.W      Screen19-Screen5   PackType
  3643.           DC.W      Screen22-Screen5   TranCmpl
  3644.           DC.W      Screen23-Screen5   ErrMessg
  3645.           DC.W      Screen24-Screen5   WarnMess
  3646.           DC.W      Screen25-Screen5   UndelTxt
  3647.           DC.W      Screen27-Screen5   TxtDlBeg
  3648.           DC.W      Screen28-Screen5   TxtDlEnd
  3649.  
  3650. Screen6   LEA       ScrnStr1(PC),A0    Display outgoing file name
  3651.           BRA.S     Screen8
  3652.  
  3653. Screen7   LEA       ScrnStr2(PC),A0    Display inbound file name
  3654.  
  3655. Screen8   BSR       NewLine            Display file name
  3656.           BSR       ConWrite
  3657.           MOVE.B    #10,D6
  3658.           MOVEA.L   A1,A0
  3659.           BSR       ConWrite
  3660.           MOVEQ     #' ',D0
  3661.           BSR       ConOut
  3662.           ADD.B     D4,D6
  3663.           ADDQ.B    #1,D6
  3664.           BRA       Screen30
  3665.  
  3666. Screen9   MOVE.B    D4,D5              Display file as-name
  3667.           ADD.B     D6,D5
  3668.           CMPI.B    #ScrnMxLL-3,D5
  3669.           BLS.S     Screen10
  3670.           BSR       NewLine
  3671.           CLR.B     D6
  3672. Screen10  LEA       ScrnStr3(PC),A0
  3673.           BSR       ConWrite
  3674.           MOVEA.L   A1,A0
  3675.           BSR       ConWrite
  3676.           MOVEQ     #' ',D0
  3677.           BSR       ConOut
  3678.           ADD.B     D4,D6
  3679.           ADDQ.B    #3+1,D6
  3680.           CMPI.B    #ScrnMxLL,D6
  3681.           BLS       Screen30
  3682.           BSR       NewLine
  3683.           CLR.B     D6
  3684.           BRA       Screen30
  3685.  
  3686. Screen11  BSR       NewLine            Display X-packet data
  3687.           MOVEA.L   A1,A0
  3688.           BSR       ConWrite
  3689.           BSR       NewLine
  3690.           CLR.B     D6
  3691.           BRA       Screen30
  3692.  
  3693. Screen12  CMPI.B    #ScrnMxLL-5,D6     Successful file transfer message
  3694.           BLS.S     Screen13
  3695.           BSR       NewLine
  3696.           CLR.B     D6
  3697. Screen13  LEA       ScrnStr4(PC),A0
  3698.           BSR       ConWrite
  3699.           ADDQ.B    #5,D6
  3700.           BRA       Screen30
  3701.  
  3702. Screen14  CMPI.B    #ScrnMxLL-12,D6    File discarded message
  3703.           BLS.S     Screen15
  3704.           BSR       NewLine
  3705.           CLR.B     D6
  3706. Screen15  LEA       ScrnStr5(PC),A0
  3707.           BSR       ConWrite
  3708.           ADDI.B    #12,D6
  3709.           BRA       Screen30
  3710.  
  3711. Screen16  CMPI.B    #ScrnMxLL-14,D6    File transfer interrupted message
  3712.           BLS.S     Screen17
  3713.           BSR       NewLine
  3714.           CLR.B     D6
  3715. Screen17  LEA       ScrnStr6(PC),A0
  3716.           BSR       ConWrite
  3717.           ADDI.B    #14,D6
  3718.           BRA       Screen30
  3719.  
  3720. Screen18  BSR       NewLine            File skipped message
  3721.           LEA       ScrnStr7(PC),A0
  3722.           BSR       ConWrite
  3723.           MOVEA.L   A1,A0
  3724.           BSR       ConWrite
  3725.           BSR       NewLine
  3726.           CLR.B     D6
  3727.           BRA       Screen30
  3728.  
  3729. *                                      Display packet type or pseudo-type
  3730. Screen19  CMPI.B    #'Y',D1            ACK packet ?
  3731.           BEQ       Screen30           Yes, return
  3732.           CMPI.B    #'D',D1            Data packet ?
  3733.           BNE.S     Screen20           No
  3734.           ANDI.B    #3,D2              Yes, only display every 4 packets
  3735.           BNE       Screen30           Return
  3736.           MOVEQ     #'.',D0
  3737.           BRA.S     Screen21
  3738. Screen20  MOVE.B    D1,D0              Display the packet type
  3739. Screen21  BSR       ConOut
  3740.           ADDQ.B    #1,D6              Increment current line length
  3741.           CMPI.B    #ScrnMxLL,D6       Near the right margin ?
  3742.           BLS.S     Screen30           No, return
  3743.           BSR       NewLine            Yes, start a new line
  3744.           CLR.B     D6                 Reset the counter
  3745.           BRA.S     Screen30
  3746.  
  3747. Screen22  MOVEQ     #Asc_Bel,D0        Transaction complete message (bell)
  3748.           BSR       ConOut
  3749.           BSR       NewLine            Start a new line
  3750.           BRA.S     Screen30
  3751.  
  3752. Screen23  BSR       NewLine            Error message
  3753.           MOVEQ     #'?',D0
  3754.           BSR       ConOut
  3755.           MOVEA.L   A1,A0
  3756.           BSR       ConWrite
  3757.           BSR       NewLine
  3758.           CLR.B     D6
  3759.           BRA.S     Screen30
  3760.  
  3761. Screen24  BSR       NewLine            Warning message
  3762.           MOVEA.L   A1,A0
  3763.           BSR       ConWrite
  3764.           BSR       NewLine
  3765.           CLR.B     D6
  3766.           BRA.S     Screen30
  3767.  
  3768. Screen25  ADD.B     D4,D6              Undelimited text
  3769.           CMPI.B    #ScrnMxLL,D6
  3770.           BLS.S     Screen26
  3771.           BSR       NewLine
  3772.           MOVE.B    D4,D6
  3773. Screen26  MOVEA.L   A1,A0
  3774.           BSR       ConWrite
  3775.           BRA.S     Screen30
  3776.  
  3777. Screen27  BSR       NewLine            Text delimited at beginning
  3778.           MOVEA.L   A1,A0
  3779.           BSR       ConWrite
  3780.           MOVE.B    D4,D6
  3781.           BRA.S     Screen30
  3782.  
  3783. Screen28  ADD.B     D4,D6              Text delimited at end
  3784.           CMPI.B    #ScrnMxLL,D6
  3785.           BLS.S     Screen29
  3786.           BSR       NewLine
  3787.           MOVE.B    D4,D6
  3788. Screen29  MOVEA.L   A1,A0
  3789.           BSR       ConWrite
  3790.           BSR       NewLine
  3791. *          BRA.S     Screen30
  3792.  
  3793. Screen30  MOVE.B    D6,LinLngth(A6)
  3794.           MOVEM.L   (A7)+,A0-A1/D1-D7
  3795.           RTS
  3796.  
  3797.           ends
  3798.           END
  3799. <<< k6omai.asm >>>
  3800.           nam       Kermit68K
  3801.           ttl       Main program module
  3802.  
  3803. *         Kermit68K: source file K68MAI
  3804.  
  3805. ********************************************************************************
  3806. ********************************************************************************
  3807. *  ****  *        *       ***   *****   *  *        ***      **      **  ****  *
  3808. *  ***  **  *******  ***   **    ***    *  ****  *****  ******  ****  *  ***  **
  3809. *  **  ***  *******  ****  **  *  *  *  *  ****  ****  *******  ****  *  **  ***
  3810. *  *  ****  *******  ***   **  **   **  *  ****  ****  *******  ****  *  *  ****
  3811. *    *****      ***       ***  *** ***  *  ****  ****       ***      **    *****
  3812. *  *  ****  *******  **  ****  *******  *  ****  ****  ****  *  ****  *  *  ****
  3813. *  **  ***  *******  ***  ***  *******  *  ****  ****  ****  *  ****  *  **  ***
  3814. *  ***  **  *******  ****  **  *******  *  ****  ****  ****  *  ****  *  ***  **
  3815. *  ****  *        *  *****  *  *******  *  ****  *****      ***      **  ****  *
  3816. ********************************************************************************
  3817. ********************************************************************************
  3818. *                                                                              *
  3819. *         Kermit implementation for the MC68000 microprocessors family         *
  3820. *                                                                              *
  3821. *                                                                              *
  3822. *   Author:        Roberto Bagnara, Physics Department, Bologna University     *
  3823. *                                                                              *
  3824. *   Started:       02 May       1986 by rb                                     *
  3825. *   Last modified: 01 July      1987 by rb                                     *
  3826. *                                                                              *
  3827. *   Modified by:   Steve Williams, University of Texas at Austin               *
  3828. *                                                                              *
  3829. *   Status :       INCOMPLETE                                                  *
  3830. *                                                                              *
  3831. *                                                                              *
  3832. *   Modification History:                                                      *
  3833. *                                                                              *
  3834. *   Version  Date    Who              Comments                                 *
  3835. *                                                                              *
  3836. *   1.0.00   870701  Roberto Bagnara  First official release                   *
  3837. *                                                                              *
  3838. ********************************************************************************
  3839.  
  3840.           use       DefsFile
  3841.  
  3842. TypeLang  equ       (Prgrm<<8)+Objct    Executable 68000 native code
  3843. AttrRev   equ       (ReEnt<<8)+0        Re-entrant code, revision 0
  3844. Edition   equ       0                   Edition number
  3845. Stack     equ       8192                Stack space needed
  3846.  
  3847.           psect     Kermit,TypeLang,AttrRev,Edition,Stack,Kerm68K
  3848.  
  3849.  
  3850. ********************************* Kerm68K *****************************ok
  3851. *                                                                     *
  3852. *  Kermit68K main program.                                            *
  3853. *                                                                     *
  3854. *         Entry conditions : none                                     *
  3855. *                                                                     *
  3856. *         Exit  conditions : none                                     *
  3857. *                                                                     *
  3858. ***********************************************************************
  3859. Kerm68K:  LEA       VarArea(A6),A6     Correct the $8000 bias of OS-9
  3860.           BSR       InitAll            Initialize all Kermit68K variables
  3861.           BSR       SysInit            Initialize any system dependent thing
  3862.           BSR       CmdLnP             Parse the command line, if possible
  3863.           LEA       InitFile(PC),A0    Point to the init file name
  3864.           MOVEQ     #ReadOp,D0         We want to read it
  3865.           MOVEQ     #TakeFil0,D1       This is the channel number
  3866.           BSR       FilOpen            Try to open the init file
  3867.           TST.B     D0                 Success ?
  3868.           BEQ.S     Kerm68K1           No, no message, parse user commands
  3869.           CLR.B     TakLevel(A6)       Yes, we are interpreting the take file 0
  3870. Kerm68K1  BSR       Parser             Parse interactive commands until done
  3871.           ST        D0                 Finally return a positive cc ...
  3872.           BRA       SysExod            ... and the control to system
  3873.  
  3874. ******************************** InitAll ******************************ok
  3875. *                                                                     *
  3876. *  Startup initialization routine.                                    *
  3877. *                                                                     *
  3878. *         Entry conditions : none                                     *
  3879. *                                                                     *
  3880. *         Exit  conditions : D0.L destroyed                           *
  3881. *                                                                     *
  3882. ***********************************************************************
  3883. InitAll   MOVE.B    #MyEOL,IEOL(A6)        Set EOL for incoming packets
  3884.           MOVE.B    #DefEOL,OEOL(A6)       Set EOL for outgoing packets
  3885.           MOVE.B    #DefCtlQt,ICtlQuot(A6) Set incoming packets control quote
  3886.           MOVE.B    #MyCtlQot,OCtlQuot(A6) Set outgoing packets control quote
  3887.           MOVE.B    #MyPad,IPadNumb(A6)    Set how much padding to ask for
  3888.           MOVE.B    #DefPadNm,OPadNumb(A6) Set how much padding to send
  3889.           MOVE.B    #MyPadChr,IPadChar(A6) Set padding character to ask for
  3890.           MOVE.B    #DefPadCr,OPadChar(A6) Set padding character to send
  3891.           MOVEQ     #Asc_SOH,D0            Default packet start character
  3892.           MOVE.B    D0,IStPckCh(A6)        Set incoming packet start char
  3893.           MOVE.B    D0,OStPckCh(A6)        Set outgoing packet start char
  3894.           MOVE.B    #DefTmOut,ITimInt(A6)  Set when I should time out
  3895.           MOVE.B    #MyTimOut,OTimInt(A6)  Set when I want to be timed out
  3896.           MOVE.B    #MyMxPSiz,IMPckSiz(A6) Set max packet size I want receive
  3897.           MOVE.B    #DefMxPSz,OMPckSiz(A6) Set max packet size I can send
  3898.           MOVE.B    #MyRptQot,ReptQuot(A6) Set the default repeat prefix
  3899.           MOVE.B    #My8BQuot,Bit8Quot(A6) Set the default 8th bit prefix
  3900.           MOVE.B    #1,BlChkRq(A6)         Set the default block check type
  3901.           MOVE.B    #DefDuplx,Duplex(A6)   Set default duplex
  3902.           MOVE.B    #DefFlow,Flow(A6)      Set default flow control
  3903.           MOVE.B    #DefPrity,Parity(A6)   Set default parity
  3904.           MOVE.B    #DefEscap,Escape(A6)   Set default escape character
  3905.           MOVE.B    #DefDelay,Delay(A6)    Set default delay before sending
  3906.           MOVE.B    #DefRetIn,RtryInit(A6) Set default retry init limit
  3907.           MOVE.B    #DefRetPk,RtryPack(A6) Set default retry normal limit
  3908.  
  3909.           LEA       MacroTbl(A6),A0
  3910.           MOVE.L    A0,MTNxtChF(A6)
  3911.  
  3912.           CLR.B     LinLngth(A6)       For the dumb terminal Screen routine
  3913.  
  3914.           SF        ReptFlag(A6)       No repeat processing by default
  3915.           SF        TimInFlg(A6)       No timeout overriding
  3916.           SF        SndPSFlg(A6)       No packet size overriding
  3917.           SF        Binary(A6)         File type is text
  3918.           SF        Quiet(A6)          File display is on
  3919.           SF        FNameCnv(A6)       File names conversion is off
  3920.           SF        Warning(A6)        File warning is off
  3921.           SF        Keep(A6)           Don't keep incomplete files
  3922.  
  3923.           SF        IntMacro(A6)
  3924.  
  3925.           CLR.L     ChrsSent(A6)       Clear the statistic variables
  3926.           CLR.L     TChsSent(A6)
  3927.           CLR.L     ChrsRecd(A6)
  3928.           CLR.L     TChsRecd(A6)
  3929.           CLR.L     DChsSent(A6)
  3930.           CLR.L     TDChSent(A6)
  3931.           CLR.L     DChsRecd(A6)
  3932.           CLR.L     TDChRecd(A6)
  3933.           CLR.L     PcksSent(A6)
  3934.           CLR.L     TPckSent(A6)
  3935.           CLR.L     PcksRecd(A6)
  3936.           CLR.L     TPckRecd(A6)
  3937.           CLR.L     NAKsSent(A6)
  3938.           CLR.L     TNAKSent(A6)
  3939.           CLR.L     NAKsRecd(A6)
  3940.           CLR.L     TNAKRecd(A6)
  3941.  
  3942.           MOVE.B    #DefLocal,Local(A6) Setup the initial mode
  3943.           MOVE.L    #DefSpeed,Speed(A6) Setup the default line speed
  3944.  
  3945.           LEA       DefLinNm(PC),A1    Setup the default line, if any
  3946.           LEA       LineName(A6),A0    This is the line name string
  3947.           MOVEQ     #LinNamML,D0       Maximum line name length
  3948.           BSR       CopyStr            Copy now
  3949.           TST.B     (A0)               The default line name was null ?
  3950.           BEQ.S     InitAll2           Yes, we hope that somebody does this job
  3951.  
  3952.           MOVEQ     #RdWrOp,D0         No, try to open it
  3953.           MOVEQ     #HostLine,D1       This is the channel number
  3954.           BSR       FilOpen            Open, if possible
  3955.           TST.B     D0                 Ok ?
  3956.           BNE.S     InitAll1           Yes
  3957.           CLR.B     (A0)               No, nullify the line name
  3958.           BEQ.S     InitAll2           Proceed initialization, no error messages
  3959.  
  3960. InitAll1  LEA       ConLinNm(PC),A1    Yes, point to the console line name
  3961.           BSR       CompStr            Compare the two line names
  3962.           TST.B     D0                 Are equal ?
  3963.           SEQ       Local(A6)          If not we are local, remote otherwise
  3964.           BEQ.S     InitAll2           If local, leave speed unchanged
  3965.           MOVE.L    #-1,Speed(A6)      If remote, say speed unknown
  3966.  
  3967. InitAll2  MOVE.B    #-1,TakLevel(A6)   No files to take yet
  3968.           SF        TermOut(A6)        No terminal output, by now
  3969.           SF        Done(A6)           Set to false the parser exit flag
  3970.           CLR.B     Argumnt1(A6)       Nullify the first command argument
  3971.           CLR.B     Argumnt2(A6)       Nullify the second command argument
  3972.           CLR.B     FilName(A6)        Nullify current file name
  3973.           CLR.B     LinLngth(A6)       *** To be removed -rb- ***
  3974.  
  3975.           LEA       DefPrmpt(PC),A1    Set up the default prompt
  3976.           LEA       Prompt(A6),A0      This is the prompt string
  3977.           MOVEQ     #PromptML,D0       Maximum prompt length
  3978.           BSR       CopyStr            Copy now
  3979.           RTS
  3980.  
  3981.           ends
  3982.  
  3983.           END       Kerm68K
  3984. <<< k6opro.asm >>>
  3985.           nam       Kermit68K
  3986.           ttl       Protocol automaton subroutines module
  3987.  
  3988. *         Kermit68K: source file K68PRO
  3989. *
  3990. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  3991. * Bologna University, Physics Department, July 1987.
  3992. *
  3993. * All rights reserved to Bologna University, Italy.
  3994. *
  3995. * Permission is granted to any individual or institution
  3996. * to use, copy, or redistribute this software so long as
  3997. * it  is not  sold for  profit, provided  this copyright
  3998. * notice is retained.
  3999. *
  4000. * Modification History:
  4001. *
  4002. * Version  Date    Who              Comments
  4003. *
  4004. * 1.0.00   870701  Roberto Bagnara  First official release
  4005.  
  4006.           use       DefsFile
  4007.  
  4008. Edition   equ       0
  4009.           psect     K68Protocol,0,0,Edition,0,0
  4010.  
  4011. ******************************** KPSwtch ******************************ok
  4012. *                                                                     *
  4013. *  Kermit protocol state table switcher. It loops until either it     *
  4014. *  finishes, or an error is encountered. D7.W contains the present    *
  4015. *  state of the automaton. The routines called by KPSwtch are         *
  4016. *  responsible for changing the state.                                *
  4017. *                                                                     *
  4018. *         Entry conditions : D7.W initial state of the automaton      *
  4019. *                                                                     *
  4020. *         Exit  conditions : D0.B completion code                     *
  4021. *                                                                     *
  4022. ***********************************************************************
  4023. KPSwtch:  TST.B     Local(A6)          Are we running in local mode ?
  4024.           BEQ.S     KPSwtch1           No, no mind about speed
  4025.           TST.L     Speed(A6)          Is line speed setted ?
  4026.           BLT.S     KPSwtch3           No, give error and return
  4027. KPSwtch1  MOVEQ     #RawMode,D0        Put line in raw mode
  4028.           MOVEQ     #HostLine,D1
  4029.           BSR       ChanCtrl
  4030.           CMPI.B    #AllOk,D0          All ok ?
  4031.           BEQ.S     KPSwtch5           Yes, enter the protocol switcher
  4032. KPSwtch2  LEA       CCndLStr(PC),A1    No, point to the error message
  4033.           BRA.S     KPSwtch4           Display this on the screen
  4034. KPSwtch3  LEA       StSpeStr(PC),A1    Point to the 'set speed' error message
  4035. KPSwtch4  MOVEQ     #ErrMessg,D0       Error message display request code
  4036.           BSR       Screen             Display on the screen
  4037.           RTS
  4038.  
  4039. KPSwtch5  PEA       KPSwtch5(PC)       Provide return address
  4040.           MOVE.W    D7,D0              Load the present state of the automaton
  4041.           ADD.W     D0,D0              Scale it
  4042.           MOVE.W    KPSwtch6(PC,D0.W),D0 Load index
  4043.           JMP       KPSwtch6(PC,D0.W)  Jump to the appropriate address
  4044.  
  4045. KPSwtch6  DC.W      SndInit-KPSwtch6   Send-Init
  4046.           DC.W      OpnFile-KPSwtch6   Open-File
  4047.           DC.W      SndFile-KPSwtch6   Send-File
  4048.           DC.W      SndData-KPSwtch6   Send-Data
  4049.           DC.W      SendEOF-KPSwtch6   Send-End-Of-File
  4050.           DC.W      SendEOT-KPSwtch6   Send-Break
  4051.           DC.W      RecInit-KPSwtch6   Receive-Init
  4052.           DC.W      RecFile-KPSwtch6   Receive-File
  4053.           DC.W      RecData-KPSwtch6   Receive-Data
  4054.           DC.W      SndSrvI-KPSwtch6   Send-Server-Init
  4055.           DC.W      SndGCmd-KPSwtch6   Send-Generic-Command
  4056.           DC.W      Complete-KPSwtch6  Complete
  4057.           DC.W      Abort-KPSwtch6     Abort
  4058.  
  4059. ******************************** SndSrvI ******************************ok
  4060. *                                                                     *
  4061. *  Send Server Init, send this host's parameters and get other side's *
  4062. *  back, then enter Send Generic Command state.                       *
  4063. *                                                                     *
  4064. *         Entry conditions : none                                     *
  4065. *                                                                     *
  4066. *         Exit  conditions : D0.L destroyed                           *
  4067. *                            D1.L destroyed                           *
  4068. *                            D2.L destroyed                           *
  4069. *                            D3.B destroyed                           *
  4070. *                            D7.L next state of the automaton         *
  4071. *                                                                     *
  4072. ***********************************************************************
  4073. SndSrvI   MOVEQ     #ClrInpBf,D0       Clear the input buffer
  4074.           MOVEQ     #HostLine,D1       Host line channel, of course
  4075.           BSR       ChanCtrl           Call the channel control routine
  4076.           BSR       SndParm            Fill up the init info packet
  4077.           MOVEQ     #'I',D1            Send an I packet
  4078.           MOVEQ     #0,D2              Packet number (always 0)
  4079.           MOVE.B    D0,D3              Packet length as returned by SndParm
  4080.           BSR       SndPack            Ok, send now
  4081.  
  4082.           BSR       InpPack            What was the reply ?
  4083.           CMPI.B    #'Y',D1            ACK ?
  4084.           BEQ.S     SndSrvI4           Yes
  4085.           CMPI.B    #'E',D1            Error packet ?
  4086.           BNE       BadPack            No, bad packet
  4087.           CLR.B     DataBuf(A6)        Yes, ignore it, clear data buffer
  4088. *                                      Fall thru, use default parameters
  4089. SndSrvI4  BSR       RdParam            Get other side's init info
  4090.           MOVE.B    BlChkRq(A6),BlChkUs(A6) Setup block check type
  4091.           MOVEQ     #SndGCmdS,D7       OK, switch state to Send-Generic-Command
  4092.           RTS
  4093.  
  4094. ******************************** SndGCmd ******************************ok
  4095. *                                                                     *
  4096. *  Send Generic Command.                                              *
  4097. *                                                                     *
  4098. *         Entry conditions : none                                     *
  4099. *                                                                     *
  4100. *         Exit  conditions : D0.L destroyed                           *
  4101. *                            D1.L destroyed                           *
  4102. *                            D2.L destroyed                           *
  4103. *                            D3.B destroyed                           *
  4104. *                            D7.L next state of the automaton         *
  4105. *                            A0.L destroyed                           *
  4106. *                                                                     *
  4107. ***********************************************************************
  4108. SndGCmd   LEA       CmdBuf(A6),A0      Point to command buffer
  4109.           BSR       EncStrng           Fill up the data buffer
  4110.           MOVE.B    ServrCmd(A6),D1    Send a packet of the appropriate type
  4111.           MOVEQ     #0,D2              Packet number (always 0)
  4112.           MOVE.B    Size(A6),D3        Packet size
  4113.           BSR       SndPack            Ok, send now
  4114.           BSR       InpPack            What was the reply ?
  4115.  
  4116.           CMPI.B    #'Y',D1            ACK ?
  4117.           BEQ.S     SndGCmd2           Yes
  4118.           CMPI.B    #'S',D1            Send-Init packet ?
  4119.           BEQ.S     SndGCmd3           Yes
  4120.           CMPI.B    #'X',D1            X packet ?
  4121.           BNE       BadPack            No, unknown packet type, abort
  4122.           ST        TermOut(A6)        Yes, set the terminal output flag
  4123.           BSR       SendACK            Acknowledge
  4124.           MOVEQ     #RecDataS,D7       Enter Receive-Data state
  4125.           RTS
  4126.  
  4127. SndGCmd2  LEA       ConOut(PC),A0      ACK received
  4128.           BSR       Decode             Decode packet and output it
  4129.           BSR       NewLine            Start a new line on the screen
  4130.           MOVEQ     #CompletS,D7       Ok, enter complete state
  4131.           RTS
  4132.  
  4133. SndGCmd3  BSR       RdParam            Get the other side's init data
  4134.           BSR       SndParm            Fill up packet with my init info
  4135.           MOVEQ     #'Y',D1            ACK my parameters
  4136.           MOVEQ     #0,D2              Packet number (0)
  4137.           MOVE.B    D0,D3              Packet length as returned by SndParm
  4138.           BSR       SndPack            OK, send now
  4139.           BSR       BumpPckN           Bump packet number, modulo 64
  4140.           MOVE.B    BlChkRq(A6),BlChkUs(A6) Setup block check type
  4141.           MOVEQ     #RecFileS,D7       Enter Receive-File state
  4142.           RTS
  4143.  
  4144. ******************************** Complete *****************************ok
  4145. *                                                                     *
  4146. *  Successful end of transaction.                                     *
  4147. *                                                                     *
  4148. *         Entry conditions : none                                     *
  4149. *                                                                     *
  4150. *         Exit  conditions : D0.B positive completion code            *
  4151. *                                                                     *
  4152. ***********************************************************************
  4153. Complete  ADDQ.L    #4,A7              Drop return address
  4154.           MOVEQ     #TranCmpl,D0       Say transaction complete
  4155.           BSR       Screen
  4156.           ST        D0                 Return a positive completion code
  4157.           RTS
  4158.  
  4159. ********************************* Abort *******************************ok
  4160. *                                                                     *
  4161. *  Unsuccessful end of transaction.                                   *
  4162. *                                                                     *
  4163. *         Entry conditions : none                                     *
  4164. *                                                                     *
  4165. *         Exit  conditions : D0.B negative completion code            *
  4166. *                            D4.B destroyed                           *
  4167. *                            A0.L destroyed                           *
  4168. *                                                                     *
  4169. ***********************************************************************
  4170. Abort     ADDQ.L    #4,A7              Drop return address
  4171.  
  4172.           CMPI.B    #'E',D1            Error packet received ?
  4173.           BNE.S     Abort1             No, too many tries or invalid type
  4174.  
  4175.           BSR       NewLine
  4176.           LEA       ErFRHStr(PC),A0    Yes, point to error string
  4177.           BSR       ConWrite           Write it to terminal
  4178.           LEA       DataBuf(A6),A0     Point to error packet contents
  4179.           BSR       ConWrite           Write it to terminal
  4180.           MOVE.B    Quiet(A6),D4       Save the quiet flag
  4181.           ST        Quiet(A6)          Set the quiet flag on
  4182.           BSR       ClsInpF            Close the input file silently
  4183.           ST        CtlZSeen(A6)       Force discarding of the ouput file
  4184.           BSR       ClsOutF            Close the output file silently
  4185.           MOVE.B    D4,Quiet(A6)       Restore the quiet flag
  4186.           BRA.S     Abort7
  4187.  
  4188. Abort1    CMPI.B    #'N',D1            NAK packet ?
  4189.           BEQ.S     Abort2             Yes
  4190.           CMPI.B    #'T',D1            Timeout pseudo-packet ?
  4191.           BEQ.S     Abort3             Yes
  4192.           CMPI.B    #'Q',D1            Garbage pseudo-packet ?
  4193.           BEQ.S     Abort4             Yes
  4194.           CMP.B     PackNum(A6),D2     Packet out of sequence ?
  4195.           BNE.S     Abort5             Yes
  4196.           BSR       NewLine
  4197.           LEA       UkUxPStr(PC),A0    No, unknown or unexpected packet type
  4198.           BSR       ConWrite
  4199.           BRA.S     Abort7
  4200.  
  4201. Abort2    PEA       NAKRcStr(PC)       NAK received string
  4202.           BRA.S     Abort6
  4203. Abort3    PEA       TimLEStr(PC)       Timeout limit expired string
  4204.           BRA.S     Abort6
  4205. Abort4    PEA       GbPRcStr(PC)       Garbage packet received string
  4206.           BRA.S     Abort6
  4207. Abort5    PEA       POuOSStr(PC)       Packet out of sequence string
  4208. Abort6    BSR       NewLine
  4209.           LEA       TooMTStr(PC),A0    Point to the abort string
  4210.           BSR       ConWrite           Write it to the terminal line
  4211.           MOVEA.L   (A7)+,A0           Now write the last error string
  4212.           BSR       ConWrite
  4213. Abort7    BSR       NewLine            Start a new line
  4214.           SF        D0                 Return a negative completion code
  4215.           RTS
  4216.  
  4217. BadPack   MOVEQ     #AbortS,D7         This is for code reduction
  4218.           RTS
  4219.  
  4220. ********************************* SndInit *****************************ok
  4221. *                                                                     *
  4222. *  Send Initiate, send this host's parameters and get other side's    *
  4223. *  back.                                                              *
  4224. *                                                                     *
  4225. *         Entry conditions : none                                     *
  4226. *                                                                     *
  4227. *         Exit  conditions : D0.L destroyed                           *
  4228. *                            D1.L destroyed                           *
  4229. *                            D2.L destroyed                           *
  4230. *                            D3.B destroyed                           *
  4231. *                            D7.L next state of the automaton         *
  4232. *                            A0.L destroyed                           *
  4233. *                            A1.L destroyed                           *
  4234. *                                                                     *
  4235. ***********************************************************************
  4236. SndInit   LEA       Argumnt1(A6),A0    Pointer to file name
  4237.           BSR       ExpandFN           Expand it into a file names list
  4238.           TST.L     D0                 Check the returned number
  4239.           BLT.S     SndInit4           Too many files match
  4240.           BNE.S     SndInit1           Some files match, get the first one
  4241.           BSR       CRemTLoc           No files match, convert name to local
  4242.           BSR       ExpandFN           Try again the file name expansion
  4243.           TST.L     D0                 Check the returned number
  4244.           BLE.S     SndInit3           If no or too many files match, error
  4245.  
  4246. SndInit1  BSR       NextFil            Get the first file name into FilName
  4247.           TST.B     D0                 Check completion code
  4248.           BEQ.S     SndInit5           Failed, exit protocol (don't enter it)
  4249.  
  4250.           MOVEQ     #ClrInpBf,D0       Clear the input buffer
  4251.           MOVEQ     #HostLine,D1
  4252.           BSR       ChanCtrl           Call the channel control routine
  4253.           TST.B     Local(A6)          Are we running in local mode ?
  4254.           BNE.S     SndInit2           Yes, no need for delay
  4255.           MOVE.B    Delay(A6),D0       Load initial delay before sending
  4256.           BSR       Sleep              Sleep the requested amount of time
  4257. SndInit2  BSR       SndParm            Fill up init info packet
  4258.           MOVEQ     #'S',D1            Send an S packet
  4259.           MOVEQ     #0,D2              Packet number (always 0)
  4260.           MOVE.B    D0,D3              Packet length as returned by SndParm
  4261.           BSR       SndPack            Ok, send now
  4262.  
  4263.           BSR       InpPack            What was the reply ?
  4264.           CMPI.B    #'Y',D1            ACK ?
  4265.           BNE       BadPack            No, bad packet
  4266.           BSR       RdParam            Yes, get other side's init info
  4267.           BSR       BumpPckN           Bump packet count
  4268.           MOVE.B    BlChkRq(A6),BlChkUs(A6) Setup block check type
  4269.           MOVE.B    RtryPack(A6),Retry(A6) Setup retry limit for normal packets
  4270.           MOVEQ     #OpnFileS,D7       OK, switch state to Open-File
  4271.           RTS
  4272.  
  4273. SndInit3  LEA       FNFStr(PC),A1      Point to file not found error message
  4274.           BRA.S     SndInit6           Join common part
  4275. SndInit4  LEA       TMFStr(PC),A1      Point to too many files error message
  4276.           BRA.S     SndInit6           Join common part
  4277. SndInit5  LEA       NRFStr(PC),A1      Point to no readable files error message
  4278. SndInit6  MOVEQ     #ErrMessg,D0       Give bad news
  4279.           BSR       Screen
  4280.           MOVEQ     #CompletS,D7       Enter complete state
  4281.           RTS
  4282.  
  4283. ********************************* OpnFile *****************************ok
  4284. *                                                                     *
  4285. *  Open File or set up text to send.                                  *
  4286. *                                                                     *
  4287. *         Entry conditions : none                                     *
  4288. *                                                                     *
  4289. *         Exit  conditions : D0.L destroyed                           *
  4290. *                            D7.L next state of the automaton         *
  4291. *                            A0.L destroyed                           *
  4292. *                            A1.L destroyed                           *
  4293. *                                                                     *
  4294. ***********************************************************************
  4295. OpnFile   LEA       FilName(A6),A0     Point to file name
  4296.           BSR       OpnInpF            Try to open the file
  4297.           TST.B     D0                 Success ?
  4298.           BEQ.S     OpnFile1           No
  4299.           MOVEQ     #SndFileS,D7       Yes switch state to Send-File
  4300.           RTS
  4301.  
  4302. OpnFile1  LEA       FlOErStr(PC),A1    Point to open failed error message
  4303.           MOVEQ     #ErrMessg,D0       Give bad news
  4304.           BSR       Screen             Screen return the pointer unchanged
  4305.           BSR       SndEPack           Send an Error packet
  4306.           MOVEQ     #AbortS,D7         Abort
  4307.           RTS
  4308.  
  4309. ******************************** SndFile ******************************ok
  4310. *                                                                     *
  4311. *  Send File Header.                                                  *
  4312. *                                                                     *
  4313. *         Entry conditions : none                                     *
  4314. *                                                                     *
  4315. *         Exit  conditions : D0.L destroyed                           *
  4316. *                            D1.L destroyed                           *
  4317. *                            D2.B destroyed                           *
  4318. *                            D3.B destroyed                           *
  4319. *                            D7.L next state of the automaton         *
  4320. *                            A0.L destroyed                           *
  4321. *                            A1.L destroyed                           *
  4322. *                                                                     *
  4323. ***********************************************************************
  4324. SndFile   LEA       FilName(A6),A1     Point to the local file name
  4325.           MOVEQ     #SFilName,D0       Display it on the screen
  4326.           BSR       Screen
  4327.           LEA       Argumnt2(A6),A0    Point to the file send-as name
  4328.           TST.B     (A0)               Has it been specified ?
  4329.           BNE.S     SndFile1           Yes, send it in the packet data field
  4330.           LEA       FilName(A6),A1     No, same as local file name
  4331.           MOVEQ     #CmdBufLn,D0       Copy it to Argumnt2
  4332.           BSR       CopyStr
  4333.           TST.B     FNameCnv(A6)       Are we converting file names ?
  4334.           BEQ.S     SndFile1           No
  4335.           BSR       CLocTRem           Yes, so convert file name in Argumnt2
  4336.  
  4337. SndFile1  MOVEA.L   A0,A1              Display the file send-as name
  4338.           MOVEQ     #FlAsName,D0
  4339.           BSR       Screen
  4340.           BSR       EncStrng           Encode the file name into the data field
  4341.           CLR.B     (A0)               Finally nullify Argumnt2
  4342.  
  4343.           MOVEQ     #'F',D1            Send a F packet
  4344.           MOVE.B    PackNum(A6),D2     Packet number
  4345.           MOVE.B    Size(A6),D3        Packet length
  4346.           BSR       SndPack            Ok, send now
  4347.  
  4348.           BSR       InpPack            What was the reply ?
  4349.           CMPI.B    #'Y',D1            ACK ?
  4350.           BNE       BadPack            No, bad packet
  4351.           BSR       BumpPckN           Bump packet counters
  4352.           MOVE.B    #1,First(A6)       Init file character lookahead
  4353.           BSR       GetPack            Get the first buffer of data
  4354.           TST.B     D0                 Null file ?
  4355.           BNE.S     SndFile4           No, enter Send-Data state
  4356.           MOVEQ     #SendEOFS,D7       Enter Send-EOF state
  4357.           RTS
  4358. SndFile4  MOVEQ     #SndDataS,D7       Switch state to Send-Data
  4359.           RTS
  4360.  
  4361. ******************************** SndData ******************************ok
  4362. *                                                                     *
  4363. *  Send File Data.                                                    *
  4364. *                                                                     *
  4365. *         Entry conditions : none                                     *
  4366. *                                                                     *
  4367. *         Exit  conditions : D0.B destroyed                           *
  4368. *                            D1.L destroyed                           *
  4369. *                            D2.B destroyed                           *
  4370. *                            D3.B destroyed                           *
  4371. *                            D7.L next state of the automaton         *
  4372. *                                                                     *
  4373. ***********************************************************************
  4374. SndData   MOVE.B    CtlXSeen(A6),D0    Current file or file group cancelled ?
  4375.           OR.B      CtlZSeen(A6),D0
  4376.           BNE.S     SndData4           Yes
  4377.           MOVEQ     #'D',D1            No, send a D packet
  4378.           MOVE.B    PackNum(A6),D2     Packet number
  4379.           MOVE.B    Size(A6),D3        Packet length
  4380.           BSR       SndPack            Ok, send now
  4381.           BSR       InpPack            What was the reply ?
  4382.  
  4383. SndData2  CMPI.B    #'Y',D1            ACK ?
  4384.           BNE       BadPack            No, bad packet
  4385.           BSR       BumpPckN           Bump packet count
  4386.           TST.B     D3                 Empty ACK packet ?
  4387.           BEQ.S     SndData5           Yes, get next data buffer
  4388.           MOVE.B    DataBuf(A6),D0     No, get first character of data buffer
  4389.           CMPI.B    #'X',D0            File interrupt directive ?
  4390.           SEQ       CtlXSeen(A6)       Yes, set the appropriate flag
  4391.           BEQ.S     SndData4           And enter, Send-EOF state
  4392.           CMPI.B    #'Z',D0            File group interrupt directive ?
  4393.           SEQ       CtlZSeen(A6)       Yes, set the appropriate flag
  4394.           BNE.S     SndData5           No, ignore ACK contents
  4395. SndData4  MOVEQ     #SendEOFS,D7       Enter Send-EOF state
  4396.           RTS
  4397. SndData5  BSR       GetPack            Get next data buffer
  4398.           TST.B     D0                 EOF or end of memory string ?
  4399.           BEQ.S     SndData4           Yes, switch state to Send-EOF
  4400.           RTS                          No, remain in this state
  4401.  
  4402. ******************************** SendEOF ******************************ok
  4403. *                                                                     *
  4404. *  Send End-Of-File.                                                  *
  4405. *                                                                     *
  4406. *         Entry conditions : none                                     *
  4407. *                                                                     *
  4408. *         Exit  conditions : D0.B destroyed                           *
  4409. *                            D1.L destroyed                           *
  4410. *                            D2.B destroyed                           *
  4411. *                            D3.L destroyed                           *
  4412. *                            D7.L next state of the automaton         *
  4413. *                                                                     *
  4414. ***********************************************************************
  4415. SendEOF   BSR       ClsInpF            Close the input file
  4416.           MOVEQ     #'Z',D1            Send a Z packet
  4417.           MOVE.B    PackNum(A6),D2     Packet number
  4418.           MOVE.B    CtlXSeen(A6),D0    Current file or file group cancelled ?
  4419.           OR.B      CtlZSeen(A6),D0
  4420.           BEQ.S     SendEOF1           No
  4421.           MOVE.B    #'D',DataBuf(A6)   Yes, put discard directive in data space
  4422.           MOVEQ     #1,D3              Packet length (1, Z/D packet)
  4423.           BRA.S     SendEOF2
  4424. SendEOF1  MOVEQ     #0,D3              Packet length (0, empty Z packet)
  4425. SendEOF2  BSR       SndPack            OK, send now
  4426.  
  4427.           BSR       InpPack            What was the reply ?
  4428.           CMPI.B    #'Y',D1            ACK ?
  4429.           BNE       BadPack            No, bad packet
  4430.           BSR       BumpPckN           Bump packet counters
  4431.  
  4432.           BSR       NextFil            Look for another file
  4433.           TST.B     D0                 Is there ?
  4434.           BEQ.S     SendEOF3           No, end of transaction
  4435.           MOVEQ     #OpnFileS,D7       Yes, send it
  4436.           RTS
  4437. SendEOF3  MOVEQ     #SendEOTS,D7       Enter Send-EOT state
  4438.           RTS
  4439.  
  4440. ******************************** SendEOT ******************************ok
  4441. *                                                                     *
  4442. *  Send Break (EOT).                                                  *
  4443. *                                                                     *
  4444. *         Entry conditions : none                                     *
  4445. *                                                                     *
  4446. *         Exit  conditions : D1.L destroyed                           *
  4447. *                            D2.B destroyed                           *
  4448. *                            D3.L destroyed                           *
  4449. *                            D7.L next state of the automaton         *
  4450. *                                                                     *
  4451. ***********************************************************************
  4452. SendEOT   MOVEQ     #'B',D1            Send a B packet
  4453.           MOVE.B    PackNum(A6),D2     Packet number
  4454.           MOVEQ     #0,D3              Packet length
  4455.           BSR       SndPack            Ok, send now
  4456.           CLR.B     NextPckN(A6)       If the expected ACK lost, the next
  4457. *                                      packet from the receiver will be NAK(0)
  4458.           BSR       InpPack            What was the reply ?
  4459.           CMPI.B    #'Y',D1            ACK ?
  4460.           BNE       BadPack            No, bad packet
  4461.           MOVEQ     #CompletS,D7       Yes, enter Complete state
  4462.           RTS
  4463.  
  4464. ********************************* RecInit *****************************ok
  4465. *                                                                     *
  4466. *  Receive Initialization.                                            *
  4467. *                                                                     *
  4468. *         Entry conditions : none                                     *
  4469. *                                                                     *
  4470. *         Exit  conditions : D1.L destroyed                           *
  4471. *                            D2.L destroyed                           *
  4472. *                            D3.B destroyed                           *
  4473. *                            D7.L next state of the automaton         *
  4474. *                                                                     *
  4475. ***********************************************************************
  4476. RecInit   BSR       InpPack            Try to get a packet
  4477.           CMPI.B    #'S',D1            Send-Init packet received ?
  4478.           BNE       BadPack            No, bad packet
  4479.           BSR       RdParam            Get the other side's init data
  4480.           BSR       SndParm            Fill up packet with my init info
  4481.           MOVEQ     #'Y',D1            ACK my parameters
  4482.           MOVEQ     #0,D2              Packet number (0)
  4483.           MOVE.B    D0,D3              Packet length as returned by SndParm
  4484.           BSR       SndPack            OK, send now
  4485.           BSR       BumpPckN           Bump packet number, modulo 64
  4486.           MOVE.B    BlChkRq(A6),BlChkUs(A6) Setup block check type
  4487.           MOVE.B    RtryPack(A6),Retry(A6) Setup retry limit for normal packets
  4488.           MOVEQ     #RecFileS,D7       Enter Receive-File state
  4489.           RTS
  4490.  
  4491. ********************************* RecFile *****************************ok
  4492. *                                                                     *
  4493. *  Receive File Header.                                               *
  4494. *                                                                     *
  4495. *         Entry conditions : none                                     *
  4496. *                                                                     *
  4497. *         Exit  conditions : D0.L destroyed                           *
  4498. *                            D1.L destroyed                           *
  4499. *                            D2.B destroyed                           *
  4500. *                            D3.B destroyed                           *
  4501. *                            D7.L next state of the automaton         *
  4502. *                            A0.L destroyed                           *
  4503. *                            A1.L destroyed                           *
  4504. *                                                                     *
  4505. ***********************************************************************
  4506. RecFile   BSR       InpPack            Try to get a packet
  4507.  
  4508.           CMPI.B    #'X',D1            Send-File packet received ?
  4509.           BEQ       RecFile4           Yes
  4510.           CMPI.B    #'B',D1            Break packet received ?
  4511.           BEQ       RecFile5           Yes
  4512.           CMPI.B    #'F',D1            Send-File packet received ?
  4513.           BNE       BadPack            No, abort
  4514.  
  4515.           CLR.B     CmdBfPnt(A6)       Yes, prepare CmdBuf to receive file name
  4516.           LEA       CmdBfOut(PC),A0    File name decoded to CmdBuf
  4517.           BSR       Decode
  4518.  
  4519.           LEA       CmdBuf(A6),A0      Pointer to the file name just decoded
  4520.           TST.B     (A0)               The F packet was null ?
  4521.           BNE.S     RecFile1           No
  4522.           LEA       NoNamStr(PC),A1    Yes, provide a default name
  4523.           MOVEQ     #CmdBufLn,D0       Copy it to CmdBuf
  4524.           BSR       CopyStr
  4525. RecFile1  MOVEA.L   A0,A1              Display the file name on the screen
  4526.           MOVEQ     #RFilName,D0       Load the appropriate request code
  4527.           BSR       Screen             Call the screen handler
  4528.           LEA       Argumnt2(A6),A1    Check for alternate file name
  4529.           TST.B     (A1)               Has been specified ?
  4530.           BEQ.S     RecFile2           No
  4531.           MOVEQ     #CmdBufLn,D0       Yes, copy it to CmdBuf
  4532.           BSR       CopyStr
  4533.           CLR.B     (A1)               Nullify Argumnt2
  4534. RecFile2  LEA       FilName(A6),A1     Return here the actual name
  4535.           BSR       OpnOutF            Try to open (create) the file
  4536.           TST.B     D0                 Check the completion code
  4537.           BEQ.S     RecFile3           Open fails
  4538.           MOVEA.L   A1,A0              Open succeeds, here is the actual name
  4539.           MOVEQ     #FlAsName,D0       Display it on the screen
  4540.           BSR       Screen
  4541.           BSR       EncStrng           Encode the file name into the data field
  4542.           MOVEQ     #'Y',D1            Send an ACK packet
  4543.           MOVE.B    PackNum(A6),D2     Packet number
  4544.           MOVE.B    Size(A6),D3        Packet length
  4545.           BSR       SndPack            Ok, send now
  4546.           BSR       BumpPckN           Bump packet counters
  4547.           MOVEQ     #RecDataS,D7       Enter Receive-Data state
  4548.           RTS
  4549.  
  4550. RecFile3  LEA       FlCrEStr(PC),A1    Point to open failed error message
  4551.           MOVEQ     #ErrMessg,D0       Give bad news
  4552.           BSR       Screen             Screen return the pointer unchanged
  4553.           BSR       SndEPack           Send an Error packet
  4554.           MOVEQ     #AbortS,D7         Abort
  4555.           RTS
  4556.  
  4557. RecFile4  ST        TermOut(A6)        Set the terminal output flag
  4558.           BSR       SendACK            Acknowledge
  4559.           MOVEQ     #RecDataS,D7       Enter Receive-Data state
  4560.           RTS
  4561.  
  4562. RecFile5  BSR       SendACK            Acknowledge
  4563.           MOVEQ     #CompletS,D7       Enter Complete state
  4564.           RTS
  4565.  
  4566. ********************************* RecData *****************************ok
  4567. *                                                                     *
  4568. *  Receive File Data.                                                 *
  4569. *                                                                     *
  4570. *         Entry conditions : none                                     *
  4571. *                                                                     *
  4572. *         Exit  conditions : D1.L destroyed                           *
  4573. *                            D2.B destroyed                           *
  4574. *                            D3.L destroyed                           *
  4575. *                            D7.L next state of the automaton         *
  4576. *                            A0.L destroyed                           *
  4577. *                                                                     *
  4578. ***********************************************************************
  4579. RecData   BSR       InpPack            Try to get a packet
  4580.  
  4581.           CMPI.B    #'Z',D1            EOF packet received ?
  4582.           BEQ.S     RecData6           Yes
  4583.           CMPI.B    #'D',D1            Send-Data packet received ?
  4584.           BNE       BadPack            No, bad packet
  4585.  
  4586.           TST.B     TermOut(A6)        Output to the terminal channel wanted ?
  4587.           BEQ.S     RecData1           No, file output
  4588.           LEA       ConOut(PC),A0      Yes
  4589.           BRA.S     RecData2
  4590. RecData1  LEA       FileOut(PC),A0     Address of the file output function
  4591. RecData2  BSR       Decode             Decode packet and output it
  4592.           LEA       DataBuf(A6),A0     Pointer to data buffer
  4593.           TST.B     CtlXSeen(A6)       File transfer interrupt request ?
  4594.           BEQ.S     RecData3           No, look for group transfer interrupt
  4595.           MOVE.B    #'X',(A0)+         Put "X" in the ACK packet data space
  4596.           BRA.S     RecData4
  4597. RecData3  TST.B     CtlZSeen(A6)       File group transfer interrupt request ?
  4598.           BEQ.S     RecData5           No, send a normal (empty) ACK packet
  4599.           MOVE.B    #'Z',(A0)+         Put "Z" in the ACK packet data space
  4600. RecData4  CLR.B     (A0)+              Mark end of data
  4601.           MOVEQ     #'Y',D1            ACK packet type
  4602.           MOVE.B    PackNum(A6),D2     Packet number
  4603.           MOVEQ     #1,D3              Packet length (1, "X" or "Z")
  4604.           BSR       SndPack            OK, send now
  4605.           BSR       BumpPckN           Bump packet number, modulo 64
  4606.           RTS                          Return, state unchanged
  4607.  
  4608. RecData5  BSR       SendACK            Acknowledge
  4609.           RTS                          Return, state unchanged
  4610.  
  4611. RecData6  TST.B     CtlXSeen(A6)       File transfer interrupted ?
  4612.           BNE.S     RecData7           Yes, close file
  4613.           TST.B     D3                 Empty Z packet ?
  4614.           BEQ.S     RecData7           Yes, close file
  4615.           CMPI.B    #'D',DataBuf(A6)   Discard directive ?
  4616.           SEQ       CtlXSeen(A6)       Set flag for ClsOutF
  4617. RecData7  BSR       ClsOutF            Close the output file
  4618.           SF        CtlXSeen(A6)       Reset flag, necessary for next file
  4619.           BSR       SendACK            Acknowledge
  4620.           MOVEQ     #RecFileS,D7       Enter Receive-File state
  4621.           RTS
  4622.  
  4623.           ends
  4624.           END
  4625. <<< k6opsf.asm >>>
  4626.           nam       Kermit68K
  4627.           ttl       Parser subroutines module
  4628.  
  4629. *         Kermit68K: source file K68PSF
  4630. *
  4631. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  4632. * Bologna University, Physics Department, July 1987.
  4633. *
  4634. * All rights reserved to Bologna University, Italy.
  4635. *
  4636. * Permission is granted to any individual or institution
  4637. * to use, copy, or redistribute this software so long as
  4638. * it  is not  sold for  profit, provided  this copyright
  4639. * notice is retained.
  4640. *
  4641. * Modification History:
  4642. *
  4643. * Version  Date    Who              Comments
  4644. *
  4645. * 1.0.00   870701  Roberto Bagnara  First official release
  4646.  
  4647.           use       DefsFile
  4648.  
  4649. Edition   equ       0
  4650.           psect     K68ParserSubs,0,0,Edition,0,0
  4651.  
  4652. ******************************** ParsWrd ******************************ok
  4653. *                                                                     *
  4654. *  Parse a word string.                                               *
  4655. *                                                                     *
  4656. *         Entry conditions : A0.L points to the target string         *
  4657. *                            A5.L points to the current position      *
  4658. *                                 in the source line                  *
  4659. *                                                                     *
  4660. *         Exit  conditions : A0.L points to the last byte of          *
  4661. *                                 the target string                   *
  4662. *                            A5.L points to the current position      *
  4663. *                                 in the source line                  *
  4664. *                            D0.B completion code                     *
  4665. *                                                                     *
  4666. *                            -3 nothing to look up (source was null)  *
  4667. *                             0 all ok                                *
  4668. *                                                                     *
  4669. ***********************************************************************
  4670. ParsWrd:  BSR      SkipSpr             Skip leading separators
  4671.           TST.B    (A5)                Null source ?
  4672.           BEQ.S    ParsWrd4            Yes, return this
  4673. ParsWrd1  MOVE.B   (A5)+,D0            No, get the first character
  4674.           BEQ.S    ParsWrd2            End of line, exit loop
  4675.           CMPI.B   #' ',D0             Blank ?
  4676.           BEQ.S    ParsWrd3            Yes, exit loop
  4677.           CMPI.B   #Asc_HT,D0          Tab ?
  4678.           BEQ.S    ParsWrd3            Yes, exit loop
  4679.           MOVE.B   D0,(A0)+            No, store the character
  4680.           BRA.S    ParsWrd1            Loop until end of word
  4681. ParsWrd2  SUBQ.L   #1,A5               Backup line pointer
  4682. ParsWrd3  CLR.B    (A0)                Terminate target
  4683.           MOVEQ    #0,D0               Return positive completion code
  4684.           RTS
  4685. ParsWrd4  CLR.B    (A0)                Terminate target
  4686.           MOVEQ    #-3,D0              Return null source completion code
  4687.           RTS
  4688.  
  4689. ******************************** ParsTxt ******************************ok
  4690. *                                                                     *
  4691. *  Parse a text string, quoted or unquoted, this is to allow the      *
  4692. *  specification of trailing delimiters.                              *
  4693. *                                                                     *
  4694. *         Entry conditions : A0.L points to the target string         *
  4695. *                            A5.L points to the current position      *
  4696. *                                 in the source line                  *
  4697. *                                                                     *
  4698. *         Exit  conditions : A0.L points to the last byte of          *
  4699. *                                 the target string                   *
  4700. *                            A5.L points to the current position      *
  4701. *                                 in the source line                  *
  4702. *                            D0.B completion code                     *
  4703. *                            D1.B destroyed                           *
  4704. *                                                                     *
  4705. *                            -3 nothing to look up (source was null)  *
  4706. *                             0 all ok                                *
  4707. *                                                                     *
  4708. ***********************************************************************
  4709. ParsTxt:  BSR      SkipSpr             Skip leading separators
  4710.           MOVE.B   (A5)+,D0            Get the first character, null source ?
  4711.           BEQ.S    ParsTxt7            Yes, return null target cc
  4712.           CMPI.B   #$22,D0             Look for a quote character (")
  4713.           BEQ.S    ParsTxt1
  4714.           CMPI.B   #$27,D0             Look for a quote character (')
  4715.           BEQ.S    ParsTxt1
  4716.           CMPI.B   #$60,D0             Look for a quote character (`)
  4717.           BNE.S    ParsTxt2
  4718. ParsTxt1  MOVE.B   D0,D1               Save the quote character
  4719.           BRA.S    ParsTxt4
  4720. ParsTxt2  CLR.B    D1                  Clear the quote register
  4721. ParsTxt3  MOVE.B   D0,(A0)+            Write character to target string
  4722. ParsTxt4  MOVE.B   (A5)+,D0            Get a character
  4723.           BEQ.S    ParsTxt6            If end of line exit loop
  4724.           CMP.B    D0,D1               Quote character again ?
  4725.           BNE.S    ParsTxt3            No, write char to target, stay in loop
  4726.           CLR.B    (A0)                Yes, terminate target
  4727. ParsTxt5  MOVEQ    #0,D0               Return positive completion code
  4728.           RTS
  4729. ParsTxt6  MOVE.B   -(A5),(A0)          Backup line pointer and terminate target
  4730.           BRA.S    ParsTxt5            Return positive completion code
  4731. ParsTxt7  MOVE.B   -(A5),(A0)          Backup line pointer and terminate target
  4732.           MOVEQ    #-3,D0              Return null source completion code
  4733.           RTS
  4734.  
  4735. ******************************** ParsNm *******************************ok
  4736. *                                                                     *
  4737. *  Parse a number.                                                    *
  4738. *                                                                     *
  4739. *         Entry conditions : D1.L range specification, lower bound    *
  4740. *                            D2.L range specification, upper bound    *
  4741. *                            A5.L points to the current position      *
  4742. *                                 in the source line                  *
  4743. *                                                                     *
  4744. *         Exit  conditions : D0.L parsed number (if any)              *
  4745. *                            D1.B completion code                     *
  4746. *                            A0.L destroyed                           *
  4747. *                            A1.L destroyed                           *
  4748. *                            A5.L points to the current position      *
  4749. *                                 in the source line                  *
  4750. *                                                                     *
  4751. *                            -3 nothing to parse (source was null)    *
  4752. *                            -2 number out of range                   *
  4753. *                            -1 illegal number specification          *
  4754. *                             0 all ok, number in D0.L                *
  4755. *                                                                     *
  4756. ***********************************************************************
  4757. ParsNm:   MOVEM.L   D3-D6,-(A7)        Save working registers
  4758.           LEA       DataBuf(A6),A1     Pointer to temporary buffer
  4759.           MOVEA.L   A1,A0              Put here the parsed word
  4760.           BSR       ParsWrd            Get a word from the source line
  4761.           TST.B     D0                 Null source ?
  4762.           BLT       ParsNm12           Yes, return this condition code
  4763.           MOVEA.L   A1,A0              Set up for addressing
  4764.           CLR.L     D0                 Clear the number register
  4765.           CLR.L     D3                 Clear the character register
  4766.           MOVE.B    (A0)+,D3           Get the first character
  4767.           CMPI.B    #'$',D3            Hexadecimal ?
  4768.           BEQ.S     ParsNm1            Yes, set base register
  4769.           CMPI.B    #'\',D3            Octal ?
  4770.           BEQ.S     ParsNm2            Yes, set base register
  4771.           CMPI.B    #'%',D3            Binary ?
  4772.           BEQ.S     ParsNm3            Yes, set base register to binary
  4773.           MOVEQ     #10,D4             No, set base register to decimal
  4774.           BRA.S     ParsNm5
  4775. ParsNm1   MOVEQ     #16,D4             Set base register to hexadecimal
  4776.           BRA.S     ParsNm4
  4777. ParsNm2   MOVEQ     #8,D4              Set base register to octal
  4778.           BRA.S     ParsNm4
  4779. ParsNm3   MOVEQ     #2,D4              Set base register to binary
  4780. ParsNm4   MOVE.B    (A0)+,D3           Got a base specification, get next
  4781.           BEQ.S     ParsNm10           End of word, invalid number
  4782. ParsNm5   CMPI.B    #'-',D3            Look for a minus sign
  4783.           SEQ       D5                 Set a flag accordingly
  4784.           BNE.S     ParsNm6            Enter the conversion loop
  4785.           MOVE.B    (A0)+,D3           Got a minus sign, get next
  4786.           BEQ.S     ParsNm10           End of word, invalid number
  4787. ParsNm6   BSR       UppCase
  4788.           SUBI.B    #'0',D3            First offset
  4789.           BLT.S     ParsNm10           Less than '0', invalid number
  4790.           CMPI.B    #9,D3              Above 9 ?
  4791.           BLE.S     ParsNm7            No
  4792.           SUBQ.B    #7,D3              Yes, second offset
  4793. ParsNm7   CMP.B     D4,D3              Above the base value ?
  4794.           BGE.S     ParsNm10           Yes, invalid number specification
  4795.           MOVE.L    D0,D6              Make some computation
  4796.           MULU      D4,D0
  4797.           SWAP      D6
  4798.           MULU      D4,D6
  4799.           SWAP      D6
  4800.           CLR.W     D6
  4801.           ADD.L     D6,D0
  4802.           ADD.L     D3,D0
  4803.           MOVE.B    (A0)+,D3           Get the next character, if any
  4804.           BNE.S     ParsNm6            Repeat until end of word
  4805.           TST.B     D5                 Negative number ?
  4806.           BEQ.S     ParsNm8            No
  4807.           NEG.L     D0                 Yes, negate it
  4808. ParsNm8   CMP.L     D1,D0              Less than lower bound ?
  4809.           BLT.S     ParsNm11           Yes, return the proper cc
  4810.           CMP.L     D2,D0              Greater than upper bound ?
  4811.           BGT.S     ParsNm11           Yes, return the proper cc
  4812.           MOVEQ     #0,D1              Provide positive completion code
  4813. ParsNm9   MOVEM.L   (A7)+,D3-D6        Restore working registers
  4814.           RTS
  4815. ParsNm10  MOVEA.L   A1,A0              Pointer to the guilty word
  4816.           LEA       PrNmStr1(PC),A1    Pointer to the error message string
  4817.           BSR       ParsErr            Give the appropriate message
  4818.           MOVEQ     #-1,D1             Return invalid number cc
  4819.           BRA.S     ParsNm9
  4820. ParsNm11  MOVEA.L   A1,A0              Pointer to the guilty word
  4821.           LEA       PrNmStr2(PC),A1    Pointer to the error message string
  4822.           BSR       ParsErr            Give the appropriate message
  4823.           MOVEQ     #-2,D1             Return number out of range cc
  4824.           BRA.S     ParsNm9
  4825. ParsNm12  SUBA.L    A0,A0              No guilty word in this case
  4826.           LEA       PrNmStr3(PC),A1    Pointer to the error message string
  4827.           BSR       ParsErr            Give the appropriate message
  4828.           MOVEQ     #-3,D1             Return missing number specification cc
  4829.           BRA.S     ParsNm9
  4830.  
  4831. ******************************** ParsKyW ******************************ok
  4832. *                                                                     *
  4833. *  Parse a keyword, giving, on error, appropriate messages.           *
  4834. *                                                                     *
  4835. *         Entry conditions : D1.B flag for mandatory keywords         *
  4836. *                            A1.L points to keywords table            *
  4837. *                            A5.L points to the current position      *
  4838. *                                 in the source line                  *
  4839. *                                                                     *
  4840. *         Exit  conditions : D0.B completion code                     *
  4841. *                                                                     *
  4842. *                            -3 nothing to look up (source was null)  *
  4843. *                            -2 ambiguous keyword                     *
  4844. *                            -1 keyword not found                     *
  4845. *                            n >= 0 value associated with keyword     *
  4846. *                                                                     *
  4847. *                            D2.B destroyed                           *
  4848. *                            A0.L destroyed                           *
  4849. *                            A1.L destroyed                           *
  4850. *                            A2.L destroyed                           *
  4851. *                                                                     *
  4852. ***********************************************************************
  4853. ParsKyW:  LEA       DataBuf(A6),A2     Pointer to temporary buffer
  4854.           MOVEA.L   A2,A0              Put here the parsed word
  4855.           BSR       ParsWrd            Get a word from the source line
  4856.           MOVEA.L   A2,A0              Set up for addressing
  4857.           BSR       Lookup             Search the keyword in the given table
  4858.           TST.B     D0                 Some error condition reported ?
  4859.           BGE.S     ParsKyW5           No, return value in D0.B
  4860.           MOVE.B    D0,D2              Yes, save the completion code
  4861.           ADDQ.B    #1,D0              Unrecognized keyword ?
  4862.           BEQ.S     ParsKyW1           Yes, give error message
  4863.           ADDQ.B    #1,D0              Ambiguous keyword ?
  4864.           BEQ.S     ParsKyW2           Yes, give error message
  4865.           TST.B     D1                 No, missing keyword, was it mandatory ?
  4866.           BEQ.S     ParsKyW4           No, no message, return bad cc
  4867.           LEA       PrKyStr3(PC),A0    Yes, give missing keyword error message
  4868.           BSR       ConWrite           Write the message
  4869.           MOVEA.L   A1,A0              Write the requested object name
  4870.           BSR       ConWrite
  4871.           BSR       NewLine            Start a new line
  4872.           BRA.S     ParsKyW4           Newline and return
  4873. ParsKyW1  LEA       PrKyStr1(PC),A0    Give unrecognized keyword error message
  4874.           BRA.S     ParsKyW3           Join common part
  4875. ParsKyW2  LEA       PrKyStr2(PC),A0    Give ambiguous keyword error message
  4876. ParsKyW3  BSR       ConWrite           Write the error type string
  4877.           MOVEA.L   A1,A0              Write the requested object name
  4878.           BSR       ConWrite
  4879.           MOVEA.L   A2,A0              Write the guilty word
  4880.           SUBA.L    A1,A1              Error message already given
  4881.           BSR       ParsErr
  4882. ParsKyW4  MOVE.B    D2,D0              Restore the completion code from LookUp
  4883. ParsKyW5  RTS
  4884.  
  4885. ******************************* ParsInF *******************************ok
  4886. *                                                                     *
  4887. *  Parse an input file name specification.                            *
  4888. *                                                                     *
  4889. *         Entry conditions : A0.L point to the target string          *
  4890. *                            A5.L points to the current position      *
  4891. *                                 in the source line                  *
  4892. *                                                                     *
  4893. *         Exit  conditions : D0.B completion code                     *
  4894. *                                                                     *
  4895. *                            -3 nothing to parse (source was null)    *
  4896. *                            -2 illegal file name specification       *
  4897. *                             0 all ok                                *
  4898. *                                                                     *
  4899. *                            A1.L destroyed                           *
  4900. *                            A5.L points to the current position      *
  4901. *                                 in the source line                  *
  4902. *                                                                     *
  4903. ***********************************************************************
  4904. ParsInF:  MOVEA.L   A0,A1              Save the target pointer
  4905.           BSR       ParsWrd            Get a word from the command line
  4906.           TST.B     D0                 Null source ?
  4907.           BLT.S     ParsInF2           Yes, return this
  4908.           MOVEA.L   A1,A0              Reload target pointer
  4909.           BSR       ChkWild            Check for wild characters
  4910.           TST.B     D0                 Wild filename ?
  4911.           BNE.S     ParsInF3           Yes, try to expand it
  4912.           BSR       ChkInpF            Check if file exists and is readable
  4913.           TST.B     D0                 Inexistent or unreadable file ?
  4914.           BLT.S     ParsInF5           Yes, give error message
  4915. ParsInF1  MOVEQ     #0,D0              No, all ok, return positive cc
  4916. ParsInF2  RTS
  4917. ParsInF3  BSR       ExpandFN           Try to expand the wild file name
  4918.           TST.L     D0                 Check the result
  4919.           BGT.S     ParsInF1           All ok, at least one match
  4920.           BLT.S     ParsInF4           Too many matches, give error message
  4921.           LEA       PrIFStr4(PC),A0    No matches, error
  4922.           BRA.S     ParsInF8           Join common part
  4923. ParsInF4  LEA       PrIFStr5(PC),A0    Notify overflow during name expansion
  4924.           BRA.S     ParsInF8           Join common part
  4925. ParsInF5  ADDQ.B    #1,D0              File not found ?
  4926.           BEQ.S     ParsInF6           Yes
  4927.           ADDQ.B    #1,D0              File not readable ?
  4928.           BEQ.S     ParsInF7           Yes
  4929.           LEA       PrIFStr3(PC),A0    No, read permission denied
  4930.           BRA.S     ParsInF8           Join common part
  4931. ParsInF6  LEA       PrIFStr1(PC),A0    File not found error message
  4932.           BRA.S     ParsInF8           Join common part
  4933. ParsInF7  LEA       PrIFStr2(PC),A0    File not readable error message
  4934. ParsInF8  EXG       A0,A1              Setup pointers
  4935.           BSR       ParsErr            Call the error messages routine
  4936.           MOVEQ     #-2,D0             Return a negative completion code
  4937.           RTS
  4938.  
  4939. ******************************* ParsOuF *******************************ok
  4940. *                                                                     *
  4941. *  Parse an output file name specification.                           *
  4942. *                                                                     *
  4943. *         Entry conditions : A0.L point to the target string          *
  4944. *                            A5.L points to the current position      *
  4945. *                                 in the source line                  *
  4946. *                                                                     *
  4947. *         Exit  conditions : A5.L points to the current position      *
  4948. *                                 in the source line                  *
  4949. *                            D0.B completion code                     *
  4950. *                                                                     *
  4951. *                            -3 nothing to parse (source was null)    *
  4952. *                            -2 illegal output file name              *
  4953. *                             0 all ok                                *
  4954. *                                                                     *
  4955. ***********************************************************************
  4956. ParsOuF:  MOVEA.L   A0,A1              Save the target pointer
  4957.           BSR       ParsWrd            Get a word from the command line
  4958.           TST.B     D0                 Null source ?
  4959.           BLT.S     ParsOuF1           Yes, return this
  4960.           MOVEA.L   A1,A0              Reload target pointer
  4961.           BSR       ChkWild            Check for wild characters
  4962.           TST.B     D0                 Wild filename ?
  4963.           BNE.S     ParsOuF2           Yes, give error message
  4964.           BSR       ChkOutF            Check if file can be created
  4965.           TST.B     D0                 Permission denied ?
  4966.           BLT.S     ParsOuF3           Yes, give error message
  4967.           MOVEQ     #0,D0              No, all ok, return positive cc
  4968. ParsOuF1  RTS
  4969. ParsOuF2  LEA       POuFStr1(PC),A0    Give wildcard not allowed error message
  4970.           BRA.S     ParsOuF4           Join common part
  4971. ParsOuF3  LEA       POuFStr2(PC),A0    Give permission denied error message
  4972. ParsOuF4  EXG       A0,A1              Setup pointers
  4973.           BSR       ParsErr            Call the error messages routine
  4974.           MOVEQ     #-2,D0             Return negative completion code
  4975.           RTS
  4976.  
  4977. ******************************* ChkWild *******************************ok
  4978. *                                                                     *
  4979. *  Check a string for wildcard character presence.                    *
  4980. *                                                                     *
  4981. *         Entry conditions : A0.L points to the string to check       *
  4982. *                                                                     *
  4983. *         Exit  conditions : D0.B completion code                     *
  4984. *                            A0.L points to the checked string        *
  4985. *                                                                     *
  4986. ***********************************************************************
  4987. ChkWild:  MOVE.L    A0,-(A7)           Save the string pointer
  4988. ChkWild1  MOVE.B    (A0)+,D0           Get a character
  4989.           BEQ.S     ChkWild3           End of string, exit loop, return false
  4990.           CMPI.B    #'*',D0            Match-all wildcard character ?
  4991.           BEQ.S     ChkWild2           Yes, the file name is wild
  4992.           CMPI.B    #'?',D0            Match-one wildcard character ?
  4993.           BNE.S     ChkWild1           No, loop until end of string
  4994. ChkWild2  ST        D0                 Yes, exit loop, return true
  4995. ChkWild3  MOVE.L    (A7)+,A0           Restore the string pointer
  4996.           RTS
  4997.  
  4998. ********************************* Lookup ******************************ok
  4999. *                                                                     *
  5000. *  Lookup a keyword in the given array of keywords.                   *
  5001. *                                                                     *
  5002. *         Entry conditions : A0.L points to the source string         *
  5003. *                                 null terminated                     *
  5004. *                            A1.L points to the keywords table        *
  5005. *                                                                     *
  5006. *         Exit  conditions : D0.B completion code                     *
  5007. *                                                                     *
  5008. *                            -3 nothing to look up (target was null)  *
  5009. *                            -2 ambiguous keyword                     *
  5010. *                            -1 keyword not found                     *
  5011. *                            n >= 0 value associated with keyword     *
  5012. *                                                                     *
  5013. *                            A0.L points to the source string         *
  5014. *                                 null terminated                     *
  5015. *                            A1.L points to the object name           *
  5016. *                                                                     *
  5017. ***********************************************************************
  5018. Lookup    MOVEM.L   A2/D1-D4,-(A7)     Save working registers
  5019.           CLR.B     D1                 Clear matchs counter
  5020.           TST.B     (A0)               Null keyword ?
  5021.           BNE.S     Lookup2            No, continue
  5022. Lookup1   MOVE.B    (A1)+,D4           Yes, skip to end of table
  5023.           CMPI.B    #-1,D4             End of table ?
  5024.           BNE.S     Lookup1            No, loop
  5025.           MOVEQ     #-3,D0             Return nothing to look up cc
  5026.           BRA.S     Lookup8
  5027.  
  5028. Lookup2   MOVE.B    (A1)+,D4           Get the value associated to this word
  5029.           CMPI.B    #-1,D4             End of table ?
  5030.           BEQ.S     Lookup7            Yes, check if match(s) occurred
  5031.           MOVEA.L   A0,A2
  5032.  
  5033. Lookup3   MOVE.B    (A2)+,D3           Get next character from command line
  5034.           BEQ.S     Lookup4            End of word, match !
  5035.           BSR       UppCase            Upper case it for compare
  5036.           MOVE.B    (A1)+,D2           Get a character from table
  5037.           BEQ.S     Lookup2            End of word, no match, try the next
  5038.           CMP.B     D3,D2              Match ?
  5039.           BNE.S     Lookup5            No, skip to the next table element
  5040.           BRA.S     Lookup3            Yes, look to the next character
  5041.  
  5042. Lookup4   TST.B     (A1)               Match found, is a supermatch ?
  5043.           BEQ.S     Lookup6            Yes, stop searching
  5044.           ADDQ.B    #1,D1              No, increment matchs counter
  5045.           MOVE.B    D4,D0              Load the return value
  5046. Lookup5   MOVE.B    (A1)+,D2           Skip to next table element
  5047.           BNE.S     Lookup5            Skip characters until end of word
  5048.           BRA.S     Lookup2            Scan all the table elements
  5049.  
  5050. Lookup6   MOVE.B    D4,D0              Supermatch found, load the return value
  5051.           BRA.S     Lookup8
  5052.  
  5053. Lookup7   CMPI.B    #1,D1              Check matchs counter
  5054.           BLT.S     Lookup9            If no match return keyword not found cc
  5055.           BGT.S     Lookup10           More than 1, ambiguous keyword cc
  5056. Lookup8   MOVEM.L   (A7)+,A2/D1-D4     Restore working registers
  5057.           RTS
  5058. Lookup9   MOVEQ     #-1,D0             Return the keyword not found cc
  5059.           BRA.S     Lookup8
  5060. Lookup10  MOVEQ     #-2,D0             Return the ambiguous keyword cc
  5061.           BRA.S     Lookup8
  5062.  
  5063. ********************************* ParsErr *****************************ok
  5064. *                                                                     *
  5065. *  Give a parsing error message.                                      *
  5066. *                                                                     *
  5067. *         Entry conditions : A0.L point to the guilty word            *
  5068. *                                 null terminated, no guilty word     *
  5069. *                                 to print if null pointer passed     *
  5070. *                            A1.L point to the error message, no      *
  5071. *                                 message to print if null pointer    *
  5072. *                                 passed                              *
  5073. *                                                                     *
  5074. *         Exit  conditions : D0.L destroyed                           *
  5075. *                            D1.L destroyed                           *
  5076. *                                                                     *
  5077. ***********************************************************************
  5078. ParsErr:  EXG       A0,A1              Write the error string first, if any
  5079.           MOVE.L    A0,D1              Null pointer passed ?
  5080.           BEQ.S     ParsErr1           Yes, no error message
  5081.           BSR       ConWrite           No, write it
  5082. ParsErr1  MOVE.L    A1,D1              Null pointer passed ?
  5083.           BEQ.S     ParsErr4           Yes, no guilty word
  5084.           LEA       PrErStr1(PC),A0    No, point to separator string
  5085.           BSR       ConWrite           Write it to terminal
  5086.           MOVEQ     #'"',D0            Type the leading quotation mark
  5087.           BSR       ConOut
  5088. ParsErr2  MOVE.B    (A1)+,D0           And then the guilty word
  5089.           BEQ.S     ParsErr3           If end of word, exit loop
  5090.           BSR       ConOut             Write a character
  5091.           BRA.S     ParsErr2           And the next, if any
  5092. ParsErr3  MOVEQ     #'"',D0            Type the trailing quotation mark
  5093.           BSR       ConOut
  5094. ParsErr4  BSR       NewLine            Start a new line
  5095.           RTS
  5096.  
  5097. ******************************* SkipSpr *******************************ok
  5098. *                                                                     *
  5099. *  Skip leading separators from the command line.                     *
  5100. *                                                                     *
  5101. *         Entry conditions : A5.L point to the current position       *
  5102. *                            in the command line                      *
  5103. *                                                                     *
  5104. *         Exit  conditions : D0.B destroyed                           *
  5105. *                            A5.L point to the current position       *
  5106. *                            in the command line                      *
  5107. *                                                                     *
  5108. ***********************************************************************
  5109. SkipSpr   MOVE.B    (A5)+,D0           Get a character
  5110.           BEQ.S     SkipSpr1           End of buffer, exit
  5111.           CMPI.B    #' ',D0            Blank ?
  5112.           BEQ.S     SkipSpr            Yes, skip
  5113.           CMPI.B    #Asc_HT,D0         Tab ?
  5114.           BEQ.S     SkipSpr            Yes, skip
  5115. SkipSpr1  SUBQ.L    #1,A5              Backup line pointer
  5116.           RTS
  5117.  
  5118.           ends
  5119.           END
  5120. <<< k6opt2.asm >>>
  5121.           nam       Kermit68K
  5122.           ttl       Low-level protocol subroutines module
  5123.  
  5124. *         Kermit68K: source file K68PT2
  5125. *
  5126. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  5127. * Bologna University, Physics Department, July 1987.
  5128. *
  5129. * All rights reserved to Bologna University, Italy.
  5130. *
  5131. * Permission is granted to any individual or institution
  5132. * to use, copy, or redistribute this software so long as
  5133. * it  is not  sold for  profit, provided  this copyright
  5134. * notice is retained.
  5135. *
  5136. * Modification History:
  5137. *
  5138. * Version  Date    Who              Comments
  5139. *
  5140. * 1.0.00   870701  Roberto Bagnara  First official release
  5141.  
  5142.           use       DefsFile
  5143.  
  5144. Edition   equ       0
  5145.           psect     K68ProtoFuncs2,0,0,Edition,0,0
  5146.  
  5147. ******************************* TrnsInit ******************************ok
  5148. *                                                                     *
  5149. *  Initialize a transaction.                                          *
  5150. *                                                                     *
  5151. *         Entry conditions : none                                     *
  5152. *                                                                     *
  5153. *         Exit  conditions : none                                     *
  5154. *                                                                     *
  5155. ***********************************************************************
  5156. TrnsInit: MOVE.B    #1,BlChkUs(A6)     Reset block check type to 1
  5157.           SF        Bit8Flag(A6)       Reset 8th bit quoting stuff
  5158.           MOVE.B    #1,NextPckN(A6)    Reset packet counters
  5159.           MOVE.B    #0,PackNum(A6)
  5160.           MOVE.B    #-1,PrevPckN(A6)
  5161.           SF        MStrFlag(A6)       Reset memory string flag
  5162.           CLR.L     MStrgPnt(A6)       Reset memory string pointer
  5163.           SF        CtlXSeen(A6)       Reset interrupts flag
  5164.           SF        CtlZSeen(A6)
  5165.           CLR.B     SendBuf(A6)        Clear send buffer
  5166.           CLR.B     FilName(A6)        Clear current file name
  5167.           MOVE.B    RtryInit(A6),Retry(A6) Initialize the retry limit
  5168.           CLR.L     ChrsSent(A6)       Clear the statistic variables
  5169.           CLR.L     ChrsRecd(A6)
  5170.           CLR.L     DChsSent(A6)
  5171.           CLR.L     DChsRecd(A6)
  5172.           CLR.L     PcksSent(A6)
  5173.           CLR.L     PcksRecd(A6)
  5174.           CLR.L     NAKsSent(A6)
  5175.           CLR.L     NAKsRecd(A6)
  5176.           RTS
  5177.  
  5178. *********************************** SetGCmd ***************************ok
  5179. *                                                                     *
  5180. *  Setup for generic commands.                                        *
  5181. *                                                                     *
  5182. *         Entry conditions : D0.B command type                        *
  5183. *                            A0.L destroyed                           *
  5184. *                            A1.L destroyed                           *
  5185. *                            A2.L first  argument address, if any     *
  5186. *                            A3.L second argument address, if any     *
  5187. *                            A4.L third  argument address, if any     *
  5188. *                                                                     *
  5189. *         Exit  conditions : D0.L destroyed                           *
  5190. *                                                                     *
  5191. ***********************************************************************
  5192. SetGCmd:  LEA       CmdBuf(A6),A1      Load pointer to command buffer
  5193.           MOVE.B    D0,(A1)+           Write command type
  5194.           CLR.B     (A1)               Terminate it
  5195.           MOVE.L    A2,D0              First argument pointer null ?
  5196.           BEQ.S     SetGCmd1           Yes, exit
  5197.           TST.B     (A2)               No, first argument null ?
  5198.           BEQ.S     SetGCmd1           Yes, exit
  5199.           MOVEA.L   A2,A0              Load pointer to first argument
  5200.           BSR       CpStrLn            Copy it to data buffer
  5201.           MOVE.L    A3,D0              Second argument pointer null ?
  5202.           BEQ.S     SetGCmd1           Yes, exit
  5203.           TST.B     (A3)               No, second argument null ?
  5204.           BEQ.S     SetGCmd1           Yes, exit
  5205.           MOVEA.L   A3,A0              Load pointer to second argument
  5206.           BSR       CpStrLn            Copy it to data buffer
  5207.           MOVE.L    A4,D0              Third argument pointer null ?
  5208.           BEQ.S     SetGCmd1           Yes, exit
  5209.           TST.B     (A4)               No, third argument null ?
  5210.           BEQ.S     SetGCmd1           Yes, exit
  5211.           MOVEA.L   A4,A0              Load pointer to third argument
  5212.           BSR       CpStrLn            Copy it to data buffer
  5213. SetGCmd1  MOVE.B    #'G',ServrCmd(A6)  Generic command packet type
  5214.           BSR       TrnsInit           Initialize the transaction
  5215.           RTS
  5216.  
  5217. ********************************* Decode ******************************ok
  5218. *                                                                     *
  5219. *  Kermit packet decoding procedure, decodes from DataBuf and call an *
  5220. *  output function at the given address.                              *
  5221. *                                                                     *
  5222. *         Entry conditions : A0.L address of the output function      *
  5223. *                                                                     *
  5224. *         Exit  conditions : D0.B completion code                     *
  5225. *                                                                     *
  5226. ***********************************************************************
  5227. Decode:   MOVEM.L   A1/D1-D3,-(A7)     Save working registers
  5228.           LEA       DataBuf(A6),A1     Pointer to data buffer
  5229. Decode1   MOVEQ     #1,D3              Setup the repeat counter
  5230.           MOVE.B    (A1)+,D0           Get a character
  5231.           BEQ.S     Decode9            Exit at end of buffer
  5232.           TST.B     ReptFlag(A6)       Repeat processing ?
  5233.           BEQ.S     Decode2            No
  5234.           CMP.B     ReptQuot(A6),D0    Yes, got a repeat prefix ?
  5235.           BNE.S     Decode2            No
  5236.           MOVE.B    (A1)+,D3           Yes, get the repeat count
  5237.           SUBI.B    #32,D3             Convert it ...
  5238.           MOVE.B    (A1)+,D0           ... and get the prefixed character
  5239. Decode2   MOVEQ     #$00,D1            Clear the 8th bit register
  5240.           TST.B     Bit8Flag(A6)       8th bit prefixing ?
  5241.           BEQ.S     Decode3            No
  5242.           CMP.B     Bit8Quot(A6),D0    Yes, got an 8th bit prefix ?
  5243.           BNE.S     Decode3            No
  5244.           MOVEQ     #$80,D1            Yes, remember this ...
  5245.           MOVE.B    (A1)+,D0           ... and get the prefixed character
  5246. Decode3   CMP.B     ICtlQuot(A6),D0    Got a control prefix ?
  5247.           BNE.S     Decode6            No
  5248.           MOVE.B    (A1)+,D0           Yes, get its operand
  5249.           MOVE.B    D0,D2              Make a copy
  5250.           ANDI.B    #$7F,D2            Only look at lower 7 bits
  5251.           CMPI.B    #$40,D2            Above Null ?
  5252.           BLT.S     Decode4            No, look for Delete
  5253.           CMPI.B    #$5F,D2            Yes, between Null and US ?
  5254.           BLE.S     Decode5            Yes, uncontrollify
  5255. Decode4   CMPI.B    #'?',D2            Delete ?
  5256.           BNE.S     Decode6            No, character not in control range
  5257. Decode5   EORI.B    #64,D0             Uncontrollify
  5258. Decode6   OR.B      D1,D0              OR in the 8th bit
  5259.           TST.B    Binary(A6)          Are we in binary mode ?
  5260.           BNE.S    Decode8             Yes, CRLF-nl mapping not needed
  5261.           CMPI.B   #Asc_CR,D0          Carriage Return ?
  5262.           BEQ.S    Decode1             Yes, discard it
  5263.           CMPI.B   #Asc_LF,D0          No, Line Feed ?
  5264.           BNE.S    Decode8             No
  5265.           MOVEQ    #NewLinCh,D0        Yes, convert it into newline character
  5266.           BRA.S     Decode8            Ok, ready for output
  5267. Decode7   JSR       (A0)               Call the output function
  5268.           TST.B     D1                 Check completion code
  5269.           BNE.S     Decode9            If failure return
  5270.           ADDQ.L    #1,DChsRecd(A6)    Increment data chars received this trans
  5271.           ADDQ.L    #1,TDChRecd(A6)    Increment total data characters received
  5272. Decode8   DBF       D3,Decode7         Output char repeat times (at least 1)
  5273.           BRA.S     Decode1
  5274. Decode9   MOVEM.L   (A7)+,A1/D1-D3     Restore working registers
  5275.           RTS
  5276.  
  5277. ******************************** CmdBfOut *****************************ok
  5278. *                                                                     *
  5279. *  Output to command buffer, called by Decode.                        *
  5280. *                                                                     *
  5281. *         Entry conditions : D0.B character to output                 *
  5282. *                                                                     *
  5283. *         Exit  conditions : D1.B AllOk completion code (0)           *
  5284. *                                                                     *
  5285. ***********************************************************************
  5286. CmdBfOut: MOVE.L    A0,-(A7)           Save register
  5287.           LEA       CmdBuf(A6),A0      Point to command buffer start address
  5288.           CLR.W     D1                 Clear the index register
  5289.           MOVE.B    CmdBfPnt(A6),D1    Load relative pointer to command buffer
  5290.           MOVE.B    D0,(A0,D1.W)       Write the character
  5291.           ADDQ.B    #1,D1              Increment the index register
  5292.           CLR.B     (A0,D1.W)          Make sure buffer is null-terminated
  5293.           MOVE.B    D1,CmdBfPnt(A6)    Save the index register
  5294.           MOVEQ     #AllOk,D1          Return a positive competion code (0)
  5295.           MOVE.L    (A7)+,A0           Restore register
  5296.           RTS
  5297.  
  5298. ********************************* Encode ******************************ok
  5299. *                                                                     *
  5300. *  Kermit packet encoding procedure, encodes to DataBuf.              *
  5301. *                                                                     *
  5302. *         Entry conditions : D0.B character to be encoded             *
  5303. *                            D2.W current size of output data packet  *
  5304. *                                                                     *
  5305. *         Exit  conditions : D2.W current size of output data packet  *
  5306. *                            D1.L destroyed                           *
  5307. *                            D3.B destroyed                           *
  5308. *                            A1.L destroyed                           *
  5309. *                                                                     *
  5310. ***********************************************************************
  5311. Encode:   LEA       DataBuf(A6),A1     Pointer to data buffer
  5312.           TST.B     ReptFlag(A6)       Repeat processing ?
  5313.           BEQ.S     Encode5            No, do prefixing
  5314.           CMP.B     Next(A6),D0        Current and next character are equal ?
  5315.           BNE.S     Encode4            No
  5316.           TST.B     First(A6)          Input in progress
  5317.           BNE.S     Encode4            No, first time called
  5318.           ADDQ.B    #1,ReptCnt(A6)     Increment the repeat counter
  5319.           CMPI.B    #94,ReptCnt(A6)    Below max ?
  5320.           BEQ.S     Encode2            No, max reached, must dump
  5321.           RTS                          Yes, just count and return
  5322.  
  5323. Encode1   ADDQ.B    #1,ReptCnt(A6)     More than 2 character to repeat
  5324. Encode2   MOVE.B    ReptQuot(A6),(A1,D2.W) Write the repeat quote
  5325.           ADDQ.W    #1,D2              Increment the pointer register
  5326.           MOVE.B    ReptCnt(A6),D1     Get the repeat count
  5327.           ADDI.B    #32,D1             Convert it into a character
  5328.           MOVE.B    D1,(A1,D2.W)       Write the repeat count
  5329.           ADDQ.W    #1,D2              Increment the pointer register
  5330. Encode3   CLR.B     ReptCnt(A6)        Reset the repeat counter
  5331.           BRA.S     Encode5            Done repeat processing, do prefixing
  5332. Encode4   CMPI.B    #1,ReptCnt(A6)     Run broken, only 2 ?
  5333.           BLT.S     Encode5            No, only 1, do it
  5334.           BGT.S     Encode1            No, more than 2
  5335.           MOVE.B    D0,D3              Yes, do the character twice, save char
  5336.           BSR.S     Encode5            Do it the first time
  5337.           MOVE.B    D3,D0              Restore the character
  5338.           CMP.B     OMPckSiz(A6),D2    Max packet size exceded ?
  5339.           BGT.S     Encode3            Yes, do the character again
  5340.           MOVE.B    D2,OldSize(A6)     No, update OldSize
  5341.           BRA.S     Encode3            Do the character again
  5342.  
  5343. Encode5   MOVEQ     #$7F,D1            Isolate ASCII part
  5344.           AND.B     D0,D1
  5345.           BTST      #7,D0              Do 8th bit prefixing if necessary
  5346.           BEQ.S     Encode6
  5347.           TST.B     Bit8Flag(A6)
  5348.           BEQ.S     Encode6
  5349.           MOVE.B    Bit8Quot(A6),(A1,D2.W) Write the 8th bit quote
  5350.           ADDQ.W    #1,D2              Increment the pointer register
  5351.           MOVE.B    D1,D0
  5352.  
  5353. Encode6   CMPI.B    #' ',D1            Do control prefixing if necessary
  5354.           BLT.S     Encode7
  5355.           CMPI.B    #Asc_Del,D1        Delete ?
  5356.           BNE.S     Encode8            No, character not in control range
  5357. Encode7   EORI.B    #64,D0             Uncotrollify
  5358.           BRA.S     Encode10
  5359.  
  5360. Encode8   CMPI.B    #MyCtlQot,D1       Prefix the control prefix
  5361.           BEQ.S     Encode10
  5362.  
  5363.           CMP.B     ReptQuot(A6),D1    If it's the repeat prefix ...
  5364.           BNE.S     Encode9
  5365.           TST.B     ReptFlag(A6)       ... quote it if doing repeat counts
  5366.           BEQ.S     Encode11
  5367.           BRA.S     Encode10
  5368.  
  5369. Encode9   CMP.B     Bit8Quot(A6),D1    Prefix the 8th bit prefix ...
  5370.           BNE.S     Encode11
  5371.           TST.B     Bit8Flag(A6)       ... if doing 8th-bit prefixes
  5372.           BEQ.S     Encode11
  5373.  
  5374. Encode10  MOVE.B    #MyCtlQot,(A1,D2.W) Write the control quote
  5375.           ADDQ.W    #1,D2              Increment the pointer register
  5376. Encode11  MOVE.B    D0,(A1,D2.W)       Finally, insert the character
  5377.           ADDQ.W    #1,D2              Increment the pointer register
  5378.           CLR.B     (A1,D2.W)          Mark the end
  5379.           RTS
  5380.  
  5381. ********************************* SndParm *****************************ok
  5382. *                                                                     *
  5383. *  Fill the data buffer with my send-init parameters.                 *
  5384. *                                                                     *
  5385. *         Entry conditions : none                                     *
  5386. *                                                                     *
  5387. *         Exit  conditions : D0.L data length                         *
  5388. *                            D1.L destroyed                           *
  5389. *                            A0.L destroyed                           *
  5390. *                                                                     *
  5391. ***********************************************************************
  5392. SndParm:  LEA       DataBuf(A6),A0     Pointer to send buffer
  5393.           MOVEQ     #32,D1             Load register for quick addition
  5394.  
  5395.           MOVE.B    IMPckSiz(A6),D0    Biggest packet I can receive
  5396.           ADD.B     D1,D0              Conversion into a printable character
  5397.           MOVE.B    D0,(A0)+           Put it into data buffer
  5398.  
  5399.           MOVE.B    OTimInt(A6),D0     When I want to be timed out
  5400.           ADD.B     D1,D0              Conversion into a printable character
  5401.           MOVE.B    D0,(A0)+           Put it into data buffer
  5402.  
  5403.           MOVE.B    IPadNumb(A6),D0    How much padding I need
  5404.           ADD.B     D1,D0              Conversion into a printable character
  5405.           MOVE.B    D0,(A0)+           Put it into data buffer
  5406.  
  5407.           MOVE.B    IPadChar(A6),D0    Padding character I want
  5408.           EORI.B    #64,D0             Uncontrollify it
  5409.           MOVE.B    D0,(A0)+           Put it into data buffer
  5410.  
  5411.           MOVE.B    IEOL(A6),D0        End-Of-Line character I want
  5412.           ADD.B     D1,D0              Conversion into a printable character
  5413.           MOVE.B    D0,(A0)+           Put it into data buffer
  5414.  
  5415.           MOVE.B    OCtlQuot(A6),(A0)+ Control-Quote character I send
  5416.  
  5417.           MOVE.B    Parity(A6),D0      Parity is enabled or the ...
  5418.           OR.B      Bit8Flag(A6),D0    ... 8th bit processing flag is on ?
  5419.           BEQ.S     SndParm1           No, no need for 8th bit quoting
  5420.           MOVE.B    #My8BQuot,(A0)+    Send my 8th bit quote character
  5421.           MOVE.B    Bit8Quot(A6),D0    Get quote
  5422.           CMPI.B    #'Y',D0            If other side say YES to do ...
  5423.           SEQ       Bit8Flag(A6)       ... 8th bit quoting
  5424.           BEQ.S     SndParm2
  5425.           BSR       ChkQuot            If other side specify a valid quote ...
  5426.           MOVE.B    D0,Bit8Flag(A6)    ... turn the 8th bit quoting flag on
  5427.           BRA.S     SndParm2
  5428. SndParm1  MOVE.B    #'Y',(A0)+         Normally just say we're willing
  5429. SndParm2  MOVE.B    BlChkRq(A6),D0     Block check type
  5430.           ADDI.B    #'0',D0            Conversion into a printable character
  5431.           MOVE.B    D0,(A0)+           Send it
  5432.           MOVE.B    #MyRptQot,(A0)+    Do repeat counts
  5433.           CLR.B     (A0)               Terminator
  5434.           MOVEQ     #9,D0              Return length
  5435.           RTS
  5436.  
  5437. ******************************** RdParam ******************************ok
  5438. *                                                                     *
  5439. *  Get the other host's send-init parameters.                         *
  5440. *                                                                     *
  5441. *         Entry conditions : none                                     *
  5442. *                                                                     *
  5443. *         Exit  conditions : D0.B destroyed                           *
  5444. *                            D1.B destroyed                           *
  5445. *                            D2.L destroyed                           *
  5446. *                            A0.L destroyed                           *
  5447. *                                                                     *
  5448. ***********************************************************************
  5449. RdParam:  LEA       DataBuf(A6),A0     Pointer to data buffer
  5450.           MOVEQ     #32,D2             Load register for quick subtraction
  5451.  
  5452.           MOVE.B    #DefMxPSz,OMPckSiz(A6) Maximum send packet size
  5453.           MOVE.B    #DefTmOut,ITimInt(A6)  When I should time out
  5454.           MOVE.B    #DefPadNm,OPadNumb(A6) Number of pads to send
  5455.           MOVE.B    #DefPadCr,OPadChar(A6) Padding character to send
  5456.           MOVE.B    #DefEOL,OEOL(A6)       EOL character I must send
  5457.           MOVE.B    #DefCtlQt,ICtlQuot(A6) Incoming data quote character
  5458.           MOVE.B    Bit8Flag(A6),D1        Save 8th bit processing flag
  5459.           SF        Bit8Flag(A6)           No 8th bit quoting by default
  5460.           MOVE.B    #1,BlChkRq(A6)         Block check type requested
  5461.           SF        ReptFlag(A6)           No repeat processing by default
  5462.  
  5463.           MOVE.B    (A0)+,D0           Maximum send packet size
  5464.           BEQ       RdParam9
  5465.           SUB.B     D2,D0
  5466.           TST.B     SndPSFlg(A6)       Override privilege ?
  5467.           BEQ.S     RdParam1           No, continue
  5468.           CMPI.B    #10,D0             Yes, less than 10 ?
  5469.           BLT.S     RdParam2           Yes, leave unchanged the default value
  5470. RdParam1  MOVE.B    D0,OMPckSiz(A6)    No, update
  5471.  
  5472. RdParam2  MOVE.B    (A0)+,D0           When I should time out
  5473.           BEQ       RdParam9
  5474.           SUB.B     D2,D0
  5475.           TST.B     TimInFlg(A6)       Override privilege ?
  5476.           BEQ.S     RdParam3           No, continue
  5477.           TST.B     D0                 Yes, less than 0 ?
  5478.           BLT.S     RdParam4           Yes, leave unchanged the default value
  5479. RdParam3  MOVE.B    D0,ITimInt(A6)     No, update
  5480.  
  5481. RdParam4  MOVE.B    (A0)+,D0           Number of pads to send
  5482.           BEQ       RdParam9
  5483.           SUB.B     D2,D0
  5484.           MOVE.B    D0,OPadNumb(A6)
  5485.  
  5486.           MOVE.B    (A0)+,D0           Padding character to send
  5487.           BEQ.S     RdParam9
  5488.           EORI.B    #64,D0
  5489.           MOVE.B    D0,OPadChar(A6)
  5490.  
  5491.           MOVE.B    (A0)+,D0           EOL character I must send
  5492.           BEQ.S     RdParam9
  5493.           SUB.B     D2,D0
  5494.           CMPI.B    #Asc_STx,D0        Valid range EOL character ?
  5495.           BCS.S     RdParam5           No, leave unchanged the default value
  5496.           CMPI.B    #Asc_US,D0         Valid range EOL character ?
  5497.           BHI.S     RdParam5           No, leave unchanged the default value
  5498.           MOVE.B    D0,OEOL(A6)
  5499.  
  5500. RdParam5  MOVE.B    (A0)+,D0           Incoming data quote character
  5501.           BEQ.S     RdParam9
  5502.           MOVE.B    D0,ICtlQuot(A6)
  5503.  
  5504.           MOVE.B    (A0)+,D0           8th bit quote character
  5505.           BEQ.S     RdParam9
  5506.           MOVE.B    D0,Bit8Quot(A6)
  5507.           CMPI.B    #'Y',D0            If flag off, then turn it on ...
  5508.           BNE.S     RdParam6           ... if other side has asked us to
  5509.           OR.B      Parity(A6),D1      ... or if we need it on
  5510.           BEQ.S     RdParam7
  5511.           ST        Bit8Flag(A6)
  5512.           MOVE.B    #My8BQuot,Bit8Quot(A6)
  5513.           BRA.S     RdParam7
  5514. RdParam6  BSR       ChkQuot
  5515.           MOVE.B    D0,Bit8Flag(A6)
  5516.  
  5517. RdParam7  MOVE.B    (A0)+,D0           Block check type
  5518.           BEQ.S     RdParam9
  5519.           SUBI.B    #'0',D0            Range adjust
  5520.           CMPI.B    #1,D0              Less than 1 ?
  5521.           BCS.S     RdParam8           Yes, invalid
  5522.           CMPI.B    #3,D0              Greater than 3 ?
  5523.           BHI.S     RdParam8           Yes, invalid
  5524.           MOVE.B    D0,BlChkRq(A6)     Ok, store block check type requested
  5525.  
  5526. RdParam8  MOVE.B    (A0)+,D0           Repeat prefix
  5527.           BEQ.S     RdParam9
  5528.           MOVE.B    D0,ReptQuot(A6)
  5529.           BSR       ChkQuot
  5530.           MOVE.B    D0,ReptFlag(A6)
  5531. RdParam9  RTS
  5532.  
  5533. ******************************** Check1 *******************************ok
  5534. *                                                                     *
  5535. *  Perform a type 1 block check.                                      *
  5536. *                                                                     *
  5537. *         Entry conditions : A0.L pointer to string buffer            *
  5538. *                                                                     *
  5539. *         Exit  conditions : D0.B type 1 block check                  *
  5540. *                                                                     *
  5541. ***********************************************************************
  5542. Check1:   MOVE.W    D1,-(A7)           Save working register
  5543.           BSR       Check2             Compute numeric sum
  5544.           MOVE.W    D0,D1              Compute a type 1 checksum
  5545.           ANDI.W    #192,D1
  5546.           LSR.W     #6,D1
  5547.           ADD.W     D1,D0
  5548.           ANDI.W    #63,D0
  5549.           MOVE.W    (A7)+,D1           Restore working register
  5550.           RTS
  5551.  
  5552. ******************************** Check2 *******************************ok
  5553. *                                                                     *
  5554. *  Perform a type 2 block check.                                      *
  5555. *                                                                     *
  5556. *         Entry conditions : A0.L pointer to string buffer            *
  5557. *                                                                     *
  5558. *         Exit  conditions : D0.W type 2 block check (numeric sum).   *
  5559. *                                                                     *
  5560. ***********************************************************************
  5561. Check2:   MOVE.W    D1,-(A7)           Save working register
  5562.           CLR.W     D1                 Clear the sum register
  5563.           CLR.W     D0
  5564. Check21   MOVE.B    (A0)+,D0           Get a character
  5565.           BEQ.S     Check22            Exit if EOL
  5566.           BSR       HndlPar            Handle parity
  5567.           ADD.W     D0,D1              Sum
  5568.           BRA.S     Check21            Repeat until EOL
  5569. Check22   MOVE.W    D1,D0              Return numeric sum
  5570.           MOVE.W    (A7)+,D1           Restore working register
  5571.           RTS
  5572.  
  5573. ******************************** Check3 *******************************ok
  5574. *                                                                     *
  5575. *  Perform a type 3 block check, calculates the 16-bit CRC using a    *
  5576. *  byte oriented tableless algorithm invented by Andy Lowry from      *
  5577. *  Columbia University. The magic number $1081 is derived from the    *
  5578. *  CRC-CCITT polynomial x^16+x^12+x^5+1.                              *
  5579. *                                                                     *
  5580. *         Entry conditions : A0.L pointer to string buffer            *
  5581. *                                                                     *
  5582. *         Exit  conditions : D0.L type 3 block check (CRC-CCITT).     *
  5583. *                                                                     *
  5584. ***********************************************************************
  5585. Check3:   MOVEM.L   D1-D3,-(A7)        Save working registers
  5586.           CLR.L     D1                 Clear character register
  5587.           CLR.L     D2                 Clear CRC register
  5588. Check31   MOVE.B    (A0)+,D0           Get a character
  5589.           BEQ.S     Check32            Null, end of string buffer
  5590.           BSR       HndlPar            Remove parity bit if necessary
  5591.           MOVE.B    D0,D1              Load the character register
  5592.           MOVE.L    D1,D3              Low order nibble
  5593.           EOR.L     D2,D3
  5594.           MOVEQ     #$0F,D0
  5595.           AND.L     D0,D3
  5596.           ASR.L     #4,D2
  5597.           MULU      #$1081,D3
  5598.           EOR.L     D3,D2
  5599.           MOVE.L    D1,D3              High order nibble
  5600.           LSR.L     #4,D3
  5601.           EOR.L     D2,D3
  5602.           MOVEQ     #$0F,D0
  5603.           AND.L     D0,D3
  5604.           ASR.L     #4,D2
  5605.           MULU      #$1081,D3
  5606.           EOR.L     D3,D2
  5607.           BRA.S     Check31            Repeat until end of string buffer
  5608. Check32   MOVE.L    D2,D0              Return CRC-CCITT
  5609.           MOVEM.L   (A7)+,D1-D3        Restore working registers
  5610.           RTS
  5611.  
  5612. ******************************** BumpPckN *****************************ok
  5613. *                                                                     *
  5614. *  Bump packet counters.                                              *
  5615. *                                                                     *
  5616. *         Entry conditions : none                                     *
  5617. *                                                                     *
  5618. *         Exit  conditions : none                                     *
  5619. *                                                                     *
  5620. ***********************************************************************
  5621. BumpPckN: MOVE.B    PackNum(A6),PrevPckN(A6) Save previous packet number
  5622.           MOVE.B    NextPckN(A6),PackNum(A6) Update current packet number
  5623.           ADDQ.B    #1,NextPckN(A6)    Increment next packet number
  5624.           ANDI.B    #63,NextPckN(A6)   Modulo 64
  5625.           RTS
  5626.  
  5627. *********************************** CpStrLn ***************************ok
  5628. *                                                                     *
  5629. *  Copy a null terminated string to a buffer adding a leading         *
  5630. *  encoded character count.                                           *
  5631. *                                                                     *
  5632. *         Entry conditions : A0.L source string buffer address        *
  5633. *                            A1.L target buffer address               *
  5634. *                                                                     *
  5635. *         Exit  conditions : A1.L target buffer next char address     *
  5636. *                            D0.L destroyed                           *
  5637. *                            D1.B destroyed                           *
  5638. *                                                                     *
  5639. ***********************************************************************
  5640. CpStrLn:  MOVEQ     #0,D0              Preset the counter/index register
  5641. CpStrLn1  MOVE.B    (A0)+,1(A1,D0.W)   Move a character
  5642.           BEQ.S     CpStrLn2           Exit on end of string
  5643.           ADDQ.W    #1,D0              Increment the counter/index register
  5644.           BRA.S     CpStrLn1           Loop for all characters
  5645. CpStrLn2  MOVE.B    D0,D1              Get the length
  5646.           BEQ.S     CpStrLn3           Return if source was null
  5647.           ADDI.B    #32,D1             Encode length
  5648.           MOVE.B    D1,(A1)            Write it on the first target buffer byte
  5649.           LEA       1(A1,D0.W),A1      Address of next available buffer byte
  5650. CpStrLn3  RTS
  5651.  
  5652. ******************************** ChkQuot ******************************ok
  5653. *                                                                     *
  5654. *  Check if a character is a valid quote.                             *
  5655. *                                                                     *
  5656. *         Entry conditions : D0.B character to check                  *
  5657. *                                                                     *
  5658. *         Exit  conditions : D0.B completion code                     *
  5659. *                                                                     *
  5660. ***********************************************************************
  5661. ChkQuot   CMPI.B    #'!',D0
  5662.           BCS.S     ChkQuot2
  5663.           CMPI.B    #'>',D0
  5664.           BLS.S     ChkQuot1
  5665.           CMPI.B    #'`',D0
  5666.           BCS.S     ChkQuot2
  5667.           CMPI.B    #$7E,D0
  5668. ChkQuot1  SLS       D0
  5669.           RTS
  5670. ChkQuot2  SF        D0
  5671.           RTS
  5672.  
  5673.           ends
  5674.           END
  5675. <<< k6optf.asm >>>
  5676.           nam       Kermit68K
  5677.           ttl       Protocol subroutines module
  5678.  
  5679. *         Kermit68K: source file K68PTF
  5680. *
  5681. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  5682. * Bologna University, Physics Department, July 1987.
  5683. *
  5684. * All rights reserved to Bologna University, Italy.
  5685. *
  5686. * Permission is granted to any individual or institution
  5687. * to use, copy, or redistribute this software so long as
  5688. * it  is not  sold for  profit, provided  this copyright
  5689. * notice is retained.
  5690. *
  5691. * Modification History:
  5692. *
  5693. * Version  Date    Who              Comments
  5694. *
  5695. * 1.0.00   870701  Roberto Bagnara  First official release
  5696.  
  5697.           use       DefsFile
  5698.  
  5699. Edition   equ       0
  5700.           psect     K68ProtoFuncs,0,0,Edition,0,0
  5701.  
  5702. ******************************** NextFil ******************************ok
  5703. *                                                                     *
  5704. *  Try to get the next file name copying it to FilName.               *
  5705. *                                                                     *
  5706. *         Entry conditions : none                                     *
  5707. *                                                                     *
  5708. *         Exit  conditions : D0.B completion code                     *
  5709. *                            A0.L destroyed                           *
  5710. *                                                                     *
  5711. ***********************************************************************
  5712. NextFil:  TST.B     CtlZSeen(A6)       Interrupt flag setted ?
  5713.           BNE.S     NextFil2           Yes, return with bad completion code
  5714. NextFil1  LEA       FilName(A6),A0     Points to file name target string
  5715.           BSR       GetNxtF            Try to get the next file name
  5716.           TST.B     D0                 Check the completion code
  5717.           BEQ.S     NextFil2           No files, return with bad cc
  5718.           BSR       ChkInpF            Check if file is readable
  5719.           TST.B     D0                 Ok ?
  5720.           BEQ.S     NextFil3           Yes, return this
  5721.           MOVEQ     #FlSkippd,D0       No, notify that we are skipping it
  5722.           BSR       Screen
  5723.           BRA.S     NextFil1           Try another
  5724. NextFil2  SF        D0                 Set a bad completion code
  5725.           RTS
  5726. NextFil3  ST        D0
  5727.           RTS
  5728.  
  5729. ******************************** SndPack ******************************ok
  5730. *                                                                     *
  5731. *  Send a packet.                                                     *
  5732. *                                                                     *
  5733. *         Entry conditions : D1.B packet type                         *
  5734. *                            D2.B packet number                       *
  5735. *                            D3.B packet length                       *
  5736. *                                                                     *
  5737. *         Exit  conditions : D4.W destroyed                           *
  5738. *                            D5.L destroyed                           *
  5739. *                            A0.L destroyed                           *
  5740. *                            A1.L destroyed                           *
  5741. *                                                                     *
  5742. ***********************************************************************
  5743. SndPack:  LEA       SendBuf(A6),A1     Packet buffer start
  5744.           MOVEQ     #32,D5             Load register for quick addition
  5745.  
  5746.           MOVE.B    OStPckCh(A6),(A1)+ Packet marker
  5747.  
  5748.           MOVE.B    D3,D0              Packet length
  5749.           ADDQ.B    #2,D0              Add 2 + block_check_type to packet ...
  5750.           ADD.B     BlChkUs(A6),D0     length to obtain the character count
  5751.           ADD.B     D5,D0              and convert it into a printable character
  5752.           MOVE.B    D0,(A1)+           Send the character count
  5753.  
  5754.           ADD.B     D5,D2              Make the packet number printable
  5755.           MOVE.B    D2,(A1)+           Send the packet number
  5756.  
  5757.           MOVE.B    D1,(A1)+           Send the packet type
  5758.           MOVE.B    D1,SendType(A6)    And save it for echos removal
  5759.  
  5760.           LEA       DataBuf(A6),A0     Pointer to data buffer
  5761.           CLR.W     D0                 Clear the counter register
  5762.           MOVE.B    D3,D0              Data length
  5763.           BRA.S     SndPack2           Loop for all data characters
  5764. SndPack1  MOVE.B    (A0)+,(A1)+        Get a character and put it in the packet
  5765. SndPack2  DBF       D0,SndPack1        Repeat
  5766.  
  5767.           CLR.B     (A1)               Mark end for block check
  5768.  
  5769.           LEA       SendBuf+1(A6),A0   First char for checksum computation
  5770.           MOVE.B    BlChkUs(A6),D0     Block check type in use
  5771.           SUBQ.B    #1,D0              Type 1 block check ?
  5772.           BNE.S     SndPack3           No, try another
  5773.           BSR       Check1             Yes, compute it
  5774.           ADD.B     D5,D0              Convert the checksum into printable
  5775.           MOVE.B    D0,(A1)+           Send it
  5776.           BRA.S     SndPack5           Join common part
  5777.  
  5778. SndPack3  SUBQ.B    #1,D0              Type 2 block check ?
  5779.           BNE.S     SndPack4           No, type 3 block check
  5780.           BSR       Check2             Yes, compute it
  5781.           MOVE.B    D0,D4              Save the lower portion of the result
  5782.           LSR.W     #6,D0              Process bits 6 --> 11, right adjusting
  5783.           ANDI.B    #$3F,D0            Mask extra bits
  5784.           ADD.B     D5,D0              Conversion into a printable character
  5785.           MOVE.B    D0,(A1)+           Send the first character
  5786.           MOVE.B    D4,D0              Reload the copy
  5787.           ANDI.B    #$3F,D0            Now bits 0 --> 5
  5788.           ADD.B     D5,D0              Conversion into a printable character
  5789.           MOVE.B    D0,(A1)+           Send the second character
  5790.           BRA.S     SndPack5           Join common part
  5791.  
  5792. SndPack4  BSR       Check3             Compute a type 3 block check
  5793.           MOVE.W    D0,D4              Make a copy of the result
  5794.           LSR.W     #8,D0              Process bits 12 --> 15, right adjusting
  5795.           LSR.W     #4,D0              Right adjusting
  5796.           ADD.B     D5,D0              Conversion into a printable character
  5797.           MOVE.B    D0,(A1)+           Send the first character
  5798.           MOVE.W    D4,D0              Reload the copy
  5799.           LSR.W     #6,D0              Now process bits 6 --> 11, right adjust
  5800.           ANDI.B    #$3F,D0            Mask extra bits
  5801.           ADD.B     D5,D0              Conversion into a printable character
  5802.           MOVE.B    D0,(A1)+           Send the second character
  5803.           MOVE.B    D4,D0              Reload the lower portion of the result
  5804.           ANDI.B    #$3F,D0            Now bits 0 --> 5
  5805.           ADD.B     D5,D0              Conversion into a printable character
  5806.           MOVE.B    D0,(A1)+           Send the third character
  5807.  
  5808. SndPack5  MOVE.B    OEOL(A6),(A1)+     Extra-packet line terminator
  5809.           CLR.B     (A1)               End-Of-Buffer marker
  5810.           BSR       TxPackt            Transmit the packet now prepared
  5811.           MOVEQ     #PackType,D0       Display the packet type on the screen
  5812.           BSR       Screen
  5813.           RTS
  5814.  
  5815. ******************************** RdPack *******************************ok
  5816. *                                                                     *
  5817. *  Attempts to read a packet.                                         *
  5818. *                                                                     *
  5819. *         Entry conditions : none                                     *
  5820. *                                                                     *
  5821. *         Exit  conditions : D1.B packet type or pseudo-type          *
  5822. *                            D2.B packet number                       *
  5823. *                            D3.B packet length                       *
  5824. *                            D5.L destroyed                           *
  5825. *                            D6.L destroyed                           *
  5826. *                            A0.L destroyed                           *
  5827. *                            A1.L destroyed                           *
  5828. *                            A2.L destroyed                           *
  5829. *                                                                     *
  5830. ***********************************************************************
  5831. RdPack:   MOVE.L    D4,-(A7)           Save working register
  5832.           SUBQ.L    #4,A7              Allocate some space on the stack
  5833.           MOVEQ     #3-1,D6            Try 3 times to get a line that has
  5834. RdPack1   BSR       InpLine            a start-of-packet char in it
  5835.           TST.B     D1                 Check InpLine completion code
  5836.           BEQ       RdPack16           Failed, return a timeout pseudo-packet
  5837. *                                      Ok, search the start-of-packet char
  5838. RdPack2   LEA       RecBuf(A6),A0      Pointer to receive buffer
  5839.           CLR.W     D1                 Clear the character counter
  5840. RdPack3   MOVE.B    (A0)+,D2           Get a character
  5841.           CMP.B     IStPckCh(A6),D2    Start-of-packet char ?
  5842.           BEQ.S     RdPack4            Yes, first goal satisfied !
  5843.           ADDQ.W    #1,D1              Increment character counter
  5844.           CMP.W     D0,D1              Last character ?
  5845.           BNE.S     RdPack3            No, try the next
  5846.           DBF       D6,RdPack1         Repeat max 3 times
  5847.           MOVEQ     #'Q',D1            Failed, return a garbage pseudo-packet
  5848.           BRA       RdPack19
  5849.  
  5850. RdPack4   MOVEQ     #32,D6             Load for quick addition/subtraction
  5851. RdPack5   MOVEA.L   A0,A1              Remember where packet started
  5852.  
  5853.           MOVE.B    (A0)+,D0           Get character
  5854.           BEQ       RdPack15           EOL, garbled packet
  5855.           CMP.B     IStPckCh(A6),D0    Start-of-packet char ?
  5856.           BEQ.S     RdPack5            Yes, resynchronize
  5857.           MOVE.B    D0,D3              This is the packet length
  5858.           SUB.B     D6,D3              Convert it to numeric
  5859.  
  5860.           MOVE.B    (A0)+,D0           Get character
  5861.           BEQ       RdPack15           EOL, garbled packet
  5862.           CMP.B     IStPckCh(A6),D0    Start-of-packet char ?
  5863.           BEQ.S     RdPack5            Yes, resynchronize
  5864.           MOVE.B    D0,D2              This is the packet number
  5865.           SUB.B     D6,D2              Convert it to numeric
  5866.  
  5867.           MOVE.B    (A0)+,D0           Get character
  5868.           BEQ       RdPack15           EOL, garbled packet
  5869.           CMP.B     IStPckCh(A6),D0    Start-of-packet char ?
  5870.           BEQ.S     RdPack5            Yes, resynchronize
  5871.           MOVE.B    D0,D1              This is the packet type
  5872.  
  5873. *                                      Heuristics for syncing block check type
  5874.  
  5875.           MOVEQ     #1,D5              Type 1 block check by default
  5876.           CMPI.B    #'S',D1            Send-Init packet ?
  5877.           BEQ.S     RdPack7            Yes, type 1 block check
  5878.           CMPI.B    #'I',D1            Initialize packet ?
  5879.           BEQ.S     RdPack7            Yes, type 1 block check
  5880.           CMPI.B    #'N',D1            NAK packet ?
  5881.           BNE.S     RdPack6            No
  5882.           MOVE.B    D3,D5              Yes, block check type is
  5883.           SUBQ.B    #2,D5              bct = packet_length - 2
  5884.           BRA.S     RdPack7
  5885. RdPack6   MOVE.B    BlChkUs(A6),D5     Otherwise block check type in use
  5886. RdPack7   SUB.B     D5,D3              Now compute data length by subtracting
  5887.           SUBQ.B    #2,D3              (block_check_type + 2)
  5888.  
  5889.           LEA       DataBuf(A6),A2     Pointer to data buffer
  5890.           CLR.W     D4                 Clear the counter register
  5891.           MOVE.B    D3,D4              Data length
  5892.           BRA.S     RdPack9            Read data, if any
  5893. RdPack8   MOVE.B    (A0)+,D0           Get character
  5894.           BEQ       RdPack15           EOL, garbled packet
  5895.           CMP.B     IStPckCh(A6),D0    Start-of-packet char ?
  5896.           BEQ.S     RdPack5            Yes, resynchronize
  5897.           MOVE.B    D0,(A2)+           Write character to data buffer
  5898. RdPack9   DBF       D4,RdPack8
  5899.           CLR.B     (A2)+              Mark the end of buffer
  5900.  
  5901.           MOVEA.L   A7,A2              Point to temporary storage space
  5902.           CLR.W     D4                 Clear the counter register
  5903.           MOVE.B    D5,D4              Block check type
  5904.           BRA.S     RdPack11           Get the block check
  5905. RdPack10  MOVE.B    (A0),D0            Get character
  5906.           BEQ       RdPack15           EOL, garbled packet
  5907.           CMP.B     IStPckCh(A6),D0    Start-of-packet char ?
  5908.           BEQ       RdPack5            Yes, resynchronize
  5909.           MOVE.B    D0,(A2)+           Store the block check character
  5910.           CLR.B     (A0)+              Nullify checksum characters in RecBuf
  5911. RdPack11  DBF       D4,RdPack10        Repeat
  5912.  
  5913. *                                      Got packet, now check the block check
  5914.  
  5915.           MOVEA.L   A1,A0              Pointer to packet start
  5916.           MOVEA.L   A7,A1              Point to received block check characters
  5917.  
  5918.           SUBQ.B    #1,D5              Type 1 block check ?
  5919.           BEQ.S     RdPack13           Yes, compute it
  5920.           SUBQ.B    #1,D5              Type 2 block check ?
  5921.           BEQ.S     RdPack12           Yes, compute it
  5922.           SUBQ.B    #1,D5              Type 3 block check ?
  5923.           BNE.S     RdPack15           No, return garbage pseudo-packet
  5924. *                                      Yes, compute it, (fall thru)
  5925.  
  5926.           BSR       Check3             Compute
  5927.           MOVEQ     #$3F,D4            Process bits 0 --> 5
  5928.           AND.B     D0,D4              Move and mask extra bits
  5929.           ADD.B     D6,D4              Conversion into a printable character
  5930.           CMP.B     2(A1),D4           Ok, now compare, third byte
  5931.           BNE       RdPack15           Compare fails, garbled packet
  5932.           LSR.W     #6,D0              Now process bits 6 --> 11, right adjust
  5933.           MOVEQ     #$3F,D4            To mask extra bits
  5934.           AND.B     D0,D4              Move and mask extra bits
  5935.           ADD.B     D6,D4              Conversion into a printable character
  5936.           CMP.B     1(A1),D4           Compare the second byte
  5937.           BNE       RdPack15           Compare fails, garbled packet
  5938.           LSR.W     #6,D0              Process bits 12 --> 15, right adjusting
  5939.           ADD.B     D6,D0              Conversion into a printable character
  5940.           CMP.B     (A1),D0            Compare the first byte
  5941.           BRA.S     RdPack14           Join common part
  5942.  
  5943. RdPack12  BSR       Check2             Compute
  5944.           MOVEQ     #$3F,D4            Process bits 0 --> 5
  5945.           AND.B     D0,D4              Move and mask extra bits
  5946.           ADD.B     D6,D4              Conversion into a printable character
  5947.           CMP.B     1(A1),D4           Ok, now compare, second byte
  5948.           BNE       RdPack15           Compare fails, garbled packet
  5949.           LSR.W     #6,D0              Process bits 6 --> 11, right adjusting
  5950.           ANDI.B    #$3F,D0            Mask extra bits
  5951.           ADD.B     D6,D0              Conversion into a printable character
  5952.           CMP.B     (A1),D0            Compare the first byte
  5953.           BRA.S     RdPack14           Join common part
  5954.  
  5955. RdPack13  BSR       Check1             Compute
  5956.           ADD.B     D6,D0              Convert it to a printable character
  5957.           CMP.B     (A1),D0            Compare it with the received block check
  5958. *                                      Join common part, (fall thru)
  5959.  
  5960. RdPack14  BEQ.S     RdPack17           If compare succeeds return packet type
  5961. RdPack15  MOVEQ     #'Q',D1            Return a garbage pseudo-packet
  5962.           BRA.S     RdPack18
  5963. RdPack16  MOVEQ     #'T',D1            Return a timeout pseudo-packet
  5964.           BRA.S     RdPack18
  5965. RdPack17  ADDQ.L    #1,PcksRecd(A6)    Increment packets received this trans
  5966.           ADDQ.L    #1,TPckRecd(A6)    Increment total packets received
  5967. RdPack18  MOVEQ     #PackType,D0       We want display the packet type
  5968.           BSR       Screen             Update the screen, if necessary
  5969. RdPack19  ADDQ.L    #4,A7              Deallocate space on the stack
  5970.           MOVE.L    (A7)+,D4           Restore working register
  5971.           RTS
  5972.  
  5973. ******************************** InpPack ******************************ok
  5974. *                                                                     *
  5975. *  Loop until the expected packet arrives or the maximum tries number *
  5976. *  exceeded. If a packet arrives with the same type of the last       *
  5977. *  packet sent, it's treated as an echo and another one is expected.  *
  5978. *  If the previous packet arrives again, the last packet is resent    *
  5979. *  and a new one is expected to come in.                              *
  5980. *                                                                     *
  5981. *         Entry conditions : none                                     *
  5982. *                                                                     *
  5983. *         Exit  conditions : D1.B packet type or pseudo-type          *
  5984. *                            D2.B packet number                       *
  5985. *                            D3.B packet length                       *
  5986. *                            D4.B destroyed                           *
  5987. *                                                                     *
  5988. ***********************************************************************
  5989. InpPack:  CLR.B     D4                 Clear the retry counter
  5990. InpPack1  BSR       ChekInt            Check for console interrupts
  5991.           BSR       RdPack             Try to read a packet
  5992.           CMP.B     SendType(A6),D1    It's the same just sent ?
  5993.           BNE.S     InpPack2           No
  5994.           BSR       RdPack             Yes, it's an echo, read another
  5995.  
  5996. InpPack2  CMP.B     PrevPckN(A6),D2    Previous packet ?
  5997.           BEQ.S     InpPack4           Yes, keep trying
  5998.           CMPI.B    #'T',D1            Timeout pseudo-packet ?
  5999.           BEQ.S     InpPack4           Yes, keep trying
  6000.           CMPI.B    #'Q',D1            Garbage pseudo-packet ?
  6001.           BEQ.S     InpPack4           Yes, keep trying
  6002.           CMPI.B    #'N',D1            NAK packet ?
  6003.           BNE.S     InpPack3           No, return the received packet
  6004.           ADDQ.L    #1,NAKsRecd(A6)    Yes, increment NAKs received counter
  6005.           ADDQ.L    #1,TNAKRecd(A6)    Increment total NAKs received counter
  6006.           CMP.B     NextPckN(A6),D2    It's a NAK for the next packet ?
  6007.           BNE.S     InpPack4           No
  6008.           MOVEQ     #'Y',D1            Yes, it's like an ACK ...
  6009.           MOVE.B    PackNum(A6),D2     ... for current packet
  6010. InpPack3  MOVE.B    D1,D4              Save this for parameter passing
  6011.           MOVEQ     #ClrInpBf,D0       Clear the input buffer ...
  6012.           MOVEQ     #HostLine,D1       ... of the host line
  6013.           BSR       ChanCtrl           Call the channel control routine
  6014.           MOVE.B    D4,D1              Restore the packet (pseudo) type
  6015.           RTS
  6016.  
  6017. InpPack4  CMP.B     Retry(A6),D4       Too many tries ?
  6018.           BCC.S     InpPack3           Yes, return
  6019.           BSR       Resend             No, send last packet again
  6020.           ADDQ.B    #1,D4              Increment the retry counter
  6021.           BRA.S     InpPack1           Stay in loop
  6022.  
  6023. ********************************* GetPack *****************************ok
  6024. *                                                                     *
  6025. *  Gets characters from the current source, file or memory string.    *
  6026. *  Encodes the data into the packet, filling the packet optimally.    *
  6027. *  Returns TRUE on success with Size containing the number of         *
  6028. *  characters in DataBuf, or FALSE if DataBuf is empty (Size = 0,     *
  6029. *  EOF for file, end of string for memory string).                    *
  6030. *                                                                     *
  6031. *         Entry conditions : none                                     *
  6032. *                                                                     *
  6033. *         Exit  conditions : D0.B completion code                     *
  6034. *                                                                     *
  6035. ***********************************************************************
  6036. GetPack:  MOVEM.L   A0/D1-D2,-(A7)     Save working registers
  6037.           LEA       DataBuf(A6),A0     Pointer to data buffer
  6038.           MOVEQ     #0,D2              Clear index register
  6039.           TST.B     First(A6)          First time ?
  6040.           BLT.S     GetPack1           No, EOF from last time
  6041.           BEQ.S     GetPack2           No, input in progress
  6042.           CLR.B     First(A6)          Yes, remember
  6043.           BSR       GetChx             Get first character of file
  6044.           MOVE.B    D0,Current(A6)     Save current character
  6045.           TST.B     D1                 Null file ?
  6046.           BNE.S     GetPack3           No
  6047. GetPack1  MOVE.B    #1,First(A6)       Yes, setup for next time
  6048.           SF        D0                 Return negative completion code
  6049.           BRA.S     GetPack9
  6050.  
  6051. GetPack2  MOVE.B    LeftOver(A6,D2.W),(A0,D2.W) Do any left-overs
  6052.           BEQ.S     GetPack3           Exit if null
  6053.           ADDQ.W    #1,D2              Increment index
  6054.           BRA.S     GetPack2           Repeat
  6055.  
  6056. GetPack3  CLR.B     LeftOver(A6)       Nullify the left-overs buffer
  6057.           CLR.B     ReptCnt(A6)        Clear out any old repeat count
  6058. GetPack4  TST.B     First(A6)          EOF reached ?
  6059.           BLT.S     GetPack8           Yes, return partially (?) filled packet
  6060.           BSR       GetChx             Get a character from file or memory
  6061.           MOVE.B    D0,Next(A6)        Save next character for lookahead
  6062.           TST.B     D1                 EOF ?
  6063.           BNE.S     GetPack5           No
  6064.           MOVE.B    #-1,First(A6)      Yes, flag it for next time
  6065. GetPack5  MOVE.B    D2,OldSize(A6)     Remember current position
  6066.           MOVE.B    Current(A6),D0     Get the current character
  6067.           BSR       Encode             Encode the current character
  6068.           MOVE.B    Next(A6),Current(A6) Next is now current
  6069.           CMP.B     OMPckSiz(A6),D2    Check packet size
  6070.           BLT.S     GetPack4           Keep filling
  6071.           BEQ.S     GetPack8           Return exactly full packet
  6072.           MOVEQ     #0,D0              Clear for indexing the left-overs buffer
  6073.           MOVEQ     #0,D1              Clear for indexing the data buffer
  6074.           MOVE.B    OldSize(A6),D1     Set up the data buffer index
  6075. GetPack6  MOVE.B    (A0,D1.W),LeftOver(A6,D0.W) Save some for next time
  6076.           BEQ.S     GetPack7           Exit if null
  6077.           ADDQ.W    #1,D0              Increment the first index
  6078.           ADDQ.W    #1,D1              Increment the second index
  6079.           BRA.S     GetPack6           Repeat
  6080. GetPack7  MOVE.B    OldSize(A6),D2     Size of the truncated packet
  6081. GetPack8  ST        D0                 Provide positive completion code
  6082. GetPack9  MOVE.B    D2,Size(A6)
  6083.           CLR.B     (A0,D2.W)          Write buffer terminator
  6084.           MOVEM.L   (A7)+,A0/D1-D2     Restore working registers
  6085.           RTS
  6086.  
  6087. ********************************* EncStrng ****************************ok
  6088. *                                                                     *
  6089. *  Encode a string from memory.                                       *
  6090. *                                                                     *
  6091. *         Entry conditions : A0.L memory string start address         *
  6092. *                                                                     *
  6093. *         Exit  conditions : A0.L memory string start address         *
  6094. *                                                                     *
  6095. ***********************************************************************
  6096. EncStrng: MOVE.B    MStrFlag(A6),-(A7) Save the old flag
  6097.           MOVE.L    MStrgPnt(A6),-(A7) Save the old pointer
  6098.           ST        MStrFlag(A6)       Say input from memory string
  6099.           MOVE.L    A0,MStrgPnt(A6)    Point to the memory string
  6100.           MOVE.B    #1,First(A6)       Initialize character lookahead
  6101.           BSR       GetPack            Get a packet from the string
  6102.           MOVE.L    (A7)+,MStrgPnt(A6) Restore the old pointer
  6103.           MOVE.B    (A7)+,MStrFlag(A6) Restore the old flag
  6104.           MOVE.B    #1,First(A6)       Re-initialize character lookahead
  6105.           RTS
  6106.  
  6107. ********************************* GetChx ******************************ok
  6108. *                                                                     *
  6109. *  Try to get the next character from file or memory string.          *
  6110. *  Returns TRUE on success with D0.B set to the character, or FALSE   *
  6111. *  on failure (EOF for file, enf of string for memory string).        *
  6112. *                                                                     *
  6113. *         Entry conditions : none                                     *
  6114. *                                                                     *
  6115. *         Exit  conditions : D0.B character (if any)                  *
  6116. *                            D1.B completion code                     *
  6117. *                                                                     *
  6118. ***********************************************************************
  6119. GetChx    MOVE.L    A0,-(A7)           Save working register
  6120.           TST.B     LFSave(A6)         Do we have a linefeed saved ?
  6121.           BEQ.S     GetChx1            No
  6122.           SF        LFSave(A6)         Yes, nullify the flag
  6123.           MOVEQ     #Asc_LF,D0         Return the saved LF
  6124.           ST        D1                 Also return a positive cc
  6125.           BRA.S     GetChx4
  6126. GetChx1   TST.B     MStrFlag(A6)       Try to get the next character, memory ?
  6127.           BEQ.S     GetChx2            No, get it from current file
  6128.           MOVEA.L   MStrgPnt(A6),A0    Load pointer to the memory string
  6129.           MOVE.B    (A0)+,D0           Get a character
  6130.           SNE       D1                 Set cc to false if end of string reached
  6131.           MOVE.L    A0,MStrgPnt(A6)    Save pointer for next time
  6132.           BRA.S     GetChx3            Join the common part
  6133. GetChx2   MOVEQ     #IOFile,D1         Get a char from the the current file
  6134.           BSR       InpChar
  6135.           TST.B     D1                 Check the returned completion code
  6136.           SEQ       D1                 Set completion code accordingly
  6137. GetChx3   TST.B     D1                 Have we got a character ?
  6138.           BEQ.S     GetChx4            No, return
  6139.           ADDQ.L    #1,DChsSent(A6)    Yes, count it
  6140.           ADDQ.L    #1,TDChSent(A6)
  6141.           TST.B     Binary(A6)         Are we in binary mode ?
  6142.           BNE.S     GetChx4            Yes, nl-CRLF mapping not needed
  6143.           CMPI.B    #NewLinCh,D0       No, newline character ?
  6144.           BNE.S     GetChx4            No
  6145.           ST        LFSave(A6)         Yes, remember a linefeed
  6146.           MOVEQ     #Asc_CR,D0         Return a carriage return
  6147. GetChx4   MOVE.L    (A7)+,A0           Restore working register
  6148.           RTS
  6149.  
  6150. ********************************* Resend ******************************ok
  6151. *                                                                     *
  6152. *  Resend the last packet sent (the one in SendBuf), if any, send     *
  6153. *  a NAK otherwise.                                                   *
  6154. *                                                                     *
  6155. *         Entry conditions : none                                     *
  6156. *                                                                     *
  6157. *         Exit  conditions : D0.L destroyed                           *
  6158. *                            D1.L destroyed                           *
  6159. *                                                                     *
  6160. ***********************************************************************
  6161. Resend:   MOVEQ     #ClrInpBf,D0       Clear the input buffer
  6162.           MOVEQ     #HostLine,D1       Host line channel
  6163.           BSR       ChanCtrl           Call the channel control routine
  6164.           TST.B     SendBuf(A6)        Send buffer empty ?
  6165.           BNE.S     Resend1            No, send last packet again
  6166.           BSR       SendNAK            Yes, send a NAK packet
  6167.           RTS
  6168. Resend1   BSR       TxPackt            Send the previous packet again
  6169.           MOVEQ     #PackType,D0       Update the screen
  6170.           MOVEQ     #'%',D1            This is the symbol for a resent packet
  6171.           BSR       Screen
  6172.           RTS
  6173.  
  6174. ******************************** SndEPack *****************************ok
  6175. *                                                                     *
  6176. *  Send an Error packet.                                              *
  6177. *                                                                     *
  6178. *         Entry conditions : A1.L point to the reason string          *
  6179. *                                                                     *
  6180. *         Exit  conditions : D0.L destroyed                           *
  6181. *                            D1.L destroyed                           *
  6182. *                            D2.B destroyed                           *
  6183. *                            D3.B destroyed                           *
  6184. *                            A0.L destroyed                           *
  6185. *                                                                     *
  6186. ***********************************************************************
  6187. SndEPack: MOVEA.L   A1,A0              Point to the reason string
  6188.           BSR       EncStrng           Encode it
  6189.           MOVEQ     #'E',D1            Error packet
  6190.           MOVE.B    PackNum(A6),D2     Packet number
  6191.           MOVE.B    Size(A6),D3        Packet length
  6192.           BSR       SndPack            OK, send now
  6193.           BSR       ClsInpF            Close the input file, if open
  6194.           ST        CtlZSeen(A6)       This is an interrupted file transfer
  6195.           BSR       ClsOutF            Close (and maybe delete) the output file
  6196.           MOVEQ     #TranCmpl,D0       Give transaction complete message
  6197.           BSR       Screen
  6198.           RTS
  6199.  
  6200. ********************************* SendACK *****************************ok
  6201. *                                                                     *
  6202. *  Send an empty ACK packet.                                          *
  6203. *                                                                     *
  6204. *         Entry conditions : none                                     *
  6205. *                                                                     *
  6206. *         Exit  conditions : D1.L destroyed                           *
  6207. *                            D2.B destroyed                           *
  6208. *                            D3.L destroyed                           *
  6209. *                                                                     *
  6210. ***********************************************************************
  6211. SendACK:  MOVEQ     #'Y',D1            ACK
  6212.           MOVE.B    PackNum(A6),D2     Packet number
  6213.           MOVEQ     #0,D3              Packet length (0, empty packet)
  6214.           BSR       SndPack            OK, send now
  6215.           BSR       BumpPckN           Bump packet number, modulo 64
  6216.           RTS
  6217.  
  6218. ********************************* SendNAK *****************************ok
  6219. *                                                                     *
  6220. *  Send a NAK packet (always empty).                                  *
  6221. *                                                                     *
  6222. *         Entry conditions : none                                     *
  6223. *                                                                     *
  6224. *         Exit  conditions : D1.L destroyed                           *
  6225. *                            D2.B destroyed                           *
  6226. *                            D3.L destroyed                           *
  6227. *                                                                     *
  6228. ***********************************************************************
  6229. SendNAK   MOVEQ     #'N',D1            NAK
  6230.           MOVE.B    PackNum(A6),D2     Packet number
  6231.           MOVEQ     #0,D3              Packet length (0, empty packet)
  6232.           BSR       SndPack            OK, send now
  6233.           ADDQ.L    #1,NAKsSent(A6)    Increment NAKs sent this transaction
  6234.           ADDQ.L    #1,TNAKSent(A6)    Increment total NAKs sent
  6235.           RTS
  6236.  
  6237.           ends
  6238.           END
  6239. <<< k6ostr.asm >>>
  6240.           nam       Kermit68K
  6241.           ttl       Character strings module
  6242.  
  6243. *         Kermit68K: source file K68STR
  6244. *
  6245. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  6246. * Bologna University, Physics Department, July 1987.
  6247. *
  6248. * All rights reserved to Bologna University, Italy.
  6249. *
  6250. * Permission is granted to any individual or institution
  6251. * to use, copy, or redistribute this software so long as
  6252. * it  is not  sold for  profit, provided  this copyright
  6253. * notice is retained.
  6254. *
  6255. * Modification History:
  6256. *
  6257. * Version  Date    Who              Comments
  6258. *
  6259. * 1.0.00   870701  Roberto Bagnara  First official release
  6260.  
  6261.           use       DefsFile
  6262.  
  6263. Edition   equ       0
  6264.           psect     K68Strings,0,0,Edition,0,0
  6265.  
  6266. *** Strings from the K68SystemPart module ***
  6267.  
  6268. ConLinNm: DC.B      "/Term",Asc_Nul         Console line name
  6269. DefLinNm: DC.B      "/T1",Asc_Nul           Default line name for connect
  6270. DefPrmpt: DC.B      "Kermit68K> ",Asc_Nul   Default prompt string
  6271. InitFile: DC.B      "Kermit.ini",Asc_Nul    Init file name
  6272.  
  6273. *** Strings from the K68Commands module ***
  6274.  
  6275. StLnFStr: DC.B      "You must 'set line' before issuing this command"
  6276.           DC.B      Asc_CR,Asc_LF,Asc_Nul
  6277.  
  6278. NoCopStr: DC.B      "Can't copy file(s)",Asc_Nul
  6279. NoCWDStr: DC.B      "Can't change working directory",Asc_Nul
  6280. NoDelStr: DC.B      "Can't delete file(s)",Asc_Nul
  6281. NoDirStr: DC.B      "Can't list directory",Asc_Nul
  6282. NoPriStr: DC.B      "Can't print file(s)",Asc_Nul
  6283. NoRenStr: DC.B      "Can't rename file(s)",Asc_Nul
  6284. NoSpaStr: DC.B      "Can't show disk usage",Asc_Nul
  6285. NoTypStr: DC.B      "Can't type file(s)",Asc_Nul
  6286. NoSyCStr: DC.B      "Can't forward command to system",Asc_Nul
  6287.  
  6288. TFNDpStr: DC.B      "?Take files nested too deeply",Asc_Nul
  6289. MsFSpStr: DC.B      "?Missing file specification",Asc_Nul
  6290.  
  6291. KerCmStr: DC.B      Asc_LF,"Kermit68K commands:"
  6292.           DC.B      Asc_CR,Asc_LF,Asc_LF,Asc_Nul
  6293. MacCmStr: DC.B      Asc_LF,"User defined macros:"
  6294.           DC.B      Asc_CR,Asc_LF,Asc_LF,Asc_Nul
  6295. NoMacStr: DC.B      Asc_LF,"There are no user defined macros."
  6296.           DC.B      Asc_CR,Asc_LF,Asc_LF,Asc_Nul
  6297.  
  6298. MNstAStr: DC.B      "?Can't nest macro definitions",Asc_Nul
  6299. MsMcNStr: DC.B      "?Missing macro name",Asc_Nul
  6300. UnkMcStr: DC.B      "?Unknown macro",Asc_Nul
  6301.  
  6302. ConnStr1: DC.B      Asc_CR,Asc_LF
  6303.           DC.B      "Connecting thru ",Asc_Nul
  6304. ConnStr2: DC.B      Asc_CR,Asc_LF
  6305.           DC.B      "Connected thru ",Asc_Nul
  6306. ConnStr3: DC.B      ", speed ",Asc_Nul
  6307. ConnStr5: DC.B      Asc_CR,Asc_LF
  6308.           DC.B      "The escape character is ",Asc_Nul
  6309. ConnStr6: DC.B      ")",Asc_CR,Asc_LF
  6310.           DC.B      "Type the escape character followed by C to get"
  6311.           DC.B      Asc_CR,Asc_LF
  6312.           DC.B      "back, or followed by ? to see other options."
  6313.           DC.B      Asc_CR,Asc_LF,Asc_LF,Asc_Nul
  6314. ConnStr7: DC.B      Asc_CR,Asc_LF,Asc_LF
  6315.           DC.B      "Kermit68K disconnected."
  6316.           DC.B      Asc_CR,Asc_LF,Asc_Nul
  6317. ConnStr8: DC.B      Asc_CR,Asc_LF,Asc_LF
  6318.           DC.B      "C to close the connection, or:"
  6319.           DC.B      Asc_CR,Asc_LF
  6320.           DC.B      "  0 (zero) to send a NULL"
  6321.           DC.B      Asc_CR,Asc_LF
  6322.           DC.B      "  B to send a BREAK"
  6323.           DC.B      Asc_CR,Asc_LF
  6324.           DC.B      "  H to hangup and close connection"
  6325.           DC.B      Asc_CR,Asc_LF
  6326.           DC.B      "  S for status"
  6327.           DC.B      Asc_CR,Asc_LF
  6328.           DC.B      "  ? for help"
  6329.           DC.B      Asc_CR,Asc_LF
  6330.           DC.B      " escape character twice to send the escape character."
  6331.           DC.B      Asc_CR,Asc_LF,Asc_LF,Asc_Nul
  6332.  
  6333. StatStr1: DC.B      "Statistics                Transaction       Total"
  6334.           DC.B      Asc_CR,Asc_LF
  6335.           DC.B      " Characters sent         ",Asc_Nul
  6336. StatStr2: DC.B      " Data characters sent    ",Asc_Nul
  6337. StatStr3: DC.B      " NAKs received           ",Asc_Nul
  6338. StatStr4: DC.B      " Packets sent            ",Asc_Nul
  6339. StatStr5: DC.B      " Characters received     ",Asc_Nul
  6340. StatStr6: DC.B      " Data characters received",Asc_Nul
  6341. StatStr7: DC.B      " NAKs sent               ",Asc_Nul
  6342. StatStr8: DC.B      " Packets received        ",Asc_Nul
  6343.  
  6344. *** Strings from the K68Commands2 module ***
  6345.  
  6346. OpLnEStr: DC.B      "Can't open line",Asc_Nul
  6347. UnsBRStr: DC.B      "?Unsupported baud rate",Asc_Nul
  6348. SetCtStr: DC.B      "?Not in ASCII control range",Asc_Nul
  6349.  
  6350. *** Strings from the K68Commands3 module ***
  6351.  
  6352. Rm1FOStr: DC.B      "?A file specification is required"
  6353.           DC.B      Asc_CR,Asc_LF,Asc_Nul
  6354. Rm2FOStr: DC.B      "?Two file specifications are required"
  6355.           DC.B      Asc_CR,Asc_LF,Asc_Nul
  6356.  
  6357. VersStr:  DC.B      Asc_CR,Asc_LF
  6358.           DC.B      "Kermit68K version 1.0.00 from 01 July 1987"
  6359.           DC.B      Asc_CR,Asc_LF,Asc_LF
  6360.           DC.B      Asc_Nul
  6361.  
  6362. ShVerStr: DC.B      "Warning, this is a preliminary version, for any"
  6363.           DC.B      Asc_CR,Asc_LF
  6364.           DC.B      "problem or suggestion please contact the author:"
  6365.           DC.B      Asc_CR,Asc_LF,Asc_LF
  6366.           DC.B      "Roberto Bagnara        Bitnet address Bagnara@Iboinfn"
  6367.           DC.B      Asc_CR,Asc_LF
  6368.           DC.B      "Physics Department     DECnet address 39937::BAGNARA"
  6369.           DC.B      Asc_CR,Asc_LF
  6370.           DC.B      "Bologna University"
  6371.           DC.B      Asc_CR,Asc_LF,Asc_LF
  6372.           DC.B      "OS-9/68000 Modifications by:"
  6373.           DC.B      Asc_CR,Asc_LF
  6374.           DC.B      "Steve Williams         Arpanet address "
  6375.           DC.B      "stevew@sally.utexas.edu"
  6376.           DC.B      Asc_CR,Asc_LF,Asc_LF,Asc_Nul
  6377.  
  6378. ShPStr1:  DC.B      Asc_CR,Asc_LF
  6379.           DC.B      "Communications Parameters:"
  6380.           DC.B      Asc_CR,Asc_LF
  6381.           DC.B      " Line: ",Asc_Nul
  6382. ShPStr2:  DC.B      ", speed: ",Asc_Nul
  6383. ShPStr3:  DC.B      "unknown",Asc_Nul
  6384. ShPStr4:  DC.B      ", mode: ",Asc_Nul
  6385. ShPStr5:  DC.B      "local",Asc_Nul
  6386. ShPStr6:  DC.B      "remote",Asc_Nul
  6387. ShPStr7:  DC.B      Asc_CR,Asc_LF
  6388.           DC.B      " Parity: ",Asc_Nul
  6389. ShPStr8:  DC.B      "even",Asc_Nul
  6390. ShPStr9:  DC.B      "odd",Asc_Nul
  6391. ShPStr10: DC.B      "mark",Asc_Nul
  6392. ShPStr11: DC.B      "space",Asc_Nul
  6393. ShPStr12: DC.B      "none",Asc_Nul
  6394. ShPStr13: DC.B      ", duplex: ",Asc_Nul
  6395. ShPStr14: DC.B      "half, ",Asc_Nul
  6396. ShPStr15: DC.B      "full, ",Asc_Nul
  6397. ShPStr16: DC.B      "flow: ",Asc_Nul
  6398. ShPStr17: DC.B      "xon/xoff",Asc_Nul
  6399. ShPStr18: DC.B      ", handshake: ",Asc_Nul
  6400. ShPStr19: DC.B      Asc_CR,Asc_LF,Asc_LF
  6401.           DC.B      "Protocol Parameters:   Send    Receive",Asc_Nul
  6402. ShPStr20: DC.B      "    (* = override)",Asc_Nul
  6403. ShPStr21: DC.B      Asc_CR,Asc_LF," Timeout:      ",Asc_Nul
  6404. ShPStr22: DC.B      Asc_CR,Asc_LF," Padding:      ",Asc_Nul
  6405. ShPStr23: DC.B      Asc_CR,Asc_LF," Pad Character:",Asc_Nul
  6406. ShPStr24: DC.B      Asc_CR,Asc_LF," Packet Start: ",Asc_Nul
  6407. ShPStr25: DC.B      Asc_CR,Asc_LF," Packet End:   ",Asc_Nul
  6408. ShPStr26: DC.B      Asc_CR,Asc_LF," Packet Length:",Asc_Nul
  6409. ShPStr27: DC.B      Asc_CR,Asc_LF
  6410.           DC.B      Asc_CR,Asc_LF,"Block Check Type: ",Asc_Nul
  6411. ShPStr28: DC.B      ", Delay: ",Asc_Nul
  6412. ShPStr29: DC.B      Asc_CR,Asc_LF
  6413.           DC.B      "Retry Limits: Initial ",Asc_Nul
  6414. ShPStr30: DC.B      ", Normal ",Asc_Nul
  6415. ShPStr31: DC.B      Asc_CR,Asc_LF,"8th-Bit Prefix:      ",Asc_Nul
  6416. ShPStr32: DC.B      Asc_CR,Asc_LF,"Repeat-Count Prefix: ",Asc_Nul
  6417. ShPStr33: DC.B      Asc_CR,Asc_LF,Asc_LF
  6418.           DC.B      "File parameters:",Asc_CR,Asc_LF
  6419.           DC.B      " File Names:   ",Asc_Nul
  6420. ShPStr34: DC.B      "converted",Asc_Nul
  6421. ShPStr35: DC.B      "literal",Asc_Nul
  6422. ShPStr36: DC.B      Asc_CR,Asc_LF," File Type:    ",Asc_Nul
  6423. ShPStr37: DC.B      "binary",Asc_Nul
  6424. ShPStr38: DC.B      "text",Asc_Nul
  6425. ShPStr39: DC.B      Asc_CR,Asc_LF," File Warning: ",Asc_Nul
  6426. ShPStr40: DC.B      "on",Asc_Nul
  6427. ShPStr41: DC.B      "off",Asc_Nul
  6428. ShPStr42: DC.B      Asc_CR,Asc_LF," File Display: ",Asc_Nul
  6429. ShPStr43: DC.B      Asc_CR,Asc_LF,"Incomplete File Disposition: ",Asc_Nul
  6430. ShPStr44: DC.B      "keep",Asc_Nul
  6431. ShPStr45: DC.B      "discard",Asc_Nul
  6432. ShPStr46: DC.B      ", Init file: ",Asc_Nul
  6433. ShPStr47: DC.B      "   Packet Log:       ",Asc_Nul
  6434.  
  6435. *** Strings from the K68Commands4 module ***
  6436.  
  6437. LBReqStr: DC.B      "?-l and -b required",Asc_CR,Asc_LF,Asc_Nul
  6438. ABadUStr: DC.B      "?-a without -s, -r, or -g"
  6439. CnfAcStr: DC.B      "?Conflicting commands",Asc_CR,Asc_LF,Asc_Nul
  6440. MsFlNStr: DC.B      "?Missing file name",Asc_CR,Asc_LF,Asc_Nul
  6441. MisLNStr: DC.B      "?Communication line device name missing"
  6442.           DC.B      Asc_CR,Asc_LF,Asc_Nul
  6443. UnOpLStr: DC.B      "?Unable to open the requested line"
  6444.           DC.B      Asc_CR,Asc_LF,Asc_Nul
  6445. InvABStr: DC.B      "?Invalid argument bundling",Asc_CR,Asc_LF,Asc_Nul
  6446. InvArStr: DC.B      "?Invalid argument, type 'kermit -h' for help"
  6447.           DC.B      Asc_CR,Asc_LF,Asc_Nul
  6448.  
  6449. UsageStr: DC.B      Asc_CR,Asc_LF
  6450.           DC.B      "  Usage: kermit [-x arg [-x arg]...[-yyy]...]]"
  6451.           DC.B      Asc_CR,Asc_LF
  6452.           DC.B      "   x is an option that requires an argument,"
  6453.           DC.B      " y an option with no argument:"
  6454.           DC.B      Asc_CR,Asc_LF
  6455.           DC.B      "     commands (* options also require -l and -b) --"
  6456.           DC.B      Asc_CR,Asc_LF
  6457.           DC.B      "       -s file(s)   send "
  6458.           DC.B      Asc_CR,Asc_LF
  6459.           DC.B      "       -r           receive"
  6460.           DC.B      Asc_CR,Asc_LF
  6461.           DC.B      "       -k           receive to terminal"
  6462.           DC.B      Asc_CR,Asc_LF
  6463.           DC.B      "     * -g file(s)   get remote file(s) from server"
  6464.           DC.B      Asc_CR,Asc_LF
  6465.           DC.B      "       -a name      alternate name, used with -s, -r, -g"
  6466.           DC.B      Asc_CR,Asc_LF
  6467.           DC.B      "     * -f           finish remote server"
  6468.           DC.B      Asc_CR,Asc_LF
  6469.           DC.B      "       -h           help - type this message"
  6470.           DC.B      Asc_CR,Asc_LF
  6471.           DC.B      "     settings --"
  6472.           DC.B      Asc_CR,Asc_LF
  6473.           DC.B      "       -l line      communication line device"
  6474.           DC.B      Asc_CR,Asc_LF
  6475.           DC.B      "       -b baud      line speed, e.g. 1200"
  6476.           DC.B      Asc_CR,Asc_LF
  6477.           DC.B      "       -i           binary file"
  6478.           DC.B      Asc_CR,Asc_LF
  6479.           DC.B      "       -p x         parity, x is one of e,o,m,s,n"
  6480.           DC.B      Asc_CR,Asc_LF
  6481.           DC.B      "       -t           line turnaround handshake = xon,"
  6482.           DC.B      " half duplex"
  6483.           DC.B      Asc_CR,Asc_LF
  6484.           DC.B      "       -w           don't write over preexisting files"
  6485.           DC.B      Asc_CR,Asc_LF
  6486.           DC.B      "       -q           be quiet during file transfer"
  6487.           DC.B      Asc_CR,Asc_LF
  6488.           DC.B      " If no command is included, enter interactive mode"
  6489.           DC.B      Asc_CR,Asc_LF,Asc_Nul
  6490.  
  6491. *** Strings from the K68IOFunctions module ***
  6492.  
  6493. FlCmdStr: DC.B      "Error reading take file",Asc_CR,Asc_LF,Asc_Nul
  6494.  
  6495. CnBchStr: DC.B      "^Z - Cancelling Batch ",Asc_Nul
  6496. CnFilStr: DC.B      "^X - Cancelling File ",Asc_Nul
  6497. ReSndStr: DC.B      "^R - Resending ",Asc_Nul
  6498.  
  6499. ScrnStr1: DC.B      "Sending ",Asc_Nul
  6500. ScrnStr2: DC.B      "Receiving ",Asc_Nul
  6501. ScrnStr3: DC.B      "as ",Asc_Nul
  6502. ScrnStr4: DC.B      " [OK]",Asc_CR,Asc_LF,Asc_Nul
  6503. ScrnStr5: DC.B      " [discarded]",Asc_CR,Asc_LF,Asc_Nul
  6504. ScrnStr6: DC.B      " [interrupted]",Asc_CR,Asc_LF,Asc_Nul
  6505. ScrnStr7: DC.B      "Skipping ",Asc_Nul
  6506.  
  6507. *** Strings from the K68Protocol module ***
  6508.  
  6509. CCndLStr: DC.B      "Can't condition line",Asc_Nul
  6510. StSpeStr: DC.B      "Sorry, you must 'set speed' first",Asc_Nul
  6511.  
  6512. ErFRHStr: DC.B      "Error from remote host :",Asc_CR,Asc_LF,Asc_Nul
  6513. TooMTStr: DC.B      "Too many tries, last error is ",Asc_Nul
  6514. NAKRcStr: DC.B      "'NAK packet received'",Asc_Nul
  6515. TimLEStr: DC.B      "'timeout limit expired'",Asc_Nul
  6516. GbPRcStr: DC.B      "'garbled packet received'",Asc_Nul
  6517. POuOSStr: DC.B      "'packet out of sequence'",Asc_Nul
  6518. UkUxPStr: DC.B      "Unknown or unexpected packet type",Asc_Nul
  6519.  
  6520. FNFStr:   DC.B      "File not found",Asc_Nul
  6521. TMFStr:   DC.B      "Too many files",Asc_Nul
  6522. NRFStr:   DC.B      "No readable file to send",Asc_Nul
  6523.  
  6524. FlOErStr: DC.B      "Can't open file",Asc_Nul
  6525.  
  6526. NoNamStr: DC.B      "NONAME",Asc_Nul
  6527. FlCrEStr: DC.B      "Can't create file",Asc_Nul
  6528.  
  6529. *** Strings from the K68ParserSubs module ***
  6530.  
  6531. PrNmStr1: DC.B      "?Invalid number specification",Asc_Nul
  6532. PrNmStr2: DC.B      "?Number out of range",Asc_Nul
  6533. PrNmStr3: DC.B      "?Number specification expected",Asc_Nul
  6534.  
  6535. PrKyStr1: DC.B      "?Unrecognized ",Asc_Nul
  6536. PrKyStr2: DC.B      "?Ambiguous ",Asc_Nul
  6537. PrKyStr3: DC.B      "?Missing ",Asc_Nul
  6538.  
  6539. PrIFStr1: DC.B     "?File not found",Asc_Nul
  6540. PrIFStr2: DC.B     "?File not readable",Asc_Nul
  6541. PrIFStr3: DC.B     "?Read permission denied",Asc_Nul
  6542. PrIFStr4: DC.B     "?No files match",Asc_Nul
  6543. PrIFStr5: DC.B     "?Too many files match",Asc_Nul
  6544.  
  6545. POuFStr1: DC.B     "?Wildcards not allowed",Asc_Nul
  6546. POuFStr2: DC.B     "?Write permission denied",Asc_Nul
  6547.  
  6548. PrErStr1: DC.B      " - ",Asc_Nul
  6549.  
  6550.           align                        Following code aligned on word boundary
  6551.           ends
  6552.           END
  6553. <<< k6osys.asm >>>
  6554.           nam       Kermit68K
  6555.           ttl       OS-9/68000 Dependent module (part 1)
  6556.  
  6557. *         Kermit68K: source file K68SYS.A
  6558. *
  6559. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  6560. * Bologna University, Physics Department, May 1987.
  6561. *
  6562. * All rights reserved to Bologna University, Italy.
  6563. *
  6564. * Permission is granted to any individual or institution
  6565. * to use, copy, or redistribute this software so long as
  6566. * it  is not  sold for  profit, provided  this copyright
  6567. * notice is retained.
  6568. *
  6569. * OS9/68000 Modifications performed by Steve Williams
  6570. * University of Texas at Austin, March 1987
  6571. *
  6572. *  Revision History:
  6573. *    Edition  Date      Author  Description
  6574. *       0     87/03/25  spw     Initial implementation for OS-9/68K
  6575. *       1     87/04/22  spw     Added code for ChanCtrl
  6576. *       2     87/04/23  spw     Modifications to SysInit to handle command line
  6577. *       3     87/05/05  spw     Changes to ChanCtrl and SysInit
  6578. *       4     87/06/05  spw     Stripped parity bit on OutChar to Terminal
  6579. *       5     87/06/20  spw     Added line-feed stripping to Terminal output
  6580. *       6     87/07/02  spw     Rejoined sys, sy2 and sy3 for distribution
  6581.  
  6582.           use       DefsFile
  6583.  
  6584. Edition   set       6
  6585.           psect     K68sys,0,0,Edition,0,0
  6586.  
  6587. ********************************* InpChar *****************************
  6588. *                                                                     *
  6589. *  Try to read a character from the specified logical channel.        *
  6590. *                                                                     *
  6591. *         Entry conditions : D1.B logical channel number              *
  6592. *                                                                     *
  6593. *         Exit  conditions : D0.B character received, if any          *
  6594. *                            D1.B Completion Code (see below)         *
  6595. *                                                                     *
  6596. *              CC symbol        Meaning                               *
  6597. *                                                                     *
  6598. *              AllOk            No errors, character in D0            *
  6599. *              BadChan          Inexistent channel                    *
  6600. *              ResChan          Access reserved, permission denied    *
  6601. *              DevNotRd         Device not ready (e.g. unmounted)     *
  6602. *              NotInpCh         Input impossible on this channel      *
  6603. *              NotOpRd          File not open for read                *
  6604. *              UnrInpF          Unrecoverable failure during input    *
  6605. *              InChLost         Input character lost                  *
  6606. *              InpBreak         Break received on input               *
  6607. *              BufEmpty         Input buffer empty                    *
  6608. *              BufOvflw         Input buffer overflow                 *
  6609. *              EndOfFil         End of file reached on input          *
  6610. *                                                                     *
  6611. *  NOTES:  This routine uses a0, d0, and d1, and restores a0          *
  6612. ***********************************************************************
  6613. InpChar:  move.l    a0,-(sp)           Save working register.
  6614.           clr.w     -(sp)              Make a temporary buffer on the stack
  6615.           add.w     d1,d1              Convert to offset in path numbers table
  6616.           lea       Pathnums(a6),a0    Base of path numbers table
  6617.           move.w    (a0,d1.w),d0       Get the OS-9 path number
  6618.           bne.s     InpChar1           Has logical channel been used yet?
  6619.           move.b    #NotOpRd,d1        No, complain
  6620.           bra.s     InpChar3
  6621.  
  6622. InpChar1  move.w    #SS_Ready,d1       Check to see if data available
  6623.           os9       I$GetStt
  6624.           bcc.s     InpChar2           Data ready, go and read it.
  6625.           cmp.w     #E$NotRdy,d1       The not ready code (means no data)
  6626.           bne.s     InpChar5           Another OS-9 error code
  6627.           move.b    #BufEmpty,d1       Tell caller no data ready
  6628.           bra.s     InpChar3
  6629.  
  6630. InpChar2  lea       1(sp),a0           pass address of buffer
  6631.           moveq     #1,d1              Read one character
  6632.           os9       I$Read
  6633.           bcs.s     InpChar5           An OS-9 error
  6634.           move.b    #AllOk,d1          Everything OK
  6635. InpChar3  move.w    (sp)+,d0           Get the character read
  6636.           move.l    (sp)+,a0           Restore working register
  6637.           rts
  6638.  
  6639. InpChar5  cmp.b     #E$FNA,d1          A permission violation?
  6640.           bne.s     InpChar6
  6641.           move.b    #ResChan,d1
  6642.           bra.s     InpChar3
  6643. InpChar6  cmp.b     #E$EOF,d1          End of file?
  6644.           bne.s     InpChar7
  6645.           move.b    #EndOfFil,d1
  6646.           bra.s     InpChar3
  6647. InpChar7  move.w    #$0707,-(sp)
  6648.           moveq     #2,d0
  6649.           move.l    sp,a0
  6650.           moveq     #1,d1
  6651.           os9       I$Write
  6652.           addq      #2,sp
  6653.           move.b    #UnrInpF,d1
  6654.           bra.s     InpChar3
  6655.  
  6656. ********************************* OutChar *****************************
  6657. *                                                                     *
  6658. *  Try to write a character to the specified logical channel.         *
  6659. *                                                                     *
  6660. *         Entry conditions : D0.B character to write                  *
  6661. *                            D1.B logical channel number              *
  6662. *                                                                     *
  6663. *         Exit  conditions : D0.B character just sent                 *
  6664. *                            D1.B Completion Code (see below)         *
  6665. *                                                                     *
  6666. *              CC symbol        Meaning                               *
  6667. *                                                                     *
  6668. *              AllOk            No errors                             *
  6669. *              BadChan          Inexistent channel                    *
  6670. *              ResChan          Access reserved, permission denied    *
  6671. *              DevNotRd         Device not ready (e.g. unmounted)     *
  6672. *              NotOutCh         Output impossible on this channel     *
  6673. *              NotOpWr          File not open for write               *
  6674. *              UnrOutF          Unrecoverable failure during output   *
  6675. *              DevFull          Device full, not enough space         *
  6676. *                                                                     *
  6677. *  NOTES:  This routine uses a0, d0, and d1, and restores a0          *
  6678. ***********************************************************************
  6679. OutChar:  move.l    a0,-(sp)           Save working pointer reg.
  6680.           cmp       #Terminal,d1       Output to terminal?
  6681.           seq       TermFlag(a6)
  6682.           bne.s     OutChar0
  6683.           and.w     #$007f,d0          Strip the parity bit
  6684.           cmp.b     #Asc_LF,d0         Is it a linefeed?
  6685.           bne.s     OutChar_0
  6686.           tst.b     CR_Last(a6)        Did we just do a CR?
  6687.           beq.s     OutChar_0          ...no, so go ahead and print it.
  6688.           clr.b     CR_Last(a6)        OK for next LF to be printed
  6689.           move.l    (sp)+,a0           Restore working reg
  6690.           rts
  6691.  
  6692. OutChar_0 cmp.b     #Asc_CR,d0         Is carriage return?
  6693.           seq       CR_Last(a6)        Set the flag.
  6694.  
  6695. OutChar0  move.w    d0,-(sp)           Save the character being written
  6696.           lea       Pathnums(a6),a0    Get path number table base address
  6697.           add.w     d1,d1              Offset in table for this logical channel
  6698.           move.w    (a0,d1.w),d0       Get OS-9 output path for channel
  6699.           bne.s     OutChar2           It is open, so go ahead with write
  6700.           move.b    #NotOpWr,d1
  6701.  
  6702. OutChar1  move.w    (sp)+,d0           get the character written
  6703.           move.l    (sp)+,a0           get the old contents of the pointer
  6704.           rts
  6705.  
  6706. OutChar2  lea       1(sp),a0           Point to character (in memory on stack)
  6707.           moveq     #1,d1              ...and get ready
  6708.           tst       TermFlag(a6)       Output to terminal?
  6709.           beq.s     OutChar21          ...no, use I$Write
  6710.           tst.b     CR_Last(a6)        a Carriage return?
  6711.           beq.s     OutChar21          ...no, use I$Write
  6712.           os9       I$WritLn           Use WritLn to make sure...
  6713.           bra.s     OutChar22          ...that CR is handled properly.
  6714. OutChar21 os9       I$Write            Just write the character in plain mode
  6715. OutChar22 bcs.s     OutChar3           Something went wrong
  6716.           move.b    #AllOk,d1
  6717.           bra.s     OutChar1           Exit through clean-up routine
  6718.  
  6719. OutChar3  cmp.b     #E$Full,d1         Device full?
  6720.           bne.s     OutChar4
  6721.           move.b    #DevFull,d1
  6722.           bra.s     OutChar1
  6723.  
  6724. OutChar4  cmp.b     #E$NotRdy,d1       Device not ready?
  6725.           bne.s     OutChar5
  6726.           move.b    #DevNotRd,d1
  6727.           bra.s     OutChar1
  6728.  
  6729. OutChar5  cmp.b     #E$FNA,d1          Permission violation?
  6730.           bne.s     OutChar6
  6731.           move.b    #ResChan,d1
  6732.           bra.s     OutChar1
  6733.  
  6734. OutChar6  move.b    #UnrOutF,d1
  6735.           bra.s     OutChar1
  6736.  
  6737. ********************************* ChanCtrl ****************************
  6738. *                                                                     *
  6739. *  Performs control operations on logical channels.                   *
  6740. *                                                                     *
  6741. *         Entry conditions : D0.B Request Code (see below)            *
  6742. *                                                                     *
  6743. *              RC symbol        Meaning                               *
  6744. *                                                                     *
  6745. *              SetBaud          Set baud rate on port                 *
  6746. *              RawMode          Enable raw mode                       *
  6747. *              TextMode         Enable text mode                      *
  6748. *              DoXCntrl         Enable XON/XOFF protocol              *
  6749. *              NoXCntrl         Disable XON/XOFF protocol             *
  6750. *              SndBreak         Send a break over RS 232 C line       *
  6751. *              ClrInpBf         Clear input buffer                    *
  6752. *              ClrOutBf         Clear output buffer                   *
  6753. *                                                                     *
  6754. *                            D1.B channel number                      *
  6755. *                            D2.L additional data (only requested     *
  6756. *                                 baud rate now)                      *
  6757. *                                                                     *
  6758. *         Exit  conditions : D0.B Completion Code (see below)         *
  6759. *                                                                     *
  6760. *              CC symbol        Meaning                               *
  6761. *                                                                     *
  6762. *              AllOk            No errors                             *
  6763. *              BadChan          Inexistent channel                    *
  6764. *              ResChan          Access reserved, permission denied    *
  6765. *              DevNotRd         Device not ready (e.g. unmounted)     *
  6766. *              BadCtReq         I/O control request code invalid      *
  6767. *                                                                     *
  6768. ***********************************************************************
  6769. ChanCtrl: add.w     d0,d0              Get offset into jump table
  6770.           move.w    ChanRCLk(pc,d0.w),d0 Get offset to start of routine
  6771.           jmp       ChanRCLk(pc,d0.w)  Jump into it.
  6772.  
  6773. ChanRCLk  dc.w      CCSetBaud-ChanRCLk
  6774.           dc.w      CCRawMode-ChanRCLk
  6775.           dc.w      CCTxtMode-ChanRCLk
  6776.           dc.w      CCDoXON-ChanRCLk
  6777.           dc.w      CCNoXON-ChanRCLk
  6778.           dc.w      CCSndBrk-ChanRCLk
  6779.           dc.w      CCClrBuf-ChanRCLk
  6780.  
  6781. *  Set Baud rate
  6782. *
  6783. *  This routine simply changes the PD_BAU parameter in the path descriptor of
  6784. *  the designated logical channel.  Standard OS-9 baud rates are supported,
  6785. *  as per the table listed below and in the SCF section of the OS-9/68000
  6786. *  Technical Manual.
  6787. *
  6788. *  Note:  although many OS9 serial port drivers support software selectable
  6789. *  baud rates, many will only set the baud rate when they are first INIZed.
  6790. *  The standard 6850 ACIA driver falls in this class.  It is a relatively
  6791. *  simple procedure to add on-the-fly baud rate selection to the Read and
  6792. *  Write routines of most drivers, if source code is available, and if the
  6793. *  hardware supports baud rate selection.
  6794.  
  6795. CCSetBaud move.l    a0,-(sp)
  6796.           lea       BaudRates(pc),a0   Point to baud rate table.
  6797. SetBaud2  move.l    (a0)+,d0           Get a baud rate/code number pair
  6798.           bmi       CCError            Past end of table
  6799.           cmp.w     d0,d2              Baud rates match?
  6800.           bne.s     SetBaud2           No, check another
  6801.  
  6802.           swap      d0                 Get the baud rate code number
  6803.           move      d0,d2              Save it around the I$GetStt call
  6804.  
  6805.           add       d1,d1              Offset to path number table
  6806.           lea       Pathnums(a6),a0
  6807.           move      (a0,d1),d0         Get the path number
  6808.           lea       OptBuff(a6),a0     Point to the options buffer
  6809.           moveq     #SS_Opt,d1
  6810.           os9       I$GetStt
  6811.           bcs       CCError
  6812.  
  6813.           move.b    d2,PD_BAU-PD_OPT(a0) Set the baud rate
  6814.  
  6815.           moveq     #SS_Opt,d1
  6816.           os9       I$SetStt
  6817.           bcs       CCError
  6818.           move.l    (sp)+,a0           Restore working register.
  6819.           moveq     #AllOk,d0
  6820.           rts
  6821.  
  6822. BaudRates dc.w      0,50      These are the OS-9 baud rate numbers/buad rates
  6823.           dc.w      1,75      Found in the Technical Manual section on SCF
  6824.           dc.w      2,110
  6825.           dc.w      3,134     NOTE:  Not all device drivers support baud rate
  6826.           dc.w      4,150     selection after the device has been INIZed!!
  6827.           dc.w      5,300
  6828.           dc.w      6,600
  6829.           dc.w      7,1200
  6830.           dc.w      8,1800
  6831.           dc.w      9,2000
  6832.           dc.w      10,2400
  6833.           dc.w      11,3600
  6834.           dc.w      12,4800
  6835.           dc.w      13,7200
  6836.           dc.w      14,9600
  6837.           dc.w      15,19200
  6838.           dc.w      -1,-1     Mark end of table.
  6839.  
  6840. *  Send break out RS232 line
  6841. *
  6842. *  This routine relies on an undocumented feature of the I$GetStt call
  6843. *  It may not (and probably won't) work on very many serial drivers.
  6844.  
  6845. CCSndBrk  move.l    a0,-(sp)
  6846.           add       d1,d1              Offset into path table
  6847.           lea       Pathnums(a6),a0
  6848.           move      (a0,d1),d0         Path number to use
  6849.           moveq     #SS_Break,d1       Request a break
  6850.           os9       I$SetStt
  6851.           bcs       CCError
  6852.           move.l    (sp)+,a0
  6853.           moveq     #AllOk,d0
  6854.           rts
  6855.  
  6856. CCError   move.l    (sp)+,a0
  6857.           moveq     #BadCtReq,d0
  6858.           rts
  6859.  
  6860. *  Raw Mode--sets options suitable for raw (binary) data transfer mode
  6861.  
  6862. CCRawMode move.l    a0,-(sp)
  6863.           add.w     d1,d1              Get offset into path number lookup table
  6864.           lea       Pathnums(a6),a0    Get base of input path lookup table
  6865.           move.w    (a0,d1.w),d0       Get the OS9 path number
  6866.           lea       OptBuff(a6),a0     ...point to a buffer
  6867.           move.w    #SS_Opt,d1         ...and read in the option block
  6868.           os9       I$GetStt
  6869.           bcs       CCError
  6870.  
  6871.           clr.b     PD_EKO-PD_OPT(a0)  No echo
  6872.           clr.b     PD_PAU-PD_OPT(a0)  No page pause
  6873.           clr.b     PD_EOF-PD_OPT(a0)  No end of file character
  6874.           clr.b     PD_PSC-PD_OPT(a0)  No pause character
  6875.           clr.b     PD_INT-PD_OPT(a0)  No interrupt character
  6876.           clr.b     PD_QUT-PD_OPT(a0)  No abort character
  6877.  
  6878.           moveq     #SS_Opt,d1         Now, set 'em back
  6879.           os9       I$SetStt
  6880.           bcs       CCError
  6881.           move.l    (sp)+,a0
  6882.           moveq     #AllOk,d0          No error
  6883.           rts
  6884.  
  6885. *  Text Mode--sets options suitable for text transfer mode
  6886.  
  6887. CCTxtMode move.l    a0,-(sp)
  6888.           add.w     d1,d1              Get offset into path number lookup table
  6889.           lea       Pathnums(a6),a0
  6890.           move.w    (a0,d1.w),d0       Get the OS9 path number
  6891.  
  6892.           moveq     #255,d1
  6893.           os9       I$GetStt
  6894.  
  6895.           lea       OptBuff(a6),a0     Restore the text mode options
  6896.           move.w    #SS_Opt,d1         ...and read in the option block
  6897.           os9       I$GetStt
  6898.           bcs       CCError
  6899.  
  6900.           clr.b     PD_EKO-PD_OPT(a0)  No echo
  6901.           clr.b     PD_PAU-PD_OPT(a0)  No page pause
  6902.           clr.b     PD_EOF-PD_OPT(a0)  No end of file character
  6903.           clr.b     PD_PSC-PD_OPT(a0)  No pause character
  6904.           clr.b     PD_INT-PD_OPT(a0)  No interrupt character
  6905.           clr.b     PD_QUT-PD_OPT(a0)  No abort character
  6906.  
  6907.           move.w    #SS_Opt,d1
  6908.           os9       I$SetStt           Set to raw mode
  6909.           bcs       CCError
  6910.           move.l    (sp)+,a0
  6911.           moveq     #AllOk,d0          No error
  6912.           rts
  6913.  
  6914. *  DoXON--turns on XON/XOFF processing
  6915.  
  6916. CCDoXON   move.l    a0,-(sp)
  6917.           add.w     d1,d1
  6918.           lea       Pathnums(a6),a0
  6919.           move.w    (a0,d1.w),d0       Get the OS9 path number
  6920.           lea       OptBuff(a6),a0
  6921.           move.w    #SS_Opt,d1         ...and read in the option block
  6922.           os9       I$GetStt
  6923.           bcs       CCError
  6924.  
  6925.           move.b    #Asc_DC1,PD_XON-PD_OPT(a0)
  6926.           move.b    #Asc_DC3,PD_XOFF-PD_OPT(a0)
  6927.  
  6928.           move.w    #SS_Opt,d1
  6929.           os9       I$SetStt           Set to XON/XOFF mode
  6930.           bcs       CCError
  6931.           move.l    (sp)+,a0
  6932.           moveq     #AllOk,d0          No error
  6933.           rts
  6934.  
  6935. *  NoXON--This turns XON/XOFF processing off for the selected path.
  6936.  
  6937. CCNoXON   move.l    a0,-(sp)
  6938.           add.w     d1,d1
  6939.           lea       Pathnums(a6),a0
  6940.           move.w    (a0,d1.w),d0       Get the OS9 path number
  6941.           lea       OptBuff(a6),a0
  6942.           move.w    #SS_Opt,d1         ...and read in the option block
  6943.           os9       I$GetStt
  6944.           bcs       CCError
  6945.  
  6946.           clr.b     PD_XON-PD_OPT(a0)
  6947.           clr.b     PD_XOFF-PD_OPT(a0)
  6948.  
  6949.           move.w    #SS_Opt,d1
  6950.           os9       I$SetStt           Set to XON/XOFF mode
  6951.           bcs       CCError
  6952.           move.l    (sp)+,a0
  6953.           moveq     #AllOk,d0          No error
  6954.           rts
  6955.  
  6956. *  Clear out the input buffer.
  6957. *
  6958. *  This routine uses the OS-9 I$GetStt call with the SS_Ready function request
  6959. *  to determine how much data is available.  Most OS-9 drivers implement the
  6960. *  SS_Ready function code, but some of them incorrectly return 0 or 1 instead
  6961. *  the true number of characters in the buffer.  Due to this the routine will
  6962. *  check multiple times.
  6963.  
  6964. CCClrBuf  move.l    a0,-(sp)
  6965.           add.w     d1,d1              Offset into path number lookup table
  6966.           lea       Pathnums(a6),a0
  6967.           move      (a0,d1.w),d0       Get the actual OS-9 path number
  6968.  
  6969. CCClrB2   moveq     #SS_Ready,d1
  6970.           os9       I$GetStt           Check for data available
  6971.           bcs.s     CCClrB3            D1 SHOULD return number of chars in buff
  6972.  
  6973.           lea       ShellCmd(a6),a0    An unused buffer for reading
  6974.           os9       I$Read             Try to read the characters in the buffer
  6975.           bcc.s     CCClrB2            Check one more time for data.
  6976.  
  6977. CCClrB3   cmp.w     #E$NotRdy,d1       Is the error data not ready?
  6978.           beq.s     CCClrB4            ...yes, we've flushed the buffer
  6979.  
  6980.           cmp.w     #E$Read,d1         Was it a buffer over-run?
  6981.           beq.s     CCClrB2            Go back and empty some more.
  6982.  
  6983. CCClrB4   move.l    (sp)+,a0
  6984.           moveq     #AllOk,d0
  6985.           rts
  6986.  
  6987. ********************************* SysInit *****************************
  6988. *                                                                     *
  6989. *  Initialize any system dependent thing.                             *
  6990. *                                                                     *
  6991. *         Entry conditions : none                                     *
  6992. *                                                                     *
  6993. *         Exit  conditions : none                                     *
  6994. *                                                                     *
  6995. *  OS-9/68000 Notes:                                                  *
  6996. *    This routine grabs the command line parameter list and makes     *
  6997. *  sure that it is null-terminated (OS-9 usually puts a carriage      *
  6998. *  return or two).  Also, in order to avoid possible problems with    *
  6999. *  locking up the user's terminal, the I$GetStt function SS_DevNm     *
  7000. *  is used to open an independent path to the user's terminal.        *
  7001. *  I$Dup is not used, because any changes made to the option          *
  7002. *  section would have to be remembered and un-done before Kermit      *
  7003. *  could safely exit.  This was a major problem in debugging since    *
  7004. *  crashing Kermit locked up the terminal until this solution was     *
  7005. *  used.                                                              *
  7006. ***********************************************************************
  7007. SysInit:  move.l    a5,CmdLinPt(a6)    Save address of command line parms
  7008.           move.l    a5,a0
  7009. SysInit2  move.b    (a0)+,d0
  7010.           beq.s     SysInit3
  7011.           cmp.b     #Asc_CR,d0
  7012.           bne.s     SysInit2
  7013.           clr.b     -(a0)              Make sure it is NULL terminated!!
  7014.  
  7015. *  Connect the Terminal channel to the same device as stdin
  7016.  
  7017. SysInit3  clr       d0                 Stdin
  7018.           moveq     #SS_DevNm,d1       Ask for name of device
  7019.           lea       ShellCmd(a6),a0    An empty buffer to retrieve name
  7020.           move.b    #'/',(a0)+
  7021.           os9       I$GetStt           Find out the name.
  7022.           bcs.s     SysInit4
  7023.  
  7024.           moveq     #RdWrOp,d0         Want a read/write access
  7025.           moveq     #Terminal,d1       ...to the terminal
  7026.           lea       ShellCmd(a6),a0
  7027.           bsr       FilOpen            open it up.
  7028.           tst.b     d0
  7029.           beq.s     SysInit4
  7030.  
  7031. *  Set proper terminal operating modes
  7032.  
  7033.           moveq     #Terminal,d1       Channel number of terminal
  7034.           bsr       CCTxtMode          Set text mode I/O parameters.
  7035.           rts
  7036.  
  7037. *  OS-9 reported an error while we were trying to initialize the terminal
  7038.  
  7039. SysInit4  lea       SysInErr(pc),a0
  7040.           moveq     #1,d0              Stdout
  7041.           moveq     #127,d1            Long length
  7042.           os9       I$WritLn
  7043.           os9       F$Exit
  7044.  
  7045. SysInErr  dc.b      "Can't initialize terminal path properly, exiting."
  7046.           dc.b      Asc_CR,Asc_Nul
  7047.           align
  7048.  
  7049.  
  7050. ********************************* SysExod *****************************
  7051. *                                                                     *
  7052. *  Return control to system.                                          *
  7053. *                                                                     *
  7054. *         Entry conditions : D0.B completion code, exit status        *
  7055. *                                                                     *
  7056. *         Exit  conditions : none                                     *
  7057. *                                                                     *
  7058. ***********************************************************************
  7059. SysExod:  clr.b     d1                 No error
  7060.           os9       F$Exit             Closes all files for us, exits to system
  7061.  
  7062.  
  7063. ******************************** GetCmdLP *****************************
  7064. *                                                                     *
  7065. *  Try to return a pointer to the command line, null terminated.      *
  7066. *                                                                     *
  7067. *         Entry conditions : none                                     *
  7068. *                                                                     *
  7069. *         Exit  conditions : A0.L pointer to the command line, if any *
  7070. *                            D0.B completion code                     *
  7071. *                                                                     *
  7072. ***********************************************************************
  7073. GetCmdLP: move.l    CmdLinPt(a6),a0
  7074.           tst.b     (a0)               Command line null?
  7075.           sne       d0                 Set completion code accordingly
  7076.           RTS
  7077.           pag
  7078.           nam       Kermit68K
  7079.           ttl       OS-9/68000 Dependent module (part 2)
  7080.  
  7081. *         Kermit68K: source file K68SY2
  7082. *
  7083. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  7084. * Bologna University, Physics Department, May 1987.
  7085. *
  7086. * All rights reserved to Bologna University, Italy.
  7087. *
  7088. * Permission is granted to any individual or institution
  7089. * to use, copy, or redistribute this software so long as
  7090. * it  is not  sold for  profit, provided  this copyright
  7091. * notice is retained.
  7092. *
  7093. * OS9/68000 Modifications performed by Steve Williams
  7094. * University of Texas at Austin, June, 1987
  7095. *
  7096. *  Revision History:
  7097. *    Edition  Date      Author  Description
  7098. *       0     87/03/25  spw     Initial implementation for OS-9/68K
  7099. *       1     87/04/16  spw     Rough code for ExpandFN (no wildcarding)
  7100. *       2     87/04/22  spw     Changes to SysExod
  7101. *       3     87/04/24  spw     Added the System services
  7102. *       4     87/05/05  spw     Revised FilOpen, FilClose for new path number
  7103. *                               handling.  Split ExpandFN, GetNxtF, CRemTLoc,
  7104. *                               NewName, and Sleep to k68os9p3.a
  7105. *       5     87/06/05  spw     Added SysCommd handling to System function
  7106.  
  7107. ********************************** System *****************************
  7108. *                                                                     *
  7109. *  Performs system commands. Called with a request code and 0, 1 or 2 *
  7110. *  null terminated argument strings, depending on request code.       *
  7111. *                                                                     *
  7112. *         Entry conditions : D0.B Request Code (see below)            *
  7113. *                                                                     *
  7114. *         RC symbol             Meaning                               *
  7115. *                                                                     *
  7116. *         SysCommd              Forward command to operating system   *
  7117. *         Directry              Display a directory listing           *
  7118. *         SpacInfo              Display informations about disk usage *
  7119. *         DeletFil              Delete file(s)                        *
  7120. *         CopyFile              Copy file(s)                          *
  7121. *         ChangDir              Change the default directory          *
  7122. *         PrntFile              Print file(s)                         *
  7123. *         RenamFil              Rename file(s)                        *
  7124. *         TypeFile              Type file(s)                          *
  7125. *                                                                     *
  7126. *                            A0.L pointer to argument 1 (see below)   *
  7127. *                            A1.L pointer to argument 2 (see below)   *
  7128. *                                                                     *
  7129. *         RC symbol             Arguments number and meaning          *
  7130. *                                                                     *
  7131. *         Directry              0 or 1  directory path                *
  7132. *         SpacInfo              0 or 1  device or account name        *
  7133. *         DeletFil              1       file name                     *
  7134. *         CopyFile              2       source and target file names  *
  7135. *         ChangDir              0 or 1  path to new directory         *
  7136. *         PrntFile              1       file name                     *
  7137. *         RenamFil              2       old and new file names        *
  7138. *         TypeFile              1       file name                     *
  7139. *                                                                     *
  7140. *         Exit  conditions : D0.B completion code                     *
  7141. *                                                                     *
  7142. *  NOTES:  This routine saves all of the registers that it uses and   *
  7143. *    restores all of them on return, except of course, d0             *
  7144. ***********************************************************************
  7145. System:   movem.l   d1-d4/a0-a3,-(sp)      Save the working registers.
  7146.           add.w     d0,d0                  Compute offset in...
  7147.           move.w    SysCmdTbl(pc,d0.w),d1  ...command routine offset table
  7148.           jmp       SysCmdTbl(pc,d1.w)     Jump to the routine.
  7149.  
  7150. SysCmdTbl dc.w      SysHandle-SysCmdTbl  for SysCommd
  7151.           dc.w      SysFork-SysCmdTbl    for Directry
  7152.           dc.w      SysFork-SysCmdTbl    for SpacInfo
  7153.           dc.w      FilDel_0-SysCmdTbl   DeletFil
  7154.           dc.w      SysFork-SysCmdTbl    CopyFile
  7155.           dc.w      SysCWD-SysCmdTbl     ChangDir
  7156.           dc.w      SysFork-SysCmdTbl    PrntFile
  7157.           dc.w      SysFork-SysCmdTbl    Rename
  7158.           dc.w      SysFork-SysCmdTbl    TypeFile
  7159.  
  7160. SysHandle lea       ShellCmd(a6),a1
  7161. SysHnd_1  move.b    (a0)+,(a1)+        Move the command line to the shell buffer
  7162.           bne.s     SysHnd_1
  7163.           bra.s     SysFork3
  7164.           rts
  7165.  
  7166. SysCWD    tst.b     (a0)               Null string?
  7167.           beq.s     SysCWD2
  7168.           move.w    #Updat_,d0         Change data directory
  7169.           os9       I$ChgDir
  7170. SysCWD2   scc       d0                 Set condition code
  7171.           movem.l   (sp)+,d1-d4/a0-a3
  7172.           rts
  7173.  
  7174. *  Come here for those commands that we can just fork to a shell
  7175.  
  7176. SysFork   move.w    ShellOff(pc,d0.w),d1  Got offset to string in string table
  7177.           move.w    ShellOps(pc,d0.w),d2  Get number of operands.
  7178.           lea       ShellOff(pc,d1.w),a2  Got address of string.
  7179.           lea       ShellCmd(a6),a3       Need to set up the shell command
  7180.           bra.s     SysFork2
  7181.  
  7182. *  Table of number of command arguments for each command.  For those commands
  7183. *  with optional arguments, these are the maximum number of arguments.
  7184. *
  7185. *  The -1 entries in this table are for the commands that are taken care
  7186. *  of directly in Kermit.
  7187.  
  7188. ShellOps  dc.w     -1                  SysCmd
  7189.           dc.w      1                  Directry
  7190.           dc.w      1                  SpacInfo
  7191.           dc.w     -1                  DeletFil
  7192.           dc.w      2                  CopyFile
  7193.           dc.w     -1                  ChangDir
  7194.           dc.w      1                  PrntFile
  7195.           dc.w      2                  RenamFil
  7196.           dc.w      1                  TypeFile
  7197.  
  7198. *  Table of offsets to the actual command strings
  7199.  
  7200. ShellOff  dc.w     -1                  SysCmd
  7201.           dc.w      Directry-ShellOff
  7202.           dc.w      SpacInfo-ShellOff
  7203.           dc.w     -1
  7204.           dc.w      CopyFile-ShellOff
  7205.           dc.w     -1
  7206.           dc.w      PrntFile-ShellOff
  7207.           dc.w      RenamFil-ShellOff
  7208.           dc.w      TypeFile-ShellOff
  7209.  
  7210. *  Build the shell paramter list in ShellCmd(a6)
  7211.  
  7212. SysFork2  move.b    (a2)+,(a3)+        Move byte of the command name
  7213.           bne.s     SysFork2
  7214.           move.b    #' ',-1(a3)        Put in a space separator
  7215.  
  7216.           move.l    a0,a2              Move on-deck to batter's box
  7217.           move.l    a1,a0              In the hole -> on-deck
  7218.           dbf       d2,SysFork2        Go until the parameters are out.
  7219.  
  7220.           move.b    #Asc_CR,-1(a3)     Terminate the command with a CR
  7221.           clr.b     (a3)               ...and then a nul
  7222.  
  7223. *  Fork a shell to process the newly constructed command line at this point,
  7224. *  the registers a0-a3 and d2-d4 have been stacked with a movem instruction.
  7225.  
  7226. SysFork3  move.w    #(Prgrm<<8)+Objct,d0
  7227.           moveq     #0,d1              No extra memory
  7228.           move.l    a3,d2              End of parameter list
  7229.           lea       ShellCmd(a6),a1    Beginning of parameter list
  7230.           sub.l     a1,d2              Length of parameter list
  7231.           lea       ShellNam(pc),a0    Address of shell's name
  7232.           move.w    #3,d3              Inherit all my stdio paths.
  7233.           clr.w     d4                 Don't care about the priority
  7234.  
  7235.           os9       F$Fork
  7236.           bcs.s     SysErr             Error, must put terminal back...
  7237. *                                      ...to proper mode.
  7238.  
  7239. *  Wait for the child process to die.
  7240.  
  7241.           os9       F$Wait
  7242.  
  7243. SysErr    scc       d0                 If no OS-9 error, return good completion.
  7244.           movem.l   (sp)+,d1-d4/a0-a3
  7245.           RTS
  7246.  
  7247. Directry  dc.b      "dir",Asc_Nul
  7248. SpacInfo  dc.b      "free",Asc_Nul
  7249. CopyFile  dc.b      "copy",Asc_Nul
  7250. PrntFile  dc.b      "list >/p",Asc_Nul
  7251. RenamFil  dc.b      "rename",Asc_Nul
  7252. TypeFile  dc.b      "list",Asc_Nul
  7253.  
  7254. ShellNam: dc.b      "Shell",Asc_Nul
  7255.           align
  7256.  
  7257. ********************************* FilOpen *****************************
  7258. *                                                                     *
  7259. *  Open a disk file or an I/O channel.                                *
  7260. *                                                                     *
  7261. *         Entry conditions : D0.B Request Code (see below)            *
  7262. *                                                                     *
  7263. *              RC symbol        Meaning                               *
  7264. *                                                                     *
  7265. *              RdWrOp           Open for read/write                   *
  7266. *              ReadOp           Open for read                         *
  7267. *              WriteOp          Open for write                        *
  7268. *              AppendOp         Open for append                       *
  7269. *                                                                     *
  7270. *                            D1.B logical channel number.             *
  7271. *                            A0.L points to file name null terminated *
  7272. *                                                                     *
  7273. *         Exit  conditions : D0.B completion code                     *
  7274. *                            A0.L still points to the file name       *
  7275. *                                                                     *
  7276. ***********************************************************************
  7277. FilOpen:  movem.l   d1-d3/a0-a1,-(sp)   Save the working registers
  7278.           move.w    d0,d2               Save a copy of the file access mode
  7279.           add.w     d1,d1               Convert channel number to offset...
  7280. *                                       ...in OS-9 lookup table
  7281.           move.w    d1,d3               Save a copy of the logical...
  7282. *                                       ...(Kermit68K) channel number
  7283.           add.w     d0,d0               Compute offset into lookup table...
  7284. *                                       ...for mode
  7285.           lea       OS9OpCd(pc),a1
  7286.           move.w    (a1,d0.w),d0        Get the OS-9 open code corresponding
  7287.  
  7288. FilOp_1   cmp.w     #WriteOp,d2         Are we going to write to file?
  7289.           beq.s     FilOp_6             Yes, handle differently.
  7290.  
  7291.           os9       I$Open              No, try to open it
  7292.           bcc.s     FilOp_2             No error on the open
  7293.  
  7294.           cmp.w     #E$PNNF,d1          Path name not found?
  7295.           bne.s     FilOp_5             Other error, get out of here.
  7296.           cmp.w     #ReadOp,d2          Trying to read this file?
  7297.           beq.s     FilOp_5             Can't read from inexistent files
  7298.  
  7299.           move.w    d2,d0               Get the access mode value again
  7300.           add.w     d0,d0
  7301.           lea       OS9OpCd(pc),a1
  7302.           move.w    (a1,d0.w),d0        Get the access mode needed
  7303.           move.w    #Updat_,d1          Set read/write permanent permission bits
  7304.           move.l    (sp),a0             Restore the file name address
  7305.           os9       I$Create            Create the file
  7306.           bcs.s     FilOp_5             Can't even come close to open, get out
  7307.  
  7308. *  Connect the logical channel to the returned OS-9 path number
  7309.  
  7310. FilOp_2   lea       Pathnums(a6),a0     Set the path number
  7311.           move.w    d0,(a0,d3.w)
  7312.           cmp.b     #AppendOp,d2        Doing an append?
  7313.           bne.s     FilOp_4             No, leave the file where it is...
  7314. *                                       ...(d0 is non-zero)
  7315.  
  7316. *  For an append, find out how big the file is (with I$GetStt)
  7317. *  and then seek to end
  7318.  
  7319.           move.w    #SS_Ready,d1        Going to find out how big the file is.
  7320.           os9       I$GetStt
  7321.           bcs.s     FilOp_5
  7322.           move.l    d2,d1               Copy the current size
  7323.           os9       I$Seek              So we can seek to current end + 1
  7324.           bcs.s     FilOp_5
  7325.  
  7326. FilOp_4   st        d0                  return good completion
  7327.           movem.l   (sp)+,d1-d3/a0-a1
  7328.           rts
  7329.  
  7330. FilOp_5   sf        d0                  return bad completion code.
  7331.           movem.l   (sp)+,d1-d3/a0-a1   restore the working registers
  7332.           rts
  7333.  
  7334. *  Code to handle opening for write access
  7335.  
  7336. FilOp_6   bsr       FilDelet            Try to delete the file
  7337.           move.w    #Write_,d0          Write mode access
  7338.           move.w    #Updat_,d1          Read and write attributes (permanent)
  7339.           os9       I$Create
  7340.           bcs.s     FilOp_5             Error, quit now.
  7341.           bra       FilOp_2             Go into code to set path number properly
  7342.  
  7343. *  Lookup/translation table to convert the open request modes of Kermit68K to
  7344. *  the standard modes of OS-9
  7345.  
  7346. OS9OpCd   dc.w      Updat_              OS-9 Updat_ mode <--> RdWrOp of Kermit
  7347.           dc.w      Read_               <--> ReadOp of Kermit
  7348.           dc.w      Write_              <--> WriteOp of Kermit
  7349.           dc.w      Write_              <--> AppendOp of Kermit (with seek)
  7350.  
  7351. ******************************** FilClose *****************************
  7352. *                                                                     *
  7353. *  Close a disk file or an I/O channel.                               *
  7354. *                                                                     *
  7355. *         Entry conditions : D1.B logical channel number.             *
  7356. *                                                                     *
  7357. *         Exit  conditions : D0.B completion code                     *
  7358. *                                                                     *
  7359. ***********************************************************************
  7360. FilClose: movem.l   d1/a0,-(sp)
  7361.  
  7362.           add.w     d1,d1               Double channel number for offset
  7363.           lea       Pathnums(a6),a0     Base of path number lookup table
  7364.           move.w    (a0,d1.w),d0        Get the path number for the channel
  7365.  
  7366.           clr.w     (a0,d1.w)           Mark path as unused
  7367.           tst.w     d0                  Was the path ever used?
  7368.           beq.s     FilCls_1            ...no, don't close it.
  7369.           os9       I$Close             Close the path
  7370.  
  7371. FilCls_1  movem.l   (sp)+,d1/a0
  7372.           st        d0                  return success
  7373.           RTS
  7374.  
  7375. ********************************* FilDelet ****************************
  7376. *                                                                     *
  7377. *  Delete a file.                                                     *
  7378. *                                                                     *
  7379. *         Entry conditions : A0.L points to file name null terminated *
  7380. *                                                                     *
  7381. *         Exit  conditions : D0.B completion code                     *
  7382. *                                                                     *
  7383. ***********************************************************************
  7384. FilDel_0  movem.l   (sp)+,d1-d4/a0-a3   Restore regs pushed by System
  7385. FilDelet: move.l    a0,-(sp)            I$Delete clobbers a0
  7386.           move.w    #Read_,d0           Get the file in current DATA directory
  7387.           os9       I$Delete
  7388.           scc       d0                  Return success
  7389.           move.l    (sp)+,a0            Restore file name pointer
  7390.           rts
  7391.           align
  7392.           pag
  7393.           nam       Kermit68K
  7394.           ttl       OS-9/68000 Dependent module (part 3)
  7395.  
  7396. *         Kermit68K: source file K68SY3
  7397. *
  7398. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  7399. * Bologna University, Physics Department, February 1987.
  7400. *
  7401. * All rights reserved to Bologna University, Italy.
  7402. *
  7403. * Permission is granted to any individual or institution
  7404. * to use, copy, or redistribute this software so long as
  7405. * it  is not  sold for  profit, provided  this copyright
  7406. * notice is retained.
  7407. *
  7408. * OS9/68000 Modifications performed by Steve Williams
  7409. * University of Texas at Austin, June, 1987
  7410. *
  7411. *  Revision History:
  7412. *    Edition  Date      Author  Description
  7413. *       0     87/05/05  spw     Separated from k68os9p2.a
  7414. *       1     87/05/25  spw     Added code to handle wildcards
  7415. *       2     87/06/05  spw     Added CLocTRem for converted file names
  7416.  
  7417. ********************************* ExpandFN ****************************
  7418. *                                                                     *
  7419. *  Expand a wildcard file name into an array of file names, returns   *
  7420. *  the number of files that match the passed string, with data        *
  7421. *  structures set up so that the first file name (if any) will be     *
  7422. *  returned by the next GetNxtF call.                                 *
  7423. *                                                                     *
  7424. *         Entry conditions : A0.L points to file name null terminated *
  7425. *                                                                     *
  7426. *         Exit  conditions : D0.L number of matches found, negative   *
  7427. *                                 if too many matches for user buffer *
  7428. *                            A0.L still points to the file name       *
  7429. *                                                                     *
  7430. ***********************************************************************
  7431. ExpandFN: movem.l   d1-d4/a0-a3,-(sp)   Save working registers
  7432.           moveq     #0,d0               Clear character pointer.
  7433.           lea       FNBuffer(a6),a1     Point to first file name in buffer
  7434.           move.l    a1,NextFile(a6)     Save address of first file name
  7435. ExpFN_1   move.b    (a0,d0.l),d1
  7436.           move.b    d1,(a1,d0.l)        Copy the file name.
  7437.           beq.s     ExpFN_2             End of string and no wild card
  7438.           cmp.b     #'?',d1
  7439.           beq.s     ExpandWC            Handle the wildcard case.
  7440.           cmp.b     #'*',d1
  7441.           beq.s     ExpandWC            Do wildcard expansion.
  7442.           addq      #1,d0
  7443.           bra.s     ExpFN_1
  7444.  
  7445. ExpFN_2   moveq     #1,d0     One match
  7446.           move.l    d0,NumFiles(a6)     Set up for GetNxtF
  7447.           movem.l   (sp)+,d1-d4/a0-a3
  7448.           rts
  7449.  
  7450. *  The file name contains wildcards a0 still points to beginning of
  7451. *  wild card file name.
  7452. *
  7453. *  This version will handle wildcards if they are in the current directory.
  7454.  
  7455. ExpandWC  move.b    #'/',d0             Going to look for a directory specifier.
  7456.           move.l    a0,a1               Copy beginning of string pointer.
  7457.           sf        d1                  Haven't found a directory terminator
  7458.           moveq     #64,d2              Set a limiting count
  7459.  
  7460. ExpWC_1   cmp.b     (a1),d0             Is this a directory separator?
  7461.           seq       d3                  Set a flag
  7462.           or.b      d3,d1               Keep a permanent indicator
  7463.           tst.b     (a1)+               End of string?
  7464.           dbeq      d2,ExpWC_1          Go back until we find end of string.
  7465.  
  7466.           tst.b     d1                  Was there a directory separator?
  7467.           beq.s     ExpWC_2             ...no, do the expansion.
  7468.  
  7469.           move.l    a0,-(sp)            Save the file name pointer
  7470.           lea       BadWCMsg(pc),a0
  7471.           moveq     #1,d0               Stdout
  7472.           moveq     #127,d1             Long length
  7473.           os9       I$WritLn
  7474.           move.l    (sp)+,a0            Restore the file name pointer
  7475.  
  7476.           moveq     #0,d0               Signal no matches
  7477.           move.l    d0,NumFiles(a6)
  7478.           movem.l   (sp)+,d1-d4/a0-a3
  7479.           rts
  7480.  
  7481. BadWCMsg  dc.b      "Wildcarded filenames must be in current directory."
  7482.           dc.b      Asc_CR,Asc_Nul
  7483.           align
  7484.  
  7485. *  The files should all be in the current directory, so a shell can be forked
  7486. *  to execute an 'echo' command which will return a list of matches.
  7487.  
  7488. ExpWC_2   lea       EchoOpts(pc),a1     Pointer to the option list needed
  7489.           lea       ShellCmd(a6),a2     Point to parameter list
  7490.  
  7491. ExpWC_3   move.b    (a1)+,(a2)+         Set up the command options
  7492.           bne.s     ExpWC_3
  7493.  
  7494.           subq      #1,a2               Backup
  7495.           move.l    a0,a1               Copy file name pointer
  7496. ExpWC_4   move.b    (a1)+,(a2)+         Set up the wild card name
  7497.           bne.s     ExpWC_4
  7498.  
  7499. * Set up a pipe to read back the output of the echo command
  7500.  
  7501.           moveq     #1,d0               StdOut
  7502.           os9       I$Dup               Duplicate current standard output path
  7503.           move      d0,-(sp)            Save the duplicated path number
  7504.           moveq     #1,d0
  7505.           os9       I$Close             close stdout
  7506.           lea       PipeName(pc),a0
  7507.           move.w    #Updat_,d0          I need to read, he needs to write
  7508.           os9       I$Open              Open up the pipe (it will become path 1)
  7509.  
  7510. *  Now that the pipe is open, fork a shell to process the command
  7511.  
  7512.           move.w    #(Prgrm<<8)+Objct,d0
  7513.           moveq     #0,d1               No extra memory
  7514.           move.l    a2,d2               End of parameter list
  7515.           lea       ShellCmd(a6),a1     Beginning of parameter list
  7516.           sub.l     a1,d2               Length of parameter list
  7517.           lea       ShellNam(pc),a0     Address of shell command name
  7518.           move.w    #3,d3               Inherit all my stdio paths.
  7519.           clr.w     d4                  Don't care about the priority
  7520.           os9       F$Fork
  7521.  
  7522. *  Now, read the lines of output that match the wild card.
  7523.  
  7524.           lea       FNBuffer(a6),a0     Pointer to where to put file name
  7525.           moveq     #0,d3               Counter for file names.
  7526.  
  7527. ExpWC_5   moveq     #1,d0               The path number of the pipe
  7528.           moveq     #80,d1              read a line's worth
  7529.           os9       I$ReadLn            read a line
  7530.           bcs.s     ExpWC_8             End of file?
  7531.  
  7532. *  Got a name read in, now, update the pointer and count and go back for more
  7533.  
  7534.           move.b    #Asc_CR,d0
  7535. ExpWC_6   cmp.b     (a0)+,d0            Is it a Carriage return?
  7536.           bne.s     ExpWC_6             ...no, go back.
  7537.  
  7538.           clr.b     -1(a0)              Change the CR to a string terminator
  7539.           addq      #1,d3               Bump the file name count
  7540.           cmp.l     #50,d3              A limit on the number of files
  7541.           blo.s     ExpWC_5
  7542.  
  7543. *  too many file names matched, so read pipe until empty then quit.
  7544.  
  7545. ExpWC_7   lea       FNBuffer(a6),a0
  7546.           moveq     #1,d0
  7547.           moveq     #80,d1
  7548.           os9       I$ReadLn
  7549.           bcc.s     ExpWC_7
  7550.           moveq     #-1,d3              Signal too many matches
  7551.  
  7552. ExpWC_8   os9       F$Wait              Wait for the child to exit.
  7553.           moveq     #1,d0               Must close the pipe
  7554.           os9       I$Close
  7555.           move.w    (sp),d0             Get the saved path number for our stdout
  7556.           os9       I$Dup
  7557.           move.w    (sp)+,d0            Close the duplicated stdout
  7558.           os9       I$Close
  7559.           move.l    d3,NumFiles(a6)
  7560.           move.l    d3,d0               Return number of files matching.
  7561.           movem.l   (sp)+,d1-d4/a0-a3
  7562.           rts
  7563.  
  7564. PipeName  dc.b      "/pipe",0
  7565. EchoOpts  dc.b      "echo -n ",0
  7566.           align
  7567.  
  7568. ********************************* GetNxtF *****************************
  7569. *                                                                     *
  7570. *  Get the next file name from the list created by ExpandFN, returns  *
  7571. *  a true completion code if there's another file, copying its name   *
  7572. *  into the target string, or false if no more file names in list.    *
  7573. *                                                                     *
  7574. *         Entry conditions : A0.L points to the target string         *
  7575. *                                                                     *
  7576. *         Exit  conditions : D0.B completion code                     *
  7577. *                            A0.L points to the target string         *
  7578. *                                                                     *
  7579. ***********************************************************************
  7580. GetNxtF:  move.l    NumFiles(a6),d0     any left to get?
  7581.           beq.s     GetNF_2             No, so get on out of here.
  7582.  
  7583.           subq      #1,d0
  7584.           move.l    d0,NumFiles(a6)     Re-set number of files left
  7585.           movem.l   a0-a1,-(sp)
  7586.           movea.l   NextFile(a6),a1     Get address of this file name string
  7587.  
  7588. GetNF_1   move.b    (a1)+,(a0)+         Move a byte
  7589.           bne.s     GetNF_1             Until null encountered
  7590.           move.l    a1,NextFile(a6)     Save updated pointer
  7591.           movem.l   (sp)+,a0-a1
  7592.           st        d0                  true result
  7593.           rts
  7594.  
  7595. GetNF_2   sf        d0                  false result
  7596.           rts
  7597.  
  7598.  
  7599. ********************************* CRemTLoc ****************************
  7600. *                                                                     *
  7601. *  Convert filenames from remote system in a form suitable for the    *
  7602. *  local system.                                                      *
  7603. *                                                                     *
  7604. *         Entry conditions : A0.L points to the string to be          *
  7605. *                                 converted                           *
  7606. *                                                                     *
  7607. *         Exit  conditions : A0.L points to the same string suitably  *
  7608. *                                 converted                           *
  7609. *                                                                     *
  7610. *  OS-9/68000 Notes:                                                  *
  7611. *    This routine will replace any illegal punctuation characters     *
  7612. *  including the directory separator '/' and device raw-mode specifer *
  7613. *  '@' with the underline character, which is legal for OS-9 path     *
  7614. *  names.                                                             *
  7615. ***********************************************************************
  7616. CRemTLoc: move.l    d1,-(sp)
  7617.           clr.w     d0                  Zero out counter
  7618.           moveq     #FilNamML-1,d1      File name string maximum length in OS-9
  7619. CRTL_1    tst.b     (a0,d0.w)           Find length of string.
  7620.           beq.s     CRTL_2              Found the null
  7621.           addq      #1,d0               Keep counting
  7622.           dbf       d1,CRTL_1           ...until length exceeded
  7623.           clr.b     0(a0,d0.w)          Terminate the string properly.
  7624.  
  7625. CRTL_2    subq      #1,d0               Backup to last byte of string
  7626. CRTL_3    move.b    0(a0,d0.w),d1
  7627.           cmp.b     #'/',d1
  7628.           beq.s     CRTL_4              A slash foul (means a directory).
  7629.           cmp.b     #'.',d1
  7630.           beq.s     CRTL_5              A period is ok
  7631.           cmp.b     #'_',d1
  7632.           beq.s     CRTL_5              An underscore is ok
  7633.           cmp.b     #'0',d1
  7634.           blo.s     CRTL_4              Other punctuation $20-$2f is foul
  7635.           cmp.b     #'9',d1
  7636.           bls.s     CRTL_5              Digits are OK
  7637.           cmp.b     #'A',d1
  7638.           blo.s     CRTL_4              ':;<=>?@' are bad
  7639.           cmp.b     #'Z',d1
  7640.           bls.s     CRTL_5              Capital letters ok
  7641.           cmp.b     #'a',d1
  7642.           blo.s     CRTL_4              '[\]^' are bad
  7643.           cmp.b     #'z',d1
  7644.           bls.s     CRTL_5              Lower case letters OK
  7645. CRTL_4    move.b    #'_',0(a0,d0.w)     Replace the illegal character
  7646. CRTL_5    dbf       d0,CRTL_3           Loop backwards through the string
  7647.  
  7648.           move.b    (a0),d0             Check first character of string...
  7649. *                                       ...for alphabetic
  7650.           cmp.b     #'A',d0
  7651.           blo.s     CRTL_6              Less than 'A' -> not alpha
  7652.           cmp.b     #'Z',d0
  7653.           bls.s     CRTL_7              In 'A'..'Z' -> alpha
  7654.           cmp.b     #'a',d0
  7655.           blo.s     CRTL_6              Less than 'a' -> not alpha
  7656.           cmp.b     #'z',d0
  7657.           bls.s     CRTL_7              In 'a'..'z' -> alpha
  7658. CRTL_6    sf        d0                  Invalid file name
  7659.           move.l    (sp)+,d1            restore working reg.
  7660.           rts
  7661. CRTL_7    st        d0                  Valid file name
  7662.           move.l    (sp)+,d1            restore working reg.
  7663.           rts
  7664.  
  7665. ********************************* CLocTRem ****************************
  7666. *                                                                     *
  7667. *  Convert filenames in local system syntax in a form suitable for    *
  7668. *  the remote Kermit system. The job that this routine must do is     *
  7669. *  explained here in detail.                                          *
  7670. *                                                                     *
  7671. *  Adapted from the "Kermit Protocol Manual", Sixth Edition, p. 16    *
  7672. *                                                                     *
  7673. *   1. Delete all pathnames and attributes from the file              *
  7674. *      specification. The file name should not contain directory      *
  7675. *      or device names  if it does, it may cause the recipient to     *
  7676. *      try to store the file in an inaccessible or nonexistent area,  *
  7677. *      or it may result in a very strange filename.                   *
  7678. *                                                                     *
  7679. *   2. After stripping any pathname, convert the remainder of the     *
  7680. *      file specification to the form "name.type", with no            *
  7681. *      restriction on length (except that it fit in the data field    *
  7682. *      of the F packet), and:                                         *
  7683. *                                                                     *
  7684. *         a. Include no more than one dot.                            *
  7685. *         b. Not begin or end with a dot.                             *
  7686. *         c. The name and type fields contain digits and uppercase    *
  7687. *            letters only.                                            *
  7688. *                                                                     *
  7689. *         Entry conditions : A0.L points to the string to be          *
  7690. *                                 converted                           *
  7691. *                                                                     *
  7692. *         Exit  conditions : A0.L points to the same string suitably  *
  7693. *                                 converted                           *
  7694. *                                                                     *
  7695. ***********************************************************************
  7696. CLocTRem: movem.l   d1-d3/a1,-(sp)
  7697.           clr.w     d0                  Zero out counter
  7698.           moveq     #FilNamML-1,d1      File name string Maximum length in OS-9
  7699. CTRL_1    tst.b     (a0,d0.w)           Find length of string.
  7700.           beq.s     CTRL_2              Found the null
  7701.           addq      #1,d0               Keep counting
  7702.           dbf       d1,CTRL_1           ...until length exceeded
  7703.           clr.b     0(a0,d0.w)          Terminate the string properly.
  7704.  
  7705. CTRL_2    move.l    a0,a1               point to start of string
  7706.           move.w    d0,d3               Save string length
  7707.           subq      #1,d0               one less for dbf loop.
  7708.  
  7709. *  Is there a leading pathname?
  7710.  
  7711.           move.b    #'/',d1             Looking for a directory mark.
  7712. CTRL_21   cmp.b     (a1,d0.w),d1
  7713.           dbeq      d0,CTRL_21          Exit loop when one found.
  7714.           bne       CTRL_29             None found
  7715.  
  7716. *  Move the simple file name forward in the name buffer.
  7717.  
  7718.           lea       1(a1,d0.w),a1       Point to first character of file name
  7719.           move.w    d3,d1               Get original length of string.
  7720.           sub.w     d0,d1               Get length of simple file name.
  7721.           subq      #1,d1               ...minus one for dbf loop
  7722. CTRL_22   move.b    (a1,d1.w),(a0,d1.w) Move the simple file name forward
  7723.           dbf       d1,CTRL_22
  7724.  
  7725. *  Restore the counter and pointer for the next loop
  7726.  
  7727. CTRL_29   move.l    a0,a1               Copy start of string address
  7728.           move.w    d3,d0               Get count of string length
  7729.           subq      #1,d0               ...minus one for the dbf loop.
  7730.  
  7731. *  Replace any punctuation with periods.
  7732.  
  7733. CTRL_3    move.b    (a1)+,d1
  7734.           cmp.b     #'0',d1
  7735.           blo.s     CTRL_4              Punctuation $20-$2f is foul
  7736.           cmp.b     #'9',d1
  7737.           bls.s     CTRL_5              Digits are OK
  7738.           cmp.b     #'A',d1
  7739.           blo.s     CTRL_4              ':;<=>?@' are bad
  7740.           cmp.b     #'Z',d1
  7741.           bls.s     CTRL_5              Capital letters ok
  7742.           cmp.b     #'a',d1
  7743.           blo.s     CTRL_4              '[\]^' are bad
  7744.           cmp.b     #'z',d1
  7745.           bls.s     CTRL_5              Lower case letters OK
  7746. CTRL_4    move.b    #'.',-1(a1)         Replace the illegal character
  7747. CTRL_5    dbf       d0,CTRL_3           Loop backwards through the string
  7748.  
  7749. *  Make the string all capitals
  7750.  
  7751.           move.l    a0,a1               Point to start of string
  7752.           move.w    d3,d0               Count of characters.
  7753.           subq.w    #1,d0               Account for dbf loop.
  7754.  
  7755. CTRL_6    move.b    (a1)+,d1            Get a byte of string.
  7756.           cmp.b     #'a',d1
  7757.           blo.s     CTRL_7              Less than 'a' -> not lower case alpha
  7758.           cmp.b     #'z',d1
  7759.           bhi.s     CTRL_7              Not in 'a'..'z' -> not lower case alpha
  7760.           sub.b     #'a'-'A',d1
  7761.           move.b    d1,-1(a1)           Replace character
  7762. CTRL_7    dbf       d0,CTRL_6           Go back for more.
  7763.  
  7764. *  Can't begin or end with a '.'
  7765.  
  7766.           move.b    #'.',d1
  7767.           cmp.b     (a0),d1             Is first character a period?
  7768.           bne.s     CTRL_8
  7769.           move.b    #'X',(a0)           Replace with an 'X'
  7770. CTRL_8    cmp.b     -1(a0,d3),d1        Last character a period?
  7771.           bne.s     CTRL_9
  7772.           move.b    #'X',-1(a0,d3)
  7773.  
  7774.  
  7775. * Replace all but first period with 'X'
  7776.  
  7777. CTRL_9    move.l    a0,a1               Point to start of string.
  7778.           sf        d2                  Haven't found a period yet.
  7779.           move      d3,d0               Counter
  7780.           subq      #1,d0               account for dbf loop.
  7781.  
  7782. CTRL_10   cmp.b     (a1)+,d1            Get a byte of the string
  7783.           bne.s     CTRL_12             Not a period, leave it alone
  7784.           tst.b     d2                  Seen a period?
  7785.           beq.s     CTRL_11             ...not yet, leave this one alone
  7786.  
  7787.           move.b    #'X',-1(a1)         mask out the period
  7788. CTRL_11   st        d2                  We've seen a period now.
  7789. CTRL_12   dbf       d0,CTRL_10
  7790.           st        d0                  Valid file name
  7791.           movem.l   (sp)+,d1-d3/a1
  7792.           rts
  7793.  
  7794. ********************************** NewName ****************************
  7795. *                                                                     *
  7796. *  Make a new name for the given file to avoid file name collisions.  *
  7797. *                                                                     *
  7798. *         Entry conditions : A0.L points to the file name string      *
  7799. *                                                                     *
  7800. *         Exit  conditions : A0.L points to the same string suitably  *
  7801. *                                 modified                            *
  7802. *                                                                     *
  7803. *  OS-9 Note:  This routine just places an underscore character at    *
  7804. *    beginning of the file name to rename it.                         *
  7805. ***********************************************************************
  7806. NewName:  move.l    a1,-(sp)
  7807.           move.l    a0,a1               Copy string pointer
  7808.           moveq     #FilNamML-2,d0      Start from the end of longest file name
  7809.  
  7810. NewNm_1   move.b    0(a0,d0.w),1(a0,d0.w) Move the current name one byte forward
  7811.           dbf       d0,NewNm_1          Keep counting back through string
  7812.  
  7813.           move.b    #'_',(a0)           Put an underscore at start of string
  7814.           clr.b     FilNamML(a0)        Make sure string is null terminated.
  7815.           st        d0                  Set a good completion code
  7816.           move.l    (sp)+,a1
  7817.           rts
  7818.  
  7819. ********************************** Sleep ******************************
  7820. *                                                                     *
  7821. *  Puts the process to sleep.                                         *
  7822. *                                                                     *
  7823. *         Entry conditions : D0.B time interval to wait (seconds)     *
  7824. *                                                                     *
  7825. *         Exit  conditions : none                                     *
  7826. *                                                                     *
  7827. ***********************************************************************
  7828. Sleep:    move.l    d1,-(sp)
  7829.           ext.w     d0                  Need to pass a long tick count
  7830.           ext.l     d0                  ...extending some more.
  7831.           asl.l     #8,d0               Compute 256ths of second to sleep
  7832.           moveq     #31,d1              Need to set the high bit...
  7833.           bset      d1,d0               ...of the tick count, in order...
  7834.           os9       F$Sleep             ...to achieve system independence.
  7835.           move.l    (sp)+,d1
  7836.           rts
  7837.  
  7838.           align
  7839.           ends
  7840.           end
  7841. <<< k6outf.asm >>>
  7842.           nam       Kermit68K
  7843.           ttl       Utility subroutines module
  7844.  
  7845. *         Kermit68K: source file K68UTF
  7846. *
  7847. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  7848. * Bologna University, Physics Department, July 1987.
  7849. *
  7850. * All rights reserved to Bologna University, Italy.
  7851. *
  7852. * Permission is granted to any individual or institution
  7853. * to use, copy, or redistribute this software so long as
  7854. * it  is not  sold for  profit, provided  this copyright
  7855. * notice is retained.
  7856. *
  7857. * Modification History:
  7858. *
  7859. * Version  Date    Who              Comments
  7860. *
  7861. * 1.0.00   870701  Roberto Bagnara  First official release
  7862.  
  7863.           use       DefsFile
  7864.  
  7865. Edition   equ       0
  7866.           psect     K68UtilitySubs,0,0,Edition,0,0
  7867.  
  7868. ********************************* CopyStr *****************************ok
  7869. *                                                                     *
  7870. *  Null terminated strings copy subroutine.                           *
  7871. *                                                                     *
  7872. *         Entry conditions : D0.W target string maximum length        *
  7873. *                            A0.L pointer to target string            *
  7874. *                            A1.L pointer to source string            *
  7875. *                                                                     *
  7876. *         Exit  conditions : A0.L pointer to target string            *
  7877. *                            A1.L pointer to source string            *
  7878. *                                                                     *
  7879. ***********************************************************************
  7880. CopyStr:  TST.W     D0                 Null strings ?
  7881.           BEQ.S     CopyStr4           Yes, do nothing
  7882.           MOVEM.L   A0-A1,-(A7)        Save pointers
  7883. CopyStr1  SUBQ.W    #1,D0              Decrement counter
  7884.           BNE.S     CopyStr2           Continue copy, if there is room
  7885.           MOVE.B    D0,(A0)            End of target string, write terminator
  7886.           BRA.S     CopyStr3           Restore pointers and return
  7887. CopyStr2  MOVE.B    (A1)+,(A0)+        Copy a character
  7888.           BNE.S     CopyStr1           Repeat until end of source string
  7889. CopyStr3  MOVEM.L   (A7)+,A0-A1        Restore pointers
  7890. CopyStr4  RTS
  7891.  
  7892. ********************************* CompStr *****************************ok
  7893. *                                                                     *
  7894. *  Null terminated strings compare subroutine.                        *
  7895. *                                                                     *
  7896. *         Entry conditions : A0.L pointer to string 1                 *
  7897. *                            A1.L pointer to string 2                 *
  7898. *                                                                     *
  7899. *         Exit  conditions : D0.B completion code                     *
  7900. *                            A0.L pointer to string 1                 *
  7901. *                            A1.L pointer to string 2                 *
  7902. *                                                                     *
  7903. ***********************************************************************
  7904. CompStr:  MOVEM.L   A0-A1,-(A7)        Save pointers
  7905. CompStr1  MOVE.B    (A0)+,D0           Get a character from string 1
  7906.           CMP.B     (A1)+,D0           Compare whit string 2 correspondent char
  7907.           BNE.S     CompStr2           Compare failed, exit loop
  7908.           TST.B     D0                 Compare succeed, end of strings ?
  7909.           BNE.S     CompStr1           No, stay in loop
  7910. CompStr2  SEQ       D0                 Set completion code accordingly
  7911.           MOVEM.L   (A7)+,A0-A1        Restore pointers
  7912.           RTS
  7913.  
  7914. ********************************* DoPrity *****************************ok
  7915. *                                                                     *
  7916. *  Add an appropriate parity bit to a character.                      *
  7917. *                                                                     *
  7918. *         Entry conditions : D0.B 7-bit character                     *
  7919. *                                                                     *
  7920. *         Exit  conditions : D0.B character with parity bit added     *
  7921. *                                                                     *
  7922. ***********************************************************************
  7923. DoPrity:  MOVEM.L   D1-D2,-(A7)        Save working registers
  7924.           MOVE.B    Parity(A6),D1      Some kind of parity enabled ?
  7925.           BEQ.S     DoPrity5           No, return
  7926.           ANDI.B    #$7F,D0            Clear bit 7
  7927.           CMPI.B    #'M',D1            Mark ?
  7928.           BNE.S     DoPrity1           No
  7929.           ORI.B     #$80,D0            Yes, set bit 7
  7930.           BRA.S     DoPrity5           Return
  7931. DoPrity1  CMPI.B    #'S',D1            Space ?
  7932.           BEQ.S     DoPrity5           Yes, return, bit 7 already cleared
  7933.           CLR.B     D2                 Clear the ones counter
  7934.           CMPI.B    #'O',D1            Odd ?
  7935.           BNE.S     DoPrity2           No
  7936.           ADDQ.B    #1,D2              Yes, the ones counter starts from 1
  7937. DoPrity2  MOVEQ     #6,D1              Set up for bit addressing
  7938. DoPrity3  BTST      D1,D0              Bit setted ?
  7939.           BEQ.S     DoPrity4           No, try the next
  7940.           ADDQ.B    #1,D2              Yes, increment the counter
  7941. DoPrity4  DBF       D1,DoPrity3        Repeat for bits 6-0
  7942.           LSL.B     #7,D2              Position the parity bit
  7943.           OR.B      D2,D0              Ok, that's all
  7944. DoPrity5  MOVEM.L   (A7)+,D1-D2        Restore working registers
  7945.           RTS
  7946.  
  7947. ****************************** HndlPar ********************************ok
  7948. *                                                                     *
  7949. *  Handle 8-th bit accordingly to parity selected.                    *
  7950. *                                                                     *
  7951. *         Entry conditions : D0.B character to be processed           *
  7952. *                                                                     *
  7953. *         Exit  conditions : D0.B processed character                 *
  7954. *                                                                     *
  7955. ***********************************************************************
  7956. HndlPar:  TST.B     Parity(A6)         Parity selected ?
  7957.           BEQ.S     HndlPar1           No, do nothing
  7958.           ANDI.B    #$7F,D0            Yes, mask parity bit
  7959. HndlPar1  RTS
  7960.  
  7961. ********************************* UDiv ********************************ok
  7962. *                                                                     *
  7963. *  32-bit/16-bit unsigned division.                                   *
  7964. *                                                                     *
  7965. *         Entry conditions : D2.L dividend                            *
  7966. *                            D3.W divisor                             *
  7967. *                                                                     *
  7968. *         Exit  conditions : D0.L quotient                            *
  7969. *                            D1.L remainder                           *
  7970. *                                                                     *
  7971. ***********************************************************************
  7972. UDiv:     MOVE.L    D2,D0              Get Dividend
  7973.           CLR.W     D0                 Clear lower part
  7974.           SWAP      D0                 Upper Dividend
  7975.           DIVU      D3,D0              Divide
  7976.           MOVE.W    D0,-(A7)           Save upper quotient
  7977.           MOVE.W    D2,D0              Remainder and lower Dividend
  7978.           DIVU      D3,D0              Divide
  7979.           SWAP      D0
  7980.           CLR.L     D1
  7981.           MOVE.W    D0,D1              Final remainder
  7982.           MOVE.W    (A7)+,D0           Lower and upper quotients
  7983.           SWAP      D0                 Final quotient
  7984.           RTS                          Return
  7985.  
  7986. ******************************* IntToAs *******************************ok
  7987. *                                                                     *
  7988. *  Integer to ASCII string conversion routine.                        *
  7989. *                                                                     *
  7990. *         Entry conditions : A0.L pointer to string buffer end        *
  7991. *                            D0.L number to convert                   *
  7992. *                            D1.B flag for signed or unsigned number  *
  7993. *                            D2.L field length                        *
  7994. *                            D3.L number base                         *
  7995. *                                                                     *
  7996. *         Exit  conditions : A0.L pointer to string buffer start      *
  7997. *                                                                     *
  7998. ***********************************************************************
  7999. IntToAs:  MOVEM.W   D4-D6,-(A7)        Save working registers
  8000.           MOVE.B    D1,D4              Load our flag for negative numbers
  8001.           BEQ.S     IntToAs1           Unsigned number processing wanted
  8002.           TST.L     D0                 Signed, negative number ?
  8003.           SLT       D4                 Set our flag accordingly
  8004.           BGE.S     IntToAs1           If positive number then continue
  8005.           NEG.L     D0                 Else negate it
  8006. IntToAs1  MOVE.B    D2,D5              Save field length
  8007.           CLR.B     -(A0)              Mark the end of string
  8008.           CLR.B     D6                 Clear the character counter
  8009. IntToAs2  MOVE.L    D0,D2              Dividend
  8010.           BSR       UDiv               Divide number by base (in D3)
  8011.           CMPI.B    #9,D1              Convert remainder to ascii
  8012.           BGT.S     IntToAs3
  8013.           ADDI.B    #$30,D1
  8014.           BRA.S     IntToAs4
  8015. IntToAs3  ADDI.B    #$37,D1
  8016. IntToAs4  MOVE.B    D1,-(A0)           Store the obtained character
  8017.           ADDQ.B    #1,D6              Increment the character counter
  8018.           TST.L     D0                 End of conversion ?
  8019.           BNE.S     IntToAs2           No, repeat
  8020.           TST.B     D4                 Yes, was a negative number ?
  8021.           BEQ.S     IntToAs5           No, continue
  8022.           MOVE.B    #'-',-(A0)         Yes, insert the minus sign
  8023.           ADDQ.B    #1,D6              Increment the character counter
  8024. IntToAs5  CMP.B     D6,D5              Field full ?
  8025.           BLE.S     IntToAs6           Yes
  8026.           MOVE.B    #' ',-(A0)         No, write a leading blank
  8027.           ADDQ.B    #1,D6              Increment the character counter
  8028.           BRA.S     IntToAs5           Continue padding until the field is full
  8029. IntToAs6  MOVEM.W   (A7)+,D4-D6        Restore working registers
  8030.           RTS
  8031.  
  8032. ******************************* UppCase *******************************ok
  8033. *                                                                     *
  8034. *  Make a character upper-cased.                                      *
  8035. *                                                                     *
  8036. *         Entry conditions : D3.B character to be converted           *
  8037. *                                                                     *
  8038. *         Exit  conditions : D3.B converted character                 *
  8039. *                                                                     *
  8040. ***********************************************************************
  8041. UppCase:  CMPI.B    #'a',D3            Below a ?
  8042.           BCS.S     UppCase1           Yes, return
  8043.           CMPI.B    #'z',D3            Above z ?
  8044.           BHI.S     UppCase1           Yes, return
  8045.           SUBI.B    #32,D3             No, make the character upper-cased
  8046. UppCase1  RTS
  8047.  
  8048. ******************************* IndxJump ******************************ok
  8049. *                                                                     *
  8050. *  Indexed jump, extract an address from a relative addresses table   *
  8051. *  and jump to it.                                                    *
  8052. *                                                                     *
  8053. *         Entry conditions : D0.B index to jump table                 *
  8054. *                            A1.L jump table start address            *
  8055. *                                                                     *
  8056. *         Exit  conditions : none, don't return                       *
  8057. *                                                                     *
  8058. ***********************************************************************
  8059. IndxJump: ANDI.W    #$FF,D0            Make sure upper byte is cleared
  8060.           LSL.W     #1,D0              Scale factor of 2
  8061.           MOVE.W    (A1,D0.W),D0       Load relative pointer
  8062.           JMP       (A1,D0.W)          Jump to service subroutine
  8063.  
  8064. MacFind:  BSR       UppCasS            Make the macro name upper-cased
  8065.           LEA       MacroTbl(A6),A1    Load start address of macro table
  8066.           CMPA.L    MTNxtChF(A6),A1    The macro table is empty ?
  8067.           BEQ.S     MacFind2           Yes, return a bad completion code
  8068. MacFind1  BSR       CompStr            Compare the two names
  8069.           TST.B     D0                 The two names are equal ?
  8070.           BNE.S     MacFind3           Yes, return the macro address
  8071.           BSR       MacSkip            No, skip to next macro name
  8072.           TST.B     D0                 It was the last macro ?
  8073.           BEQ.S     MacFind1           No, so check this one
  8074. MacFind2  MOVEA.L   A1,A0              Yes, this points to table end
  8075.           SF        D0                 Return a bad completion code
  8076.           RTS
  8077. MacFind3  MOVEA.L   A1,A0              This is the desired macro address
  8078.           ST        D0                 Return a positive completion code
  8079.           RTS
  8080.  
  8081. MacSkip:  TST.B     (A1)+              Find the end of the macro name
  8082.           BNE.S     MacSkip            Loop until end of macro name found
  8083. MacSkip1  TST.B     (A1)+              Find the end of the macro body
  8084.           BNE.S     MacSkip1           Loop until end of macro body found
  8085.           CMPA.L    MTNxtChF(A6),A1    End of macro table ?
  8086.           SEQ       D0                 Set the completion code accordingly
  8087.           RTS
  8088.  
  8089. UppCasS   MOVE.L    A0,-(A7)
  8090. UppCasS1  MOVE.B    (A0),D3
  8091.           BEQ.S     UppCasS2
  8092.           BSR       UppCase
  8093.           MOVE.B    D3,(A0)+
  8094.           BRA.S     UppCasS1
  8095. UppCasS2  MOVE.L    (A7)+,A0
  8096.           RTS
  8097.  
  8098.           ends
  8099.           END
  8100.