home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / os968ka / k6ocmd.asm < prev    next >
Assembly Source File  |  2020-01-01  |  34KB  |  693 lines

  1.           nam       Kermit68K
  2.           ttl       Top-level commands subroutines module
  3.  
  4. *         Kermit68K: source file K68CMD
  5. *
  6. * Author: Roberto Bagnara (Bagnara@Iboinfn.Bitnet),
  7. * Bologna University, Physics Department, July 1987.
  8. *
  9. * All rights reserved to Bologna University, Italy.
  10. *
  11. * Permission is granted to any individual or institution
  12. * to use, copy, or redistribute this software so long as
  13. * it  is not  sold for  profit, provided  this copyright
  14. * notice is retained.
  15. *
  16. * Modification History:
  17. *
  18. * Version  Date    Who              Comments
  19. *
  20. * 1.0.00   870701  Roberto Bagnara  First official release
  21.  
  22.           use       DefsFile
  23.  
  24. Edition   equ       0
  25.           psect     K68Commands,0,0,Edition,0,0
  26.  
  27. ********************************** Parser *****************************ok
  28. *                                                                     *
  29. *  Kermit68K interactive command parser.                              *
  30. *                                                                     *
  31. *         Entry conditions : none                                     *
  32. *                                                                     *
  33. *         Exit  conditions : D1.B destroyed                           *
  34. *                            A0.L destroyed                           *
  35. *                                                                     *
  36. ***********************************************************************
  37. Parser:   LEA       VersStr(PC),A0     Give version informations
  38.           BSR       ConWrite
  39.  
  40. Parser1   TST.B     IntMacro(A6)       Are we interpreting a macro ?
  41.           BEQ.S     Parser2            No, see if we are interpreting a file
  42.           BSR       McCmdIn            Yes, get the next line of the macro
  43.           TST.B     D0                 End of macro ?
  44.           BNE.S     Parser4            No, join the common part
  45.           SF        IntMacro(A6)       Yes, we're no longer interpreting a macro
  46.  
  47. Parser2   MOVE.B    TakLevel(A6),D1    Are we interpreting a take file ?
  48.           BLT.S     Parser3            No, get a command from terminal
  49.           ADD.B     #TakeFil0,D1       Yes, compute its channel number
  50.           BSR       FlCmdIn            Get a command line from file
  51.           TST.B     D0                 End of file ?
  52.           BNE.S     Parser4            No, join the common part
  53.           MOVE.B    TakLevel(A6),D1    Yes, compute the file channel number
  54.           ADD.B     #TakeFil0,D1       Add this offset
  55.           BSR       FilClose           Close it
  56.           SUBQ.B    #1,TakLevel(A6)    Continue with outer take file, if any
  57.           BRA.S     Parser1
  58.  
  59. Parser3   LEA       Prompt(A6),A0      Point to the prompt string
  60.           BSR       ConWrite           Write it
  61.           BSR       CCmdIn             Input a command line
  62.           TST.B     D0                 EOF ?
  63.           SEQ       Done(A6)           Set the termination flag accordingly
  64.           BSR       NewLine            Start a new line
  65.  
  66. Parser4   SF        Display(A6)        Turn off the display flag
  67.           LEA       CmdBuf(A6),A0      Command to parse is here
  68.           BSR       DoCommd            Parse command and execute it
  69.           TST.B     Done(A6)           Done ?
  70.           BEQ.S     Parser1            No, stay in loop
  71.           RTS                          Yes, return to main
  72.  
  73. ********************************** DoCommd ****************************ok
  74. *                                                                     *
  75. *  Main switcher for commands execution.                              *
  76. *                                                                     *
  77. *         Entry conditions : A0.L points to the command line          *
  78. *                                                                     *
  79. *         Exit  conditions : D1.B destroyed                           *
  80. *                            A1.L destroyed                           *
  81. *                                                                     *
  82. ***********************************************************************
  83. DoCommd   MOVEA.L   A0,A5              This is the pointer to command line
  84.           TST.B     IntMacro(A6)       Are we interpreting a macro ?
  85.           BNE.S     DoCommd6           Yes, don't search in macro table
  86.           MOVE.L    A5,-(A7)           No, save the pointer to command line
  87.           LEA       Argumnt1(A6),A0    Put here the command verb, if any
  88.           BSR       ParsWrd            Try to get the command verb
  89.           TST.B     D0                 Success ?
  90.           BLT.S     DoCommd2           No, return
  91.           LEA       Argumnt1(A6),A0    Yes, here is the macro name to find
  92.           BSR       MacFind            Search this name in macro table
  93.           TST.B     D0                 Found ?
  94.           BEQ.S     DoCommd4           No, search in command table
  95. DoCommd1  TST.B     (A0)+              Yes, skip the macro name
  96.           BNE.S     DoCommd1           Loop until end of macro name
  97.           MOVE.L    A0,MacroPnt(A6)    Setup this pointer for reading the macro
  98.           ST        IntMacro(A6)       NOW we are intepreting a macro !
  99. DoCommd2  ADDQ.L    #4,A7              Remove the line pointer from stack
  100. DoCommd3  RTS
  101.  
  102. DoCommd4  MOVE.L    (A7)+,A5           Restore the pointer to command line
  103. DoCommd6  LEA       CmdTable(PC),A1    Pointer to command table
  104.           SF        D1                 The command verb is not mandatory
  105.           BSR       ParsKyW            Look for a valid command verb
  106.           TST.B     D0                 Ok ?
  107.           BLT.S     DoCommd3           No, return
  108.           LEA       DoCmdTab(PC),A1    Start of jump table
  109.           BRA       IndxJump           Jump to appropriate command handler
  110.  
  111. *** Code for top level commands execution ***
  112.  
  113. ChkLocl:  TST.B     Local(A6)          Are we running in local mode ?
  114.           BNE.S     ChkLocl1           Yes, all ok
  115.           LEA       StLnFStr(PC),A0    No, load pointer to the error message
  116.           BSR       ConWrite           Give error message
  117.           ADDQ.L    #4,A7              Remove caller's return address
  118. ChkLocl1  RTS
  119.  
  120. DoBYE:    BSR       ChkLocl            Check mode
  121.           SUBA.L    A2,A2              No arguments for SetGCmd
  122.           MOVEQ     #'L',D0            Logout command
  123.           BSR       SetGCmd            Setup for generic commands
  124.           MOVEQ     #SndGCmdS,D7
  125.           BSR       KPSwtch            Enter the protocol automaton switcher
  126.           RTS
  127.  
  128. *** % command (Treat the rest of the line as a comment) ***
  129.  
  130. DoCOMMNT: LEA       DataBuf(A6),A0     Pointer to temporary buffer
  131.           BSR       ParsWrd            Get a word from the command line
  132.           TST.B     D0                 End of line ?
  133.           BGE.S     DoCOMMNT           No, continue
  134.           RTS                          Yes, return
  135.  
  136. *** CONNECT command ***
  137.  
  138. DoCONN:   BSR       ChkLocl            Check mode
  139.           TST.L     Speed(A6)          Is line speed setted ?
  140.           BGT.S     DoCONN1            Yes, continue
  141.           LEA       StSpeStr(PC),A0    No, give error message and return
  142.           BSR       ConWrite
  143.           RTS
  144.  
  145. DoCONN1   LEA       ConnStr1(PC),A0    Yes, give the start of connection message
  146.           BSR       ConWrite
  147.           LEA       LineName(A6),A0    Write the line name
  148.           BSR       ConWrite
  149.  
  150.           LEA       ConnStr3(PC),A0    Line speed
  151.           BSR       ConWrite
  152.           MOVE.L    Speed(A6),D0       Load speed
  153.           BSR       TypeUNum           Write the baud rate
  154.  
  155.           LEA       ConnStr5(PC),A0    Escape character
  156.           BSR       ConWrite
  157.           MOVE.B    Escape(A6),D0      Get the escape character
  158.           CMPI.B    #' ',D0            Printable character ?
  159.           BGE.S     DoCONN3            Yes, print it out
  160.           ADDI.B    #64,D0             Make it printable
  161.           MOVEQ     #'^',D2            Prefix character for control
  162.           EXG       D0,D2              Exchange
  163.           BSR       ConOut             Output prefix
  164.           EXG       D0,D2              Exchange
  165. DoCONN3   BSR       ConOut             Output character
  166.           MOVEQ     #' ',D0            Write a blank
  167.           BSR       ConOut
  168.           MOVEQ     #'(',D0            Write an open parenthesis
  169.           BSR       ConOut
  170.           MOVEQ     #0,D0              Write the ASCII code of the escape char
  171.           MOVE.B    Escape(A6),D0
  172.           BSR       TypeUNum
  173.           LEA       ConnStr6(PC),A0    Close the parenthesis and give some info
  174.           BSR       ConWrite
  175.  
  176.           MOVEQ     #TextMode,D0       Put line in text mode
  177.           MOVEQ     #HostLine,D1
  178.           BSR       ChanCtrl
  179.           CMPI.B    #AllOk,D0          All ok ?
  180.           BEQ.S     DoCONN4            Yes, enter the connect loop
  181.           LEA       CCndLStr(PC),A0    No, point to the error message
  182.           BSR       ConWrite           Write it on the screen
  183.           RTS
  184.  
  185. DoCONN4   MOVEQ     #Terminal,D1       Try to get a character from terminal
  186.           BSR       InpChar
  187.           TST.B     D1                 Character received ?
  188.           BNE       DoCONN14           No, look at the host line
  189.           CMP.B     Escape(A6),D0      Escape character ?
  190.           BNE       DoCONN13           No
  191.           BSR       ConInp             Get a single character command
  192.           MOVE.B    D0,D3              Uppercase it
  193.           BSR       UppCase
  194.           CMPI.B    #'C',D3            Close command ?
  195.           BEQ       DoCONN12           Yes
  196.           CMPI.B    #'?',D3            Help command ?
  197.           BNE.S     DoCONN5            No
  198.           LEA       ConnStr8(PC),A0    Yes, give the help message
  199.           BSR       ConWrite
  200.           BRA       DoCONN14
  201. DoCONN5   CMPI.B    #'0',D3            Send null command ?
  202.           BNE.S     DoCONN6            No
  203.           MOVEQ     #0,D0              Yes, obey it
  204.           BSR       HostOut
  205.           BRA.S     DoCONN14
  206. DoCONN6   CMPI.B    #'B',D3            Send break command ?
  207.           BNE.S     DoCONN7
  208.           MOVEQ     #SndBreak,D0       Request code
  209.           MOVEQ     #HostLine,D1       Logical channel number
  210.           BSR       ChanCtrl           Call the channel control routine
  211.           BRA.S     DoCONN14
  212. DoCONN7   CMPI.B    #'S',D3            Show status command ?
  213.           BNE.S     DoCONN9            No
  214.           LEA       ConnStr2(PC),A0    Yes, show the communication status
  215.           BSR       ConWrite
  216.           LEA       LineName(A6),A0    Write the line name
  217.           BSR       ConWrite
  218.           LEA       ConnStr3(PC),A0    Write the line speed
  219.           BSR       ConWrite
  220.           MOVE.L    Speed(A6),D0       Load speed
  221.           BSR       TypeUNum           Write the baud rate
  222.           BSR       NewLine            Start a new line
  223.           BRA.S     DoCONN14
  224. DoCONN9   CMPI.B    #'H',D3            Hangup and close command ?
  225.           BNE.S     DoCONN10           No
  226. *
  227. *         Place code for hangup here
  228. *
  229.           BRA.S     DoCONN12           Close the connection
  230. DoCONN10  CMP.B     Escape(A6),D3      Escape character again ?
  231.           BNE.S     DoCONN11           No
  232.           MOVE.B    Escape(A6),D0      Yes, send it
  233.           BSR       HostOut
  234.           BRA.S     DoCONN14
  235. DoCONN11  MOVEQ     #Asc_Bel,D0        Invalid command, ring bell
  236.           BSR       ConOut
  237.           BRA.S     DoCONN14
  238. DoCONN12  LEA       ConnStr7(PC),A0    Yes, give the end of connection message
  239.           BSR       ConWrite
  240.           RTS                          Exit from transparent mode
  241.  
  242. DoCONN13  BSR       HostOut            Output the character just received
  243.           TST.B     Duplex(A6)         Half duplex ?
  244.           BEQ.S     DoCONN14           No
  245.           BSR       ConOut             Yes, echo the character to the terminal
  246. DoCONN14  MOVEQ     #HostLine,D1       Try to get a character from host
  247.           BSR       InpChar
  248.           TST.B     D1                 Character received ?
  249.           BNE       DoCONN4            No, look at the terminal line
  250.           BSR       HndlPar            Yes, handle the parity bit
  251.           BSR       ConOut             Output the character just received
  252.           BRA       DoCONN4
  253.  
  254. *** (Local) COPY command ***
  255.  
  256. DoCOPY:   LEA       Argumnt1(A6),A0    Source file specification
  257.           BSR       ParsWrd            Get it, if any
  258.           LEA       Argumnt2(A6),A0    Target file specification
  259.           BSR       ParsTxt            Get it, if any
  260.           LEA       Argumnt1(A6),A0    Pass arguments addresses ...
  261.           LEA       Argumnt2(A6),A1    ... to the System subroutine
  262.           MOVEQ     #CopyFile,D0       Copy file system function wanted
  263.           BSR       System             Call the external handler
  264.           LEA       NoCopStr(PC),A0    This is the "on failure" error message
  265.           BRA       CSysErr            Check cc and, on failure, give message
  266.  
  267. *** (Local) CWD command ***
  268.  
  269. DoCWD:    LEA       Argumnt1(A6),A0    Directory specification
  270.           BSR       ParsTxt            Get it, if any
  271.           LEA       Argumnt1(A6),A0    Pass argument address to System
  272.           MOVEQ     #ChangDir,D0       Change working directory function
  273.           BSR       System             Call the external handler
  274.           LEA       NoCWDStr(PC),A0    This is the "on failure" error message
  275.           BRA       CSysErr            Check cc and, on failure, give message
  276.  
  277. *** DEFINE command ***
  278.  
  279. DoDEFN:   TST.B     IntMacro(A6)       Are we interpreting from a macro ?
  280.           BNE       DoDEFN11           Yes, error
  281.           LEA       Argumnt1(A6),A0    Put here the macro name, if any
  282.           BSR       ParsWrd            Try to get it
  283.           TST.B     D0                 Success ?
  284.           BLT       DoLIST3            No, notify that macro name is missing
  285.           LEA       Argumnt1(A6),A0    Yes, point to the parsed macro name
  286.           BSR       MacFind            Check if this macro is already defined
  287.           TST.B     D0                 Found ?
  288.           BEQ.S     DoDEFN4            No, create it
  289. *                                      Yes, erase it from macro table
  290. DoDEFN1   MOVEA.L   A0,A1              Macro definition start address
  291.           BSR       MacSkip            Skip to end of macro body
  292.           TST.B     D0                 It was the last one ?
  293.           BNE.S     DoDEFN3            Yes, simply adjust pointer to table end
  294.           MOVE.L    MTNxtChF(A6),D0    No, load address of the next byte free
  295. DoDEFN2   MOVE.B    (A1)+,(A0)+        Shift the macro table
  296.           CMP.L     A1,D0              At end of macro table ?
  297.           BNE.S     DoDEFN2            No, stay in loop
  298. DoDEFN3   MOVE.L    A0,MTNxtChF(A6)    Next byte free in macro table is here
  299.  
  300. DoDEFN4   LEA       Argumnt1(A6),A1    Point to the parsed macro name
  301. DoDEFN5   MOVE.B    (A1)+,(A0)+        Store the macro name in macro table
  302.           BNE.S     DoDEFN5            Loop until end of macro name
  303.           BSR       ParsTxt            Try to get a one-line macro body
  304.           TST.B     D0                 Success ?
  305.           BLT.S     DoDEFN6            No, it's a multi-line macro
  306.           ADDQ.L    #1,A0              Yes, skip the termination null
  307.           BRA.S     DoDEFN10           Adjust the end pointer and return
  308.  
  309. DoDEFN6   MOVE.L    A0,-(A7)           Save the pointer to the macro table
  310.  
  311.           MOVE.B    TakLevel(A6),D1    Are we defining from a take file ?
  312.           BLT.S     DoDEFN7            No, get next macro line from terminal
  313.           ADD.B     #TakeFil0,D1       Yes, compute its channel number
  314.           BSR       FlCmdIn            Get the next macro line from file
  315.           TST.B     D0                 End of file ?
  316.           BEQ.S     DoDEFN9            Yes, end of macro body
  317.           SF        D2                 No, set the termination flag to false
  318.           BNE.S     DoDEFN8            Join the common part
  319.  
  320. DoDEFN7   BSR       CCmdIn             Get another line of text from terminal
  321.           TST.B     D0                 EOF on input ?
  322.           SEQ       D2                 Set the termination flag accordingly
  323.           BSR       NewLine            Start a new line on the terminal
  324.  
  325. DoDEFN8   LEA       CmdBuf(A6),A5      The macro line is here
  326.           MOVE.L    (A7)+,A0           Restore the pointer to the macro table
  327.           BSR       ParsTxt            Try to get it into the macro table
  328.           MOVE.B    #Asc_CR,(A0)+      Terminate the line whit a CR
  329.           TST.B     D0                 The line was null ?
  330.           BLT.S     DoDEFN9            Yes, this is an end condition
  331.           TST.B     D2                 Is the termination flag true ?
  332.           BEQ.S     DoDEFN6            No, continue entering macro lines
  333. DoDEFN9   CLR.B     -1(A0)             Null terminate the macro body
  334. DoDEFN10  MOVE.L    A0,MTNxtChF(A6)    Update next byte free in macro table
  335.           RTS
  336.  
  337. DoDEFN11  SUBA.L    A0,A0              No guilty
  338.           LEA       MNstAStr(PC),A1    Error message, can't nest macros
  339.           BSR       ParsErr            Write it
  340.           RTS
  341.  
  342. *** (Local) DELETE command ***
  343.  
  344. DoDELETE: LEA       Argumnt1(A6),A0    File to delete specification
  345.           BSR       ParsTxt            Get it, if any
  346.           LEA       Argumnt1(A6),A0    Pass argument address to System
  347.           MOVEQ     #DeletFil,D0       Delete file function wanted
  348.           BSR       System             Call the external handler
  349.           LEA       NoDelStr(PC),A0    This is the "on failure" error message
  350.           BRA       CSysErr            Check cc and, on failure, give message
  351.  
  352. *** (Local) DIRECTORY command ***
  353.  
  354. DoDIR:    LEA       Argumnt1(A6),A0    File or directory specification
  355.           BSR       ParsTxt            Get it, if any
  356.           LEA       Argumnt1(A6),A0    Pass argument address to System
  357.           MOVEQ     #Directry,D0       Directory function wanted
  358.           BSR       System             Call the external handler
  359.           LEA       NoDirStr(PC),A0    This is the "on failure" error message
  360.           BRA       CSysErr            Check cc and, on failure, give message
  361.  
  362. *** ECHO command ***
  363.  
  364. DoECHO:   LEA       DataBuf(A6),A1     Pointer to temporary buffer
  365.           MOVEA.L   A1,A0              Pass it to ParsTxt
  366.           BSR       ParsTxt            Get a text string from the command line
  367.           TST.B     D0                 Ok ?
  368.           BLT.S     DoECHO1            No, return
  369.           MOVEA.L   A1,A0              Reload pointer
  370.           BSR       ConWrite           Write the string to the terminal line
  371.           BSR       NewLine            Start a new line
  372. DoECHO1   RTS
  373.  
  374. *** EXIT command ***
  375.  
  376. DoEXIT:   ST        Done(A6)           Set the termination flag
  377.           RTS
  378.  
  379. *** FINISH command ***
  380.  
  381. DoFINISH: BSR       ChkLocl            Check mode
  382.           SUBA.L    A2,A2              No arguments for SetGCmd
  383.           MOVEQ     #'F',D0            Finish server command
  384.           BSR       SetGCmd            Set up for generic commands
  385.           MOVEQ     #SndGCmdS,D7
  386.           BSR       KPSwtch            Enter the protocol automaton switcher
  387.           RTS
  388.  
  389. *** GET command ***
  390.  
  391. DoGET:    BSR       ChkLocl            Check mode
  392.           LEA       Argumnt1(A6),A0    Point to file name string
  393.           BSR       ParsWrd            Try to get a file name
  394.           TST.B     D0                 Missing file name ?
  395.           BLT.S     DoGET1             Yes, give error message
  396.           LEA       Argumnt2(A6),A0    Point to file as-name string
  397.           BSR       ParsOuF            Look for a valid output file name
  398.           LEA       CmdBuf(A6),A0      Put here the file name
  399.           LEA       Argumnt1(A6),A1    Copy from here
  400.           MOVEQ     #CmdBufLn,D0       Buffers length
  401.           BSR       CopyStr            Copy now
  402.           TST.B     Local(A6)          Are we in local mode ?
  403.           SNE       Display(A6)        Set transaction display flag accordingly
  404.           BSR       TrnsInit           Initialize transaction related variables
  405.           MOVE.B    #'R',ServrCmd(A6)  Get command
  406.           MOVEQ     #SndSrvIS,D7       Send-Server-Init is the start state
  407.           BSR       KPSwtch            Enter protocol switcher
  408.           RTS
  409. DoGET1    SUBA.L    A0,A0              No guilty
  410.           LEA       MsFSpStr(PC),A1    Point to error message
  411.           BSR       ParsErr            Write it
  412.           RTS
  413.  
  414. *** HELP command ***
  415.  
  416. ScrnMxLL  EQU       78
  417. ColumnLn  EQU       12
  418.  
  419. DoHELP:   LEA       KerCmStr(PC),A0    Write introduction to Kermit68K commands
  420.           BSR       ConWrite
  421.           LEA       CmdTable(PC),A0    Point to top-level commands table start
  422.           CLR.B     D2                 Initialize the line length counter
  423. DoHELP1   MOVE.B    (A0)+,D0           Get a character from command table
  424.           CMP.B     #-1,D0             End of table ?
  425.           BEQ.S     DoHELP2            Yes, now write macro names
  426.           BSR.S     DoHELP5            No, write the command name
  427.           BRA.S     DoHELP1            Loop until end of table
  428.  
  429. DoHELP2   BSR       NewLine            Start a new line on the screen
  430.           CLR.B     D2                 Re-initialize the line length counter
  431.           LEA       MacroTbl(A6),A1    Load start address of macro table
  432.           CMPA.L    MTNxtChF(A6),A1    The macro table is empty ?
  433.           BEQ.S     DoHELP4            Yes, notify this and return
  434.           LEA       MacCmStr(PC),A0    No, write introduction to user macros
  435.           BSR       ConWrite
  436. DoHELP3   MOVEA.L   A1,A0              Now A0 points to tha macro name
  437.           BSR.S     DoHELP5            Write the macro name
  438.           BSR       MacSkip            Skip to next macro name
  439.           TST.B     D0                 The previous was the last macro ?
  440.           BEQ.S     DoHELP3            No, so write this one
  441.           BSR       NewLine            Yes, start a new line and return
  442.           RTS
  443.  
  444. DoHELP4   LEA       NoMacStr(PC),A0    Say that there are no user macros
  445.           BSR       ConWrite
  446.           RTS
  447.  
  448. DoHELP5   MOVEQ     #ColumnLn,D3       Initialize the column length counter
  449. DoHELP6   MOVE.B    (A0)+,D0           Get a character from the source string
  450.           BEQ.S     DoHELP7            End of name, write separators
  451.           BSR       ConOut             Output this character
  452.           ADDQ.B    #1,D2              Count it
  453.           SUBQ.B    #1,D3              Decrement the column length counter
  454.           BEQ.S     DoHELP5            If zero reload it
  455.           BRA.S     DoHELP6            Loop until end of name
  456.  
  457. DoHELP7   CMPI.B    #ScrnMxLL-ColumnLn,D2 There is room for another column ?
  458.           BGT.S     DoHELP9            No, start a new line on the screen
  459.           MOVEQ     #' ',D0            Yes, let's pad the column with blanks
  460. DoHELP8   BSR       ConOut             Write one blank
  461.           ADDQ.B    #1,D2              Count it
  462.           SUBQ.B    #1,D3              At end of column ?
  463.           BNE.S     DoHELP8            No, repeat
  464.           RTS
  465. DoHELP9   BSR       NewLine            Start a new line on the terminal screen
  466.           CLR.B     D2                 Re-initialize the line length counter
  467.           RTS
  468.  
  469. *** LIST command ***
  470.  
  471. DoLIST:   LEA       Argumnt1(A6),A0    Put here the macro name, if any
  472.           BSR       ParsWrd            Try to get the macro name
  473.           TST.B     D0                 Success ?
  474.           BLT.S     DoLIST3            No, give error and return
  475.           LEA       Argumnt1(A6),A0    Yes, point to the parsed macro name
  476.           BSR       MacFind            Search it in the macro table
  477.           TST.B     D0                 Found ?
  478.           BEQ.S     DoLIST4            No, give error and return
  479. DoLIST0   TST.B     (A0)+              Skip the macro name
  480.           BNE.S     DoLIST0
  481. DoLIST1   MOVE.B    (A0)+,D0           Type the macro body, get a character
  482.           BEQ.S     DoLIST2            End of macro body, exit
  483.           BSR       ConOut             Output the character just read
  484.           CMPI.B    #Asc_CR,D0         It was a carriage return ?
  485.           BNE.S     DoLIST1            No, continue
  486.           MOVEQ     #Asc_LF,D0         Yes, output a line feed
  487.           BSR       ConOut
  488.           BRA.S     DoLIST1            Stay in loop
  489. DoLIST2   BSR       NewLine            Start a new line on the terminal
  490.           RTS
  491. DoLIST3   SUBA.L    A0,A0              No guilty
  492.           LEA       MsMcNStr(PC),A1    Error message, missing macro name
  493.           BSR       ParsErr            Write it
  494.           RTS
  495. DoLIST4   LEA       Argumnt1(A6),A0    Here is the guilty word
  496.           LEA       UnkMcStr(PC),A1    Error message, macro not found
  497.           BSR       ParsErr            Write it
  498.           RTS
  499.  
  500. *** PRINT command ***
  501.  
  502. DoPRINT:  LEA       Argumnt1(A6),A0    File to print specification
  503.           BSR       ParsTxt            Get it, if any
  504.           LEA       Argumnt1(A6),A0    Pass argument address to System
  505.           MOVEQ     #PrntFile,D0       Print file function wanted
  506.           BSR       System             Call the external handler
  507.           LEA       NoPriStr(PC),A0    This is the "on failure" error message
  508.           BRA       CSysErr            Check cc and, on failure, give message
  509.  
  510. *** RECEIVE command ***
  511.  
  512. DoRECVE:  LEA       Argumnt2(A6),A0    Point to file as-name string
  513.           BSR       ParsOuF            Look for a valid output file name
  514.           TST.B     D0                 Ok ?
  515.           BGE.S     DoRECVE1           Yes, file must be stored under this name
  516.           CMPI.B    #-3,D0             Missing file specification ?
  517.           BEQ.S     DoRECVE1           Yes, no problem
  518.           RTS                          No, some other error, return
  519. DoRECVE1  TST.B     Local(A6)          Are we in local mode ?
  520.           SNE       Display(A6)        Set transaction display flag accordingly
  521.           BSR       TrnsInit           Setup transaction related variables
  522.           MOVEQ     #RecInitS,D7       Receive-Init is the start state
  523.           BSR       KPSwtch            Enter protocol switcher
  524.           RTS
  525.  
  526. *** RENAME command ***
  527.  
  528. DoRENAME: LEA       Argumnt1(A6),A0    Old file name specification
  529.           BSR       ParsWrd            Get it, if any
  530.           LEA       Argumnt2(A6),A0    New file name specification
  531.           BSR       ParsTxt            Get it, if any
  532.           LEA       Argumnt1(A6),A0    Pass arguments addresses ...
  533.           LEA       Argumnt2(A6),A1    ... to the System subroutine
  534.           MOVEQ     #RenamFil,D0       Rename file function wanted
  535.           BSR       System             Call the external handler
  536.           LEA       NoRenStr(PC),A0    This is the "on failure" error message
  537.           BRA       CSysErr            Check cc and, on failure, give message
  538.  
  539. *** SEND command ***
  540.  
  541. DoSEND:   LEA       Argumnt1(A6),A0    Point to file name string
  542.           BSR       ParsInF            Try to get a valid input file name
  543.           TST.B     D0                 Some error ?
  544.           BLT.S     DoSEND1            Yes, handle it
  545.           LEA       Argumnt2(A6),A0    Point to file as-name string
  546.           BSR       ParsTxt            Try to get an as name for this file
  547.           TST.B     Local(A6)          Are we in local mode ?
  548.           SNE       Display(A6)        Set transaction display flag accordingly
  549.           BSR       TrnsInit           Initialize transaction related variables
  550.           MOVEQ     #SndInitS,D7       Send-Init is the start state
  551.           BSR       KPSwtch            Enter protocol switcher
  552.           RTS
  553. DoSEND1   CMPI.B    #-3,D0             Missing file specification ?
  554.           BNE.S     DoSEND2            No, error already given
  555.           SUBA.L    A0,A0              No guilty
  556.           LEA       MsFSpStr(PC),A1    Point to error message
  557.           BSR       ParsErr            Write it
  558. DoSEND2   RTS
  559.  
  560. *** (Local) SPACE command ***
  561.  
  562. DoSPACE:  LEA       Argumnt1(A6),A0    Directory or device specification
  563.           BSR       ParsTxt            Get it, if any
  564.           LEA       Argumnt1(A6),A0    Pass argument address to System
  565.           MOVEQ     #SpacInfo,D0       Disk usage query function wanted
  566.           BSR       System             Call the external handler
  567.           LEA       NoSpaStr(PC),A0    This is the "on failure" error message
  568.           BRA       CSysErr            Check cc and, on failure, give message
  569.  
  570. *** STATISTICS command ***
  571.  
  572. DoSTATS:  LEA       StatStr1(PC),A0    Header line and characters sent string
  573.           MOVE.L    ChrsSent(A6),D6    Characters sent this transaction
  574.           MOVE.L    TChsSent(A6),D7    Total characters sent
  575.           BSR.S     DoSTATS1           Display this
  576.           LEA       StatStr2(PC),A0    Data characters sent string
  577.           MOVE.L    DChsSent(A6),D6    Data characters sent this transaction
  578.           MOVE.L    TDChSent(A6),D7    Total data characters sent
  579.           BSR.S     DoSTATS1           Display this
  580.           LEA       StatStr3(PC),A0    NAKs received string
  581.           MOVE.L    NAKsRecd(A6),D6    NAKs received this transaction
  582.           MOVE.L    TNAKRecd(A6),D7    Total NAKs received
  583.           BSR.S     DoSTATS1           Display this
  584.           LEA       StatStr4(PC),A0    Packets sent string
  585.           MOVE.L    PcksSent(A6),D6    Packets sent this transaction
  586.           MOVE.L    TPckSent(A6),D7    Total packets sent
  587.           BSR.S     DoSTATS1           Display this
  588.           LEA       StatStr5(PC),A0    Characters received string
  589.           MOVE.L    ChrsRecd(A6),D6    Characters received this transaction
  590.           MOVE.L    TChsRecd(A6),D7    Total characters received
  591.           BSR.S     DoSTATS1           Display this
  592.           LEA       StatStr6(PC),A0    Data characters received string
  593.           MOVE.L    DChsRecd(A6),D6    Data characters received this transaction
  594.           MOVE.L    TDChRecd(A6),D7    Total data characters received
  595.           BSR.S     DoSTATS1           Display this
  596.           LEA       StatStr7(PC),A0    NAKs received string
  597.           MOVE.L    NAKsSent(A6),D6    NAKs sent this transaction
  598.           MOVE.L    TNAKSent(A6),D7    Total NAKs sent
  599.           BSR.S     DoSTATS1           Display this
  600.           LEA       StatStr8(PC),A0    Packets received string
  601.           MOVE.L    PcksRecd(A6),D6    Packets received this transaction
  602.           MOVE.L    TPckRecd(A6),D7    Total packets received
  603.           BSR.S     DoSTATS1           Display this
  604.           RTS
  605.  
  606. DoSTATS1  BSR       ConWrite           Write the string
  607.           MOVE.L    D6,D0              Total for last transaction
  608.           BSR.S     DoSTATS2           Write number
  609.           MOVE.L    D7,D0              Total since start of Krmit68K
  610.           BSR.S     DoSTATS2           Write number
  611.           BSR       NewLine            Start a new line
  612.           RTS
  613.  
  614. DoSTATS2  SF        D1                 Unsigned conversion wanted
  615.           MOVEQ     #12,D2             Field length
  616.           MOVEQ     #10,D3             Base 10
  617.           LEA       DataBuf+34(A6),A0  Point to the end of a temporary buffer
  618.           BSR       IntToAs            Convert the number into a string
  619.           BSR       ConWrite           Write the obtained string
  620.           RTS
  621.  
  622. *** % command (Forward the rest of line to system command processor) ***
  623.  
  624. DoSYSCMD: LEA       Argumnt1(A6),A0    Put here the system command
  625.           BSR       ParsTxt            Get it, if any
  626.           LEA       Argumnt1(A6),A0    Pass argument address to System
  627.           MOVEQ     #SysCommd,D0       System command function wanted
  628.           BSR       System             Call the external handler
  629.           LEA       NoSyCStr(PC),A0    This is the "on failure" error message
  630.           BRA       CSysErr            Check cc and, on failure, give message
  631.  
  632. *** TAKE command ***
  633.  
  634. DoTAKE:   CMPI.B    #MaxTakeF,TakLevel(A6) Take level number at our limit ?
  635.           BEQ.S     DoTAKE1            Yes, give error and return
  636.  
  637.           LEA       Argumnt1(A6),A0    Point to the file name buffer
  638.           BSR       ParsInF            Try to get a valid input file name
  639.           TST.B     D0                 Some error ?
  640.           BLT.S     DoTAKE2            Yes
  641.  
  642.           BSR       ChkWild            Check the specified file name
  643.           TST.B     D0                 Wildcarded name ?
  644.           BNE.S     DoTAKE4            Yes, give error and return
  645.  
  646.           MOVE.B    TakLevel(A6),D1    Get the take level number
  647.           ADDQ.B    #1,D1              Increment this temporary variable
  648.           ADD.B     #TakeFil0,D1       Compute the new file channel number
  649.  
  650.           MOVEQ     #ReadOp,D0         We want open the file for input
  651.           BSR       FilOpen            Open the new take file
  652. *
  653. *         Warning, the cc is not checked !!!
  654. *
  655.           ADDQ.B    #1,TakLevel(A6)    Finally increment the take level
  656.           RTS
  657.  
  658. DoTAKE1   LEA       TFNDpStr(PC),A1    Say take file nested too deeply
  659.           SUBA.L    A0,A0              No guilty word
  660.           BSR       ParsErr            Call the error messages routine
  661.           RTS
  662.  
  663. DoTAKE2   CMPI.B    #-3,D0             Has a file name been specified ?
  664.           BNE.S     DoTAKE3            Yes, message already given, return
  665.           LEA       MsFSpStr(PC),A1    Give missing file specification error
  666.           SUBA.L    A0,A0              No guilty word
  667.           BSR       ParsErr            Write the error message
  668. DoTAKE3   RTS
  669.  
  670. DoTAKE4   LEA       POuFStr1(PC),A1    Give illegal wildcard error message
  671.           BSR       ParsErr            Call the error messages routine
  672.           RTS
  673.  
  674. *** (Local) TYPE command ***
  675.  
  676. DoTYPE:   LEA       Argumnt1(A6),A0    File to type specification
  677.           BSR       ParsTxt            Get it, if any
  678.           LEA       Argumnt1(A6),A0    Pass argument address to System
  679.           MOVEQ     #TypeFile,D0       Type file function wanted
  680.           BSR       System             Call the external handler
  681.           LEA       NoTypStr(PC),A0    This is the "on failure" error message
  682. *          BRA       CSysErr            Check cc and, on failure, give message
  683.  
  684.  
  685. CSysErr   TST.B     D0                 System operation failed ?
  686.           BNE.S     CSysErr1           No, return
  687.           BSR       ConWrite           Yes, write corresponding error message
  688.           BSR       NewLine            Start a new line
  689. CSysErr1  RTS
  690.  
  691.           ends
  692.           END
  693.