home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d537 / zshell.lha / ZShell / ZShell.s.lzh / ZSH.s
Text File  |  1991-08-26  |  109KB  |  5,215 lines

  1. ********   ZSHELL (C) 1990,91 Paul Hayter   ********
  2. * See my lharcs disk for log of previous versions
  3. * ZSHELL V1.23 MAY 1991
  4. * New readfile routine had to be created, and execscript and type had to be
  5. * changed to accommodate this. New copy handles wildcards and ctrlC. Delete
  6. * also supports the -r option.
  7. *
  8. * Changed comment specifier to * # or ;
  9. * Changed delete so that it handles ctrl c better
  10. *
  11. * Altered type command so it is more like normal type. i.e. just continuously
  12. * lists to the screen. CTRLC should break it.
  13. *
  14. * Added 'more' type text file viewer. Default clears screen and shows 23 lines
  15. * (maximum allowed on original AmigaDOS window at startup). Space takes you
  16. * forward 20 lines. Backspace takes you back 20 lines. Optional line count
  17. * used for displaying more than 23 lines, ala PAL screens.
  18. *  Added <RETURN> to more; advances you one line.
  19. *  Added T and B to more. Take you to Top and Bottom.
  20. *
  21. * V1.24 900605
  22. *  Made it so that if you execute the last line in the history, it won't
  23. * continually fill up the history. Can have 1 level of nested aliases I think.
  24. * eg.  set cls "echo ^L";set cdir "%1 cls;cd $1;diw"
  25. *  Fixed age old bug which made it so that anything printed with newprint had
  26. * a null char at the end of it. Not anymore! Changed rpn so it uses less
  27. * memory.
  28. *
  29. * V1.25 900630 start of July break.
  30. *  Added residentable command. Uses resi_list linked list created by
  31. * resident command. All resident commands unloaded when shell is quit. Type
  32. * RESIDENT [command1] [command2]...[command11] to make resident
  33. *
  34. * V1.26 900630
  35. *  Changed resident so that it auto replaces an entry in the resident list
  36. * if it already exists. Fixed bug in search_res which failed to compare
  37. * resident names to parm1 properly. Also changed search_sets so it is case
  38. * independent.
  39. *
  40. * Changed sets so that defn has no size limitation. However shell line
  41. * length is limited to 256 chars anyway
  42. *
  43. * V1.27 900704
  44. *  Changed packet sending so it is general purpose. There is now myArg1 thru
  45. * myArg7 in memory block as well as packettype (the ACTION) and packettask
  46. * which is the task you are sending it to. Added relabel and addbuffers
  47. * commands which utilize the general purpose sendpacket.
  48. *  Changed m command so you can specify a start and end address.
  49. *
  50. * V1.28 900706
  51. *  Added IF ELSE ENDIF commands. Same as AmigaDOS so far. Support IF EXISTS,
  52. * IF NOT EXISTS, IF WARN, IF ERROR, IF FAIL etc. Added ASK command for
  53. * y n type responses. Changed get_parm so that TABs can precede parms.
  54. * Is really only useful for TABs at start of line. It still looks for a space
  55. * as the delimiter after a parameter.
  56. *
  57. * V1.29 900708
  58. *  Added LABEL and GOTO commands. Both of limited use considering the IF
  59. * command constructs. Also added SLEEP command. NOTE Changed scflag from
  60. * absolute to offset a5. Added RETURN command for exiting scripts midstream.
  61. *  Added join command. Added htype command. Added strings command. Changed
  62. * help command so everything is printed pretty on window with border.
  63. *  Discovered strange bug which makes info show a different number of bytes
  64. * free than is actually free on a particular disk. I dont know why?
  65. *  Changed prompt command so that \ character works in it. ie \%.
  66. *
  67. * V1.30 900722
  68. *  Changed path area size. Altered default path. Includes vd0: rad: etc.
  69. * MADE shelline and clibuf bigger 384 bytes. Should allow for really long
  70. * sets.
  71. FIB        equ    260            ;FileInfoBlock
  72. ACCESS_READ    equ    -2
  73. ACCESS_WRITE    equ    -1
  74. MODE_OLDFILE    equ    1005
  75. MODE_NEWFILE    equ    1006
  76.  
  77.  
  78. ;DOS LIBRARY
  79. dl_A2        equ    42
  80.  
  81. SIGBREAKF_CTRL_C    equ    1<<12
  82. SIGBREAKB_CTRL_C    equ    $0C
  83.     
  84. ;FILE INFO BLOCK
  85.  
  86. fib_DiskKey    equ  $0000
  87. fib_DirEntryType    equ  $0004
  88. fib_FileName    equ  $0008
  89. fib_Protection    equ  $0074
  90. fib_EntryType    equ  $0078
  91. fib_Size        equ  $007c
  92. fib_NumBlocks    equ  $0080
  93. fib_Date        equ  $0084
  94. fib_Comment    equ  $0090
  95. fib_Reserved    equ  $00e0
  96.  
  97. ;INFO DATA STRUCTURE
  98. id_NumBlocks    equ    12
  99. id_NumBlocksUsed    equ    16
  100. id_BytesPerBlock    equ    20
  101. id_VolumeNode    equ    28
  102.  
  103. ;PROCESS
  104. pr_ReturnAddr    equ    176
  105. pr_CLI        equ    172
  106. pr_CIS        equ    156
  107. pr_COS        equ    160
  108. pr_ConsoleTask    equ    164
  109. pr_StackSize    equ    132
  110. pr_Result2    equ    148
  111. pr_WindowPtr    equ    184
  112. pr_TaskNum    equ    140
  113. pr_CurrentDir    equ    152
  114.  
  115. ;COMMAND LINE INTERFACE
  116. cli_Module    equ    60
  117. cli_CommandName    equ    16
  118. cli_DefaultStack    equ    52
  119. cli_StandardInput    equ    28
  120. cli_StandardOutput    equ    56
  121.  
  122.  
  123. ;FILE HANDLE
  124. fh_Pos        equ    16
  125. fh_End        equ    20
  126. fh_Buf        equ    12
  127.  
  128. *DATESTAMP
  129. ds_Days        equ    0
  130. ds_Minute        equ    4
  131. ds_Tick        equ    8
  132.  
  133. RETURN_OK        EQU  0
  134. RETURN_WARN    EQU  5
  135. RETURN_ERROR    EQU  10
  136. RETURN_FAIL    EQU  20
  137.  
  138. ;AVAIL STUFF
  139. MEMF_PUBLIC    equ 1
  140. MEMF_CHIP        equ 2
  141. MEMF_FAST        equ 4
  142. MEMF_CLEAR    equ $10000
  143. MEMF_LARGEST    equ $20000
  144.  
  145. * ACTIONS
  146. ACTION_SCREEN_MODE    EQU    994
  147. ACTION_INHIBIT    EQU    31
  148. ACTION_MORE_CACHE    EQU    18
  149. ACTION_RENAME_DISK    EQU    9
  150.     
  151. _LVOOpenLibrary    equ    -552
  152. _LVOCloseLibrary    equ    -414
  153. _LVOAllocMem    equ    -198
  154. _LVOFreeMem    equ    -210
  155. _LVORawDoFmt    equ    -522
  156. _LVORawMayGetChar    equ    -510
  157. _LVOFindTask    equ    -294
  158. _LVOForbid    equ    -132
  159. _LVOPermit    equ    -138
  160. _LVOAvailMem    equ    -216
  161. _LVOPutMsg    equ    -366
  162. _LVOGetMsg    equ    -372
  163. _LVOWaitPort    equ    -384
  164. _LVOSetSignal    equ    -306
  165. _LVOAllocSignal    equ    -330
  166. _LVOFreeSignal    equ    -336
  167.  
  168. _LVOSetProtection    equ    -186
  169. _LVOOutput    equ    -60
  170. _LVOWrite        equ    -48
  171. _LVOLock        equ    -84
  172. _LVOUnLock    equ    -90
  173. _LVODupLock    equ    -96
  174. _LVOExamine    equ    -102
  175. _LVOExNext    equ    -108
  176. _LVOOpen        equ    -30
  177. _LVOClose        equ    -36
  178. _LVORead        equ    -42
  179. _LVOInput        equ    -54
  180. _LVODeleteFile    equ    -72
  181. _LVORename    equ    -78
  182. _LVOCreateDir    equ    -120
  183. _LVOCurrentDir    equ    -126
  184. _LVOIoErr        equ    -132
  185. _LVOParentDir    equ    -210
  186. _LVOLoadSeg    equ    -150
  187. _LVOUnLoadSeg    equ    -156
  188. _LVOInfo        equ    -114
  189. _LVODateStamp    equ    -192
  190. _LVOSeek        equ    -66
  191. _LVODeviceProc    equ    -174
  192. _LVODelay        equ    -198
  193.  
  194. _AbsExecBase    equ    4
  195.  
  196. * NEED THESE 2 MACROS FOR A68K ASSEMBLER
  197. blo    macro
  198.     bcs \1
  199.     endm
  200.     
  201. bhs    macro
  202.     bcc \1
  203.     endm
  204.  
  205. *SYSTEM0 stuff!!!!!!!!!!
  206. REG_SysBase    equr a6
  207.  
  208.  
  209. callsys    macro
  210.     jsr _LVO\1(REG_SysBase)
  211.     endm
  212.  
  213. * parameter offsets & stack
  214.  
  215. SAVED_REGS    reg    a2-a6/d2-d3
  216.  
  217. DELTA        equ    7*4
  218.  
  219. ARG_NAME        equ    4+DELTA
  220. ARG_SEGLIST    equ    8+DELTA
  221. ARG_ARGS        equ    12+DELTA
  222.  
  223. * additional return codes
  224.  
  225. NO_CLI        equ    -1
  226. NO_MEM        equ    -2
  227.  
  228. * local constants
  229.  
  230. MAXBSTR        equ    255
  231. LF        equ    10
  232.  
  233. * register usage
  234.  
  235. REG_Result    equr    d3
  236. REG_Process    equr    a2      ;may not be A4, see below!
  237. REG_CLI        equr    a3
  238. REG_CIS        equr    a4      ;may not be A3, see below!
  239. REG_PrevStack    equr    a5
  240.  
  241. * local stack frame
  242.  
  243. * STRUCTURE      StackFrame,0
  244. sf_CommandName    equ    0
  245. sf_CommandArgs    equ    MAXBSTR+1        ;BSTR, length byte!
  246. sf_PrevStack    equ    sf_CommandArgs+MAXBSTR+1        ;not a BSTR, LF-terminated!
  247. sf_SaveReturnAddr    equ    sf_PrevStack+4
  248. sf_SaveModule    equ    sf_SaveReturnAddr+4
  249. sf_SaveCommandName    equ    sf_SaveModule+4
  250. sf_StackBase    equ    sf_SaveCommandName+4
  251. sf_StackSize    equ    sf_StackBase+4
  252. sf_PushSize    equ    sf_StackSize+4
  253. sf_Process    equ    sf_PushSize+4
  254. sf_CLI        equ    sf_Process+4
  255. sf_CIS        equ    sf_CLI+4
  256. sf_SCB_Buf    equ    sf_CIS+4
  257. sf_SCB_Pos    equ    sf_SCB_Buf+4
  258. sf_SCB_End    equ    sf_SCB_Pos+4
  259. sf_SIZEOF        equ    sf_SCB_End+4
  260.  
  261.  
  262. SHELLINE_SIZE    equ    256+128    V1.30
  263. CLIBUF_SIZE    equ    256+128
  264. PATH_SIZE        equ    256    V1.30
  265. HISTORY_SIZE    equ    1024    MUST BE POWER OF 2
  266. SEARCH_STRING_SIZE    equ    60
  267. DEST_LABEL_SIZE    equ    60
  268.  
  269. * THE GENERAL MEMORY BLOCK
  270. blockbase        equ    0    ;the fib or info goes here
  271. outhandle        equ    blockbase+260
  272. inhandle        equ    outhandle+4
  273. parm1        equ    inhandle+4    ;addr of each parameter within shelline
  274. parm2        equ    parm1+4
  275. parm3        equ    parm2+4
  276. parm4        equ    parm3+4
  277. parm5        equ    parm4+4
  278. parm6        equ    parm5+4
  279. parm7        equ    parm6+4
  280. parm8        equ    parm7+4
  281. parm9        equ    parm8+4
  282. parm10        equ    parm9+4
  283. parm11        equ    parm10+4
  284. parm12        equ    parm11+4
  285. parm13        equ    parm12+4
  286. parm14        equ    parm13+4
  287. parm15        equ    parm14+4
  288. endofparms    equ    parm15+4
  289.         
  290. shelline        equ    endofparms
  291. endofshelline    equ    shelline+SHELLINE_SIZE
  292.  
  293. CLIbuf        equ    endofshelline
  294. errorstack    equ    CLIbuf+CLIBUF_SIZE
  295. temp1        equ    errorstack+4
  296. temp2        equ    temp1+4
  297. tempbuf        equ    temp2+4
  298. dosbase        equ    tempbuf+SHELLINE_SIZE
  299. temp2buf        equ    dosbase+4    ;80 char temp buffer
  300. scsize        equ    temp2buf+80
  301. scaddr        equ    scsize+4
  302. scptr        equ    scaddr+4
  303. scflag        equ    scptr+4        new v1.29
  304. patharea        equ    scflag+2
  305. now        equ    patharea+PATH_SIZE
  306. nost        equ    now+4
  307. then        equ    nost+4
  308. past        equ    then+4    ;history buffer=1024 bytes
  309. thistask        equ    past+HISTORY_SIZE
  310. gather_ptr    equ    thistask+4
  311. gather        equ    gather_ptr+4 ;CSI string=20 bytes
  312. tempbytes        equ    gather+20
  313. first_set_defn    equ    tempbytes+2
  314. set_search_string    equ    first_set_defn+4
  315. line_count    equ    set_search_string+SEARCH_STRING_SIZE
  316. mem_addr        equ    line_count+2
  317. wild_flag        equ    mem_addr+4
  318. stat_mode_flag    equ    wild_flag+1
  319. wild_string    equ    stat_mode_flag+1    allow 80 chars for wildcard
  320. date_mark        equ    wild_string+80    3 lwords
  321. mem_mark        equ    date_mark+12    3 lwords chip/fast/total
  322. CD_string        equ    mem_mark+12    Allow 80 bytes.
  323. prompt_string    equ    CD_string+80    Allow 80 bytes.
  324. prompt_args    equ    prompt_string+80    Allow 40 bytes
  325. nonstdin        equ    prompt_args+40    Allow 40 bytes
  326. nonstdout        equ    nonstdin+40    Allow 40 bytes
  327. stdout        equ    nonstdout+40
  328. stdin        equ    stdout+4
  329. mult_comm_flag    equ    stdin+4
  330. next_comm_ptr    equ    mult_comm_flag+2
  331. ctrl_c_flag    equ    next_comm_ptr+4
  332. failat_level    equ    ctrl_c_flag+2    word size
  333. cd_block        equ    failat_level+2
  334. cd_volnode    equ    cd_block+4
  335. recurs_flag    equ    cd_volnode+4
  336. indent_count    equ    recurs_flag+2
  337. resi_head        equ    indent_count+2
  338. resi_flag        equ    resi_head+4
  339. myArg1        equ    resi_flag+2
  340. myArg2        equ    myArg1+4
  341. myArg3        equ    myArg2+4
  342. myArg4        equ    myArg3+4
  343. myArg5        equ    myArg4+4
  344. myArg6        equ    myArg5+4
  345. myArg7        equ    myArg6+4
  346. packettype    equ    myArg7+4
  347. packettask    equ    packettype+4
  348. last_failcode    equ    packettask+4
  349. if_flag        equ    last_failcode+4
  350. if_condition_flag    equ    if_flag+1
  351. goto_flag        equ    if_condition_flag+1
  352. dest_label    equ    goto_flag+2
  353. please_close_me    equ    dest_label+DEST_LABEL_SIZE
  354. mem_offset_addr    equ    please_close_me+4
  355.     
  356. stackbot        equ    mem_offset_addr+4
  357. sizeofblk        equ    stackbot
  358.  
  359.  
  360.  
  361. ********************************************
  362.  
  363.     SECTION    MYSHELL,CODE
  364.     
  365. ;Try to open dos then do the shell
  366. start    move.l a0,entryA0
  367.     move.l d0,entryD0
  368.     move.l    _AbsExecBase,a6
  369.     move.l #sizeofblk,d0
  370.     moveq #0,d1
  371.     jsr _LVOAllocMem(a6)    ;alloc general mem block
  372.     tst.l d0
  373.     beq.s blkfail
  374.     move.l d0,membase
  375.     move.l membase(pc),a5    ;A5=membase
  376. *    move.l _AbsExecBase,a6
  377.     moveq #0,d0
  378.     lea dosname(pc),a1
  379.     jsr _LVOOpenLibrary(a6)
  380.     tst.l d0
  381.     beq.s dosfail
  382.     move.l d0,a6            ;A6 = DOSBASE
  383.     move.l d0,dosbase(a5)
  384.     move.l    d0,_DOSBase        ;V1.02
  385.     bsr    shell            DO IT
  386.     bsr    deallocate_sets        v1.05
  387.     bsr    deallocate_residents
  388.     bsr    raw_off
  389.     move.l a6,a1
  390.     move.l _AbsExecBase,a6
  391.     jsr _LVOCloseLibrary(a6)
  392. dosfail    move.l a5,a1
  393.     move.l #sizeofblk,d0
  394. *    move.l _AbsExecBase,a6
  395.     jsr _LVOFreeMem(a6)    
  396.     moveq #0,d0
  397.     rts
  398. blkfail    moveq #RETURN_ERROR,d0
  399.     rts
  400.     
  401. * SAVE THE CONSOLE HANDLERS
  402. get_handles
  403.     jsr _LVOOutput(a6)
  404.     move.l d0,outhandle(a5)
  405.     move.l    d0,stdout(a5)    V1.13
  406.     jsr _LVOInput(a6)
  407.     move.l d0,inhandle(a5)
  408.     move.l    d0,stdin(a5)
  409.     rts
  410.  
  411. initialise_default_paths
  412.     lea    defpath1(pc),a0
  413.     lea    patharea(a5),a1
  414.     moveq    #10,d0        11 DEFAULT PATHS
  415. idp_1    move.b    (a0)+,(a1)+
  416.     bne.s    idp_1
  417.     dbra    d0,idp_1
  418.     clr.b    (a1)        MAKE SURE 2 ZERO BYTES AT END
  419.     rts
  420.  
  421.     
  422. * PRINT DECIMAL print D0 as decimal
  423. print10    movem.l    d0/a0-a1,-(sp)
  424.     move.l    d0,-(a7)
  425.     move.l    a7,a1
  426.     lea    format(pc),a0
  427.     bsr    new_print
  428.     lea    4(sp),sp
  429.     movem.l    (sp)+,d0/a0-a1
  430.     rts
  431.  
  432.     
  433. *PRINT STRING at a1        ;saves some of the important low registers
  434. pr_space    lea    space(pc),a1
  435.     bra.s    pr_string
  436. pr_tab    lea tab(pc),a1
  437.     bra.s pr_string
  438. pr_prompt    lea prompt_string(a5),a1
  439.     bra.s pr_string    
  440. pr_lf    lea lf(pc),a1
  441. pr_string    movem.l    d0-d3/a0-a3,-(sp)
  442.     move.l    a1,d2
  443.     moveq    #-1,d3
  444. ps1    addq.l    #1,d3
  445.     tst.b    (a1)+
  446.     bne.s    ps1
  447.     move.l    outhandle(a5),d1
  448.     jsr    _LVOWrite(a6)
  449.     movem.l    (sp)+,d0-d3/a0-a3
  450.     rts
  451.  
  452. *CHECK WHETHER A SCRIPT NAME WAS TYPED ON ENTRY TO ZSHELL
  453. execscr    move.l entryA0(pc),a0
  454.     cmpi.b #10,(a0)
  455.     bne.s execscr2
  456.     moveq    #-1,d1        handle DEFAULT SCRIPT FILE login.z
  457.     bsr    changeWindowPtr    disable volume requesters
  458.     lea    defscript1(pc),a2
  459.     move.l    a2,d1
  460.     moveq    #ACCESS_READ,d2
  461.     jsr    _LVOLock(a6)
  462.     tst.l    d0
  463.     bne.s    1$
  464.     lea    defscript2(pc),a2
  465.     move.l    a2,d1
  466.     moveq    #ACCESS_READ,d2
  467.     jsr    _LVOLock(a6)
  468.     tst.l    d0
  469.     beq.s    2$
  470. 1$    move.l    d0,d1
  471.     jsr    _LVOUnLock(a6)
  472.     move.l    a2,a0
  473.     moveq    #0,d1
  474.     bsr    changeWindowPtr
  475.     bra    xz2
  476. 2$    moveq    #0,d1
  477.     bsr    changeWindowPtr
  478.     rts
  479. execscr2    move.l a0,a1
  480. execscr3    cmpi.b #10,(a1)+
  481.     bne.s execscr3
  482.     clr.b -1(a1)    ;A0 pts to CLI residue.
  483.     bra xz2        ;NB this is OK, xz2 will pop the return addr and jump to chorus
  484.  
  485. *MAIN BIT
  486. shell    bsr    get_task            V0.15
  487.     bsr    raw_on
  488.     clr.l    first_set_defn(a5)
  489.     clr.b    stat_mode_flag(a5)        V1.09
  490.     clr.l    resi_head(a5)
  491.     clr.b    if_flag(a5)        No IF
  492.     clr.l    please_close_me(a5)
  493.     clr.b    goto_flag(a5)
  494.     clr.b    scflag(a5)
  495.     clr.l    then(a5)
  496.     clr.l    now(a5)
  497.     clr.l    nost(a5)
  498.     MOVE.W    #10,failat_level(a5)
  499.     move.b    #$a,past(a5)
  500.     clr.b    nonstdin(a5)
  501.     clr.b    nonstdout(a5)
  502.     clr.b    mult_comm_flag(a5)
  503.     bsr    get_handles
  504.     bsr    initialise_default_paths
  505.     bsr    init_prompt
  506.     bsr    eval_CD
  507. *    lea    hello(pc),a1        V1.18    no hello
  508. *    bsr    pr_string
  509.     move.l    a7,errorstack(a5)
  510.     bsr    execscr    
  511. chorus    bsr    raw_on        MAKE SURE RAW MODE IS ON
  512.     bsr    compose_prompt
  513.     bsr    close_redirection
  514.     bsr    get_line
  515.     move.l    parm1(a5),a0
  516.     lea    comtext(pc),a1
  517.     lea    comoffs(pc),a2
  518.     bsr    match
  519.     tst.l    d0
  520.     beq.s    notfound
  521.     lea    start(pc),a0
  522.     move.l    a7,errorstack(a5)
  523.     clr.b    ctrl_c_flag(a5)
  524.     jsr    0(a0,d0.w)    ;call internal command
  525.     tst.b    ctrl_c_flag(a5)
  526.     bne.s    com_fail
  527. chkfail    move.l    d0,last_failcode(a5)
  528.     cmp.w    failat_level(a5),d0    ;ALL COMMANDS MUST RETURN  D0=0 unless failure
  529.     blo.s    chorus
  530. com_fail    clr.b    mult_comm_flag(a5)
  531. *    bsr    print10
  532.     tst.b    scflag(a5)
  533.     beq.s    chorus
  534.     bsr    kill_script
  535.     bra.s    chorus
  536. notfound    bsr    archie3    ;try disk    NOTE V1.02
  537.     move.l    d0,-(sp)
  538.     move.l    thistask(a5),a0
  539.     move.l    cd_volnode(a5),d0
  540.     move.l    pr_CurrentDir(a0),a1
  541.     add.l    a1,a1
  542.     add.l    a1,a1
  543.     cmp.l    fl_Volume(a1),d0    check volume node
  544.     bne.s    1$
  545.     move.l    cd_block(a5),d0
  546.     cmp.l    fl_Key(a1),d0    check disk block number
  547.     beq.s    2$
  548. 1$    bsr    eval_CD    If command changes cd then change prompt.
  549. 2$    move.l    (sp)+,d0
  550. *    bsr    print10
  551.     bra.s    chkfail
  552.  
  553.     
  554. *Match the string pointed to by A0 to one in a table pted to by a1
  555. *The number of the matched string is linked to an offset table pted to by
  556. *A2.  return with 
  557. *D0 holding offset from 'start' so a jsr 0(a0,d0.w) can be done
  558. *Entry    A1 pts to Command text table  A2 pts to command offset table
  559.  
  560.  
  561. match    moveq #0,d1    ;command count
  562.     move.l a0,a3    ;save command
  563. mat2    move.b (a0)+,d0
  564.     cmp.b (a1),d0    ;V1.01
  565.     beq.s mat3
  566.     add.b #$20,d0    ;'A' -> 'a'    handle commands typed in UCase
  567.     cmp.b (a1),d0
  568.     bne.s nextcom    ;if any character wrong then check next
  569. mat3    lea 1(a1),a1
  570.     tst.b -1(a0)    ;check whether 0 was last compared
  571.     beq.s foundit    ;if it was then success
  572.     bra.s mat2
  573. nextcom    tst.b (a1)+
  574.     bne.s nextcom
  575.     addq.l #2,d1    ;each offset is a word
  576.     move.l a3,a0
  577.     tst.b (a1)    ;put 0,0 at end of com table
  578.     bne.s mat2
  579.     moveq #0,d0    ;D0 = 0 if command not found
  580.     rts
  581. foundit    move.w 0(a2,d1.l),d0    ;get offset
  582.     rts
  583.  
  584. get_one_char
  585. read_kbd    lea    tempbytes(a5),a0    V0.15
  586.     move.l    a0,d2
  587.     move.l    inhandle(a5),d1
  588.     moveq    #1,d3
  589.     jsr    _LVORead(a6)
  590.     move.b    tempbytes(a5),d6
  591.     rts
  592.  
  593. * A1 pts to past, d0=nost
  594. gimme    lea    shelline(a5),a2
  595.     move.l    d0,nost(a5)
  596.     cmp.l    now(a5),d0
  597.     bne.s    gimme2
  598.     moveq    #0,d4        clear linmax
  599.     moveq    #0,d5        clear linhere
  600.     lea    delete_line(pc),a1
  601.     bsr    pr_string
  602.     bsr    pr_prompt
  603.     rts
  604. gimme2    moveq    #0,d5        linhere = 0
  605.  
  606. gimme5    addq.l    #1,d0        copy to shelline
  607.     and.l    #HISTORY_SIZE-1,d0
  608.     cmp.b    #$a,0(a1,d0.l)
  609.     beq.s    gimme4
  610.     move.b    0(a1,d0.l),0(a2,d5.l)
  611.     addq.l    #1,d5
  612.     bra.s    gimme5
  613. gimme4    move.l    d5,d4        linmax=linhere
  614. gimme3    lea    delete_line(pc),a1
  615.     bsr    pr_string
  616.     bsr    pr_prompt
  617.     clr.b    0(a2,d4.l)    clear last
  618.     move.l    a2,a1
  619.     bra    pr_string
  620.  
  621.  
  622. * READ TEXT LINE from keyboard or script into buffer pointed to by a0,
  623. * and clear last byte. NOTE A0 is essentially ignored, and shelline is the assumed address
  624. * Return with a0 same, and d0=length of text read
  625. type_in    tst.b scflag(a5)        ;check whether we're doing a script
  626.     bne    scr_in
  627. type_in2    move.l a0,-(sp)
  628. type_in3    moveq    #0,d5        D5=linhere V0.15
  629.     moveq    #0,d4        D4=linmax
  630. next_ch    bsr    get_one_char
  631.     cmp.b    #$9b,d6
  632.     bne    not_csi
  633.     clr.l    gather_ptr(a5)
  634. fetch_csi    bsr    get_one_char
  635.     lea    gather(a5),a0
  636.     move.l    gather_ptr(a5),d0
  637.     move.b    d6,0(a0,d0.l)        ;save byte from CSI sequence.
  638.     addq.l    #1,gather_ptr(a5)
  639.     cmp.b    #'@',d6
  640.     blo.s    fetch_csi        ;keep gathering if char < @
  641.     cmp.b    #'~',d6
  642.     bhi.s    fetch_csi        ;keep gathering if char > ~
  643.  
  644.     cmp.b    #'D',d6        CHECK LEFT ARROW    <CSI>D
  645.     bne.s    not_left
  646.     tst.l    d5
  647.     beq.s    not_left
  648.     subq.l    #1,d5
  649.     lea    left_cursor(pc),a1
  650.     bsr    pr_string
  651.     bra    next_ch
  652.     
  653. not_left    cmp.b    #'A',d6
  654.     bne.s    not_sh_left
  655.     cmp.b    #' ',gather(a5)    CHECK SHIFT LEFT ARROW <CSI> A
  656.     bne.s    not_sh_left
  657. move_left    tst.l    d5
  658.     beq.s    next_ch
  659.     subq.l    #1,d5
  660.     lea    left_cursor(pc),a1
  661.     bsr    pr_string
  662.     lea    shelline(a5),a0
  663.     cmp.b    #' ',-1(a0,d5.w)
  664.     bne.s    move_left
  665.     bra.s    next_ch
  666.     
  667. not_sh_left
  668.     cmp.b    #'C',d6        CHECK RIGHT ARROW    <CSI>C
  669.     bne.s    not_right
  670.     cmp.l    d4,d5
  671.     bhs.s    not_right
  672.     addq.l    #1,d5
  673.     lea    right_cursor(pc),a1
  674.     bsr    pr_string
  675.     bra    next_ch
  676.  
  677. not_right    cmp.b    #'@',d6
  678.     bne.s    not_sh_right
  679.     cmp.b    #' ',gather(a5)    CHECK SHIFT RIGHT ARROW <CSI> @
  680.     bne.s    not_sh_right
  681. move_ryt    cmp.l    d4,d5
  682.     bhs    next_ch
  683.     addq.l    #1,d5
  684.     lea    right_cursor(pc),a1
  685.     bsr    pr_string
  686.     lea    shelline(a5),a0
  687.     cmp.b    #' ',-1(a0,d5.w)
  688.     bne.s    move_ryt
  689.     bra    next_ch
  690.     
  691. not_sh_right
  692.     cmp.b    #'A',d6        CHECK UP ARROW
  693.     bne.s    not_up
  694.     lea    past(a5),a1
  695.     move.l    nost(a5),d0
  696.     cmp.l    then(a5),d0
  697.     beq.s    no_srch_back
  698.     
  699. db1    subq.l    #1,d0
  700.     and.l    #HISTORY_SIZE-1,d0        WRAP AROUND
  701.     cmp.b    #$a,0(a1,d0.l)
  702.     bne.s    db1
  703. no_srch_back
  704.     bsr    gimme
  705.     bra    next_ch
  706.  
  707. not_up    cmp.b    #'B',d6        CHECK DOWN ARROW
  708.     bne.s    not_down
  709. up_bit    lea    past(a5),a1    CALLED BY SHIFT DOWN BIT
  710.     move.l    nost(a5),d0
  711.     cmp.l    now(a5),d0
  712.     beq.s    no_srch_fwd
  713. ub1    addq.l    #1,d0
  714.     and.l    #HISTORY_SIZE-1,d0
  715.     cmp.b    #$a,0(a1,d0.l)
  716.     bne.s    ub1
  717. no_srch_fwd
  718.     bsr    gimme
  719.     bra    next_ch
  720.  
  721. not_down    cmp.b    #'T',d6        CHECK SHIFT UP
  722.     bne.s    not_sh_up
  723.     lea    past(a5),a1
  724.     move.l    then(a5),nost(a5)    nost = then (the top)
  725.     move.l    nost(a5),d0
  726.     bsr    gimme
  727.     bra    next_ch
  728.  
  729. not_sh_up    cmp.b    #'S',d6        CHECK SHIFT DOWN
  730.     bne.s    not_sh_down
  731.     move.l    now(a5),nost(a5)    nost = now (the bottom)
  732.     bra.s    up_bit
  733.     
  734. not_sh_down            ;NOTE V1.05
  735.     cmp.b    #'~',d6        CHECK FUNCTION KEYS AND HELP KEY
  736.     bne    next_ch
  737.     cmp.b    #'?',gather(a5)
  738.     bne.s    process_the_func_key
  739.     lea    help_ret(pc),a1
  740.     move.l    d0,-(sp)        need crap on stack to call print_def
  741.     bsr    print_def        will rip last 2 addrs off stack
  742. * never gets to this line
  743. process_the_func_key
  744.     bsr    translate_func_key
  745.     bra    next_ch
  746.         
  747. not_csi    cmp.b    #8,d6        CHECK BACKSPACE
  748.     bne.s    not_bs
  749.     tst.l    d5
  750.     beq.s    not_bs
  751.     subq.l    #1,d5
  752.     lea    backspace_it(pc),a1
  753.     bsr    pr_string
  754. del_str    lea    shelline(a5),a4
  755.     lea    SHELLINE_SIZE+shelline(a5),a1    NOTE SHELLINE SIZE!!!
  756.     lea    0(a4,d5.w),a0
  757.     lea    1(a0),a2
  758. bs_1    move.b    (a2)+,(a0)+
  759.     cmp.l    a2,a1
  760.     bne.s    bs_1
  761.     subq.l    #1,d4
  762.     bra    next_ch
  763.  
  764. not_bs    cmp.b    #$7f,d6        CHECK DELETE
  765.     bne.s    not_del
  766.     cmp.l    d4,d5
  767.     bhs.s    not_del
  768.     lea    delete_it(pc),a1
  769.     bsr    pr_string
  770.     bra.s    del_str
  771.     
  772. not_del    cmp.b    #$18,d6        CHECK CTRL X
  773.     bne.s    not_ctrlx
  774.     moveq    #0,d5
  775.     moveq    #0,d4
  776.     lea    delete_line2(pc),a1
  777.     bsr    pr_string
  778.     bsr    pr_prompt
  779.     bra    next_ch
  780.     
  781. not_ctrlx    cmp.b    #$05,d6        CHECK CTRL E
  782.     bne.s    not_ctrle
  783. seek_ryt    cmp.l    d4,d5        send cursor to end of line
  784.     bhs    next_ch
  785.     addq.l    #1,d5
  786.     lea    right_cursor(pc),a1
  787.     bsr    pr_string
  788.     bra.s    seek_ryt
  789.     
  790. not_ctrle    cmp.b    #$1a,d6        CHECK CTRL Z
  791.     bne.s    not_ctrlz
  792. seek_left    tst.l    d5        send cursor to start of line
  793.     beq    next_ch
  794.     subq.l    #1,d5
  795.     lea    left_cursor(pc),a1
  796.     bsr    pr_string
  797.     bra.s    seek_left
  798.     
  799. not_ctrlz    cmp.b    #$d,d6        check CR
  800.     bne    no_cr
  801. do_cr    lea    return_it(pc),a1
  802.     bsr    pr_string
  803.     lea    shelline(a5),a4
  804.     move.b    #10,0(a4,d4.w)    HACK JOB    (MUST END IN LF 0)
  805.     clr.b    1(a4,d4.w)    FOR ALIAS STUFF
  806.     tst.l    d4        CHECK IF NOTHING TYPED
  807.     bne.s    history_it
  808.     bsr    pr_prompt        IF JUST HIT RETURN, THEN START AGAIN
  809.     bra    type_in3
  810. history_it
  811.     lea    past(a5),a1    CHECK IF LAST ENTRY IS SAME AS CURRENT
  812.     move.l    now(a5),d0
  813.     cmp.l    then(a5),d0
  814.     beq.s    2$
  815.     move.l    d0,nost(a5)
  816. 1$    subq.l    #1,d0        FIND LAST
  817.     and.l    #HISTORY_SIZE-1,d0    WRAP AROUND
  818.     cmp.b    #$a,0(a1,d0.l)
  819.     bne.s    1$
  820.     lea    (a4),a0
  821.     bra.s    3$
  822. 4$    cmp.b    #$a,d1        COMPARE LAST TO SHELLINE
  823.     beq    finland
  824. 3$    addq.l    #1,d0
  825.     and.l    #HISTORY_SIZE-1,d0
  826.     move.b    (a0)+,d1
  827.     cmp.b    0(a1,d0.l),d1
  828.     beq.s    4$
  829.  
  830. 2$    move.l    a4,a3    lin    COPY LINE TO HISTORY  BUFFER
  831.     move.l    now(a5),d3    pts to the last LF
  832.  
  833. 5$    addq.l    #1,d3
  834.     and.l    #HISTORY_SIZE-1,d3        WRAP AROUND
  835.     move.b    (a3)+,d0
  836.     move.b    d0,0(a1,d3.l)
  837.     cmp.b    #10,d0
  838.     bne.s    5$
  839. dumped_hist
  840.     move.l    d3,nost(a5)    nost = now
  841.     move.l    d3,now(a5)
  842.     move.l    then(a5),d1
  843.     cmp.b    #$a,0(a1,d1.l)
  844.     bne.s    wxv1    BRANCH IF WRAPPED AROUND
  845.     cmp.l    d3,d1
  846.     bne.s    finland    BRANCH IF THEN = (10) & THEN <> NOW
  847. wxv1    
  848. *    move.l    d3,then(a5)    then=now
  849. wxv3    addq.l    #1,d3    SEARCH FOR NEXT LF (NEW TOP OF HISTORY)
  850.     and.l    #HISTORY_SIZE-1,d3        WRAP AROUND
  851.     move.b    0(a1,d3.l),d0
  852.     cmp.b    #$a,d0
  853.     bne.s    wxv3        ***
  854. wxv2    move.l    d3,then(a5) SET NEW THEN (TOP OF HISTORY)
  855.  
  856. ******* 
  857. finland
  858.     move.l (sp)+,a0
  859.     rts
  860.  
  861. no_cr    cmp.b    #' ',d6
  862.     blo.s    dunno_it
  863.     cmp.b    #'~',d6
  864.     bhi.s    dunno_it
  865.     cmp.w    #SHELLINE_SIZE-2,d4        make sure line is not too long
  866.     bhi.s    dunno_it
  867.     lea    insert_it(pc),a1
  868.     move.b    d6,2(a1)        shove printable char after insert seq
  869.     bsr    pr_string        insert space for char
  870.     lea    shelline(a5),a1    ethel
  871.     lea    1(a1,d4.w),a0    linmax
  872.     lea    1(a0),a2        A2=linmax+1
  873.     lea    0(a1,d5.w),a1    linhere
  874. tc_1    move.b    -(a0),-(a2)    insert char into shelline
  875.     cmp.l    a0,a1
  876.     bne.s    tc_1
  877. plop_ch    lea    shelline(a5),a4
  878.     move.b    d6,0(a4,d5.w)
  879.     addq.l    #1,d5
  880.     addq.l    #1,d4
  881. dunno_it    
  882.     BRA    next_ch
  883.  
  884. * TRANSLATE FUNC CODE TO F1,F2 ETC AND SET UP POINTERS
  885. translate_func_key
  886.     lea    gather(a5),a0
  887.     move.l    gather_ptr(a5),d0
  888.     cmp.b    #3,d0        CHECK IF TWO CODES EG '12'
  889.     beq    process_shift_func
  890. unshifted_func_key
  891.     cmp.b    #2,d0
  892.     bne    translate_func_fail
  893.     move.b    (A0),d0
  894.     moveq    #'f',d1
  895. act_sh    bsr    convert_to_set_name
  896.     bsr    search_sets    returns D0 pointer to set
  897.     bsr    print_func_defn
  898.     rts
  899. process_shift_func
  900.     move.b    1(A0),d0
  901.     moveq    #'F',d1
  902.     bra.s    act_sh
  903. translate_func_fail
  904.     rts
  905.  
  906. *d0=set ptr
  907. print_func_defn
  908.     tst.l    d0
  909.     beq    do_not_print_func
  910.     move.l    d0,a1
  911.     lea    set_defn(a1),a1
  912. print_def    lea    shelline(a5),a2
  913.     bra.s    2$
  914. 1$    addq.l    #1,d5        copy defn to shelline
  915. 2$    move.b    (a1)+,0(a2,d5.l)
  916.     bne.s    1$
  917.     cmp.b    #'M',-1(a2,d5.l)    check for auto return ^M
  918.     bne.s    3$
  919.     cmp.b    #'^',-2(a2,d5.l)
  920.     bne.s    3$
  921.     subq.l    #2,d5
  922.     move.l    d5,d4
  923.     bsr    gimme3        print it
  924.     movem.l    (sp)+,d0-d1    get rid of last 2 return addresses
  925.     bra    do_cr        do a carriage return
  926.  
  927. 3$    move.l    d5,d4        linmax=linhere
  928.     bra    gimme3        show prompt,new line
  929. do_not_print_func
  930.     rts
  931.     
  932. convert_to_set_name
  933.     lea    set_search_string(a5),a1
  934.     move.b    d1,(a1)+
  935.     addq.b    #1,d0
  936.     move.b    d0,(a1)+
  937.     cmp.b    #':',d0
  938.     bne    not_func10
  939.     move.b    #'1',-1(a1)
  940.     move.b    #'0',(a1)+
  941. not_func10
  942.     clr.b    (a1)
  943.     rts
  944.  
  945. search_sets
  946. * uses set_search_string, EXIT: D0 ptr to the associated set. D1 pts to prior set
  947. * RETURN D0=0 IF NOT FOUND.
  948.     movem.l    d2-d4/a1-a2,-(sp)
  949.     lea    set_search_string(a5),a1
  950.     move.l    a1,d2
  951.     lea    first_set_defn(a5),a2
  952.     move.l    a2,d4        NOTE PRIOR SET 
  953.     move.l    (a2),d3
  954. search_next_set
  955.     beq    2$
  956.     move.l    d3,a2
  957.     lea    set_name(a2),a2    A2=current set name
  958.     move.l    d2,a1        A1=name to match
  959.     bra.s    3$
  960. 1$    tst.b    d0
  961.     beq.s    2$
  962. 3$    move.b    (a1)+,d0
  963.     move.b    (a2)+,d1
  964.     bsr    compD1D0nocase
  965.     beq.s    1$
  966.  
  967.     move.l    d3,a2
  968.     move.l    d3,d4
  969.     move.l    (a2),d3
  970.     bra    search_next_set
  971. 2$    move.l    d3,d0
  972.     move.l    d4,d1
  973.     
  974.     movem.l    (sp)+,d2-d4/a1-a2
  975.     rts
  976.  
  977.  
  978. * DO SCRIPT FILE STUFF   ENTRY A0 -> input line
  979. scr_in    bsr    check_c
  980.     bne.s    terminate_script
  981.     move.l scsize(a5),d0    ;read a line from the script file
  982.     add.l scaddr(a5),d0
  983.     cmp.l scptr(a5),d0
  984.     bgt.s scr_in2
  985. terminate_script
  986.     bsr    kill_script
  987.     bsr    pr_prompt
  988.     bra type_in2
  989. scr_in2    move.l a0,a2
  990.     moveq #0,d0
  991.     move.l scptr(a5),a1
  992. 1$    move.b    (a1)+,(a2)+
  993.     addq.l    #1,d0
  994.     cmp.b    #10,(a1)
  995.     bne.s    1$
  996.     move.b    (a1)+,(a2)+    LF
  997.     clr.b    (a2)        0
  998.     move.l    a1,scptr(a5)
  999.     rts
  1000.  
  1001.  
  1002. kill_script
  1003.     move.l    a0,-(sp)
  1004.     clr.b    scflag(a5)    clean up if no more lines left
  1005.     clr.b    if_flag(a5)    Make sure if structure ends
  1006.     clr.b    goto_flag(a5)    Make sure goto is terminated
  1007.     move.l    scaddr(a5),a1
  1008.     move.l    scsize(a5),d0
  1009.     bsr    givemem
  1010.     move.l    (sp)+,a0
  1011.     rts
  1012.  
  1013. ** SAME AS compare_strings EXCEPT
  1014. ** ALLOWS FOR A1 ENDING IN LF
  1015. lf_compare_strings
  1016.     movem.l    a0-a1/d0-d1,-(sp)
  1017.     bra.s    1$
  1018. 2$    tst.b    d0
  1019.     beq.s    3$    RETURN EQ
  1020. 1$    move.b    (a0)+,d0
  1021.     move.b    (a1)+,d1
  1022.     bsr    compD1D0nocase
  1023.     beq.s    2$    return NE
  1024.     tst.b    d0
  1025.     bne.s    3$
  1026.     cmp.b    #10,d1
  1027. 3$    movem.l    (sp)+,a0-a1/d0-d1
  1028.     rts
  1029.  
  1030.     
  1031. ** CASE INDEPENDENT STRING COMPARE. COMPARES (A0) TO (A1)
  1032. ** RETURN EQ IF SAME
  1033. compare_strings
  1034.     movem.l    a0-a1/d0-d1,-(sp)
  1035.     bra.s    1$
  1036. 2$    tst.b    d0
  1037.     beq.s    3$    RETURN EQ
  1038. 1$    move.b    (a0)+,d0
  1039.     move.b    (a1)+,d1
  1040.     bsr    compD1D0nocase
  1041.     beq.s    2$    return NE
  1042. 3$    movem.l    (sp)+,a0-a1/d0-d1
  1043.     rts
  1044.  
  1045.     
  1046. * COPY STRING :copys null ending string from A0 to A1, Return with D0=length+1
  1047. cp_string    movem.l a0-a1,-(sp)
  1048.     moveq #0,d0
  1049. cp_str1    addq.l #1,d0
  1050.     move.b (a0)+,(a1)+
  1051.     bne.s cp_str1
  1052.     movem.l (sp)+,a0-a1
  1053.     rts
  1054.  
  1055. *Get line of text and seperate into up to 6 parameters    
  1056. get_line    bsr clr_parms
  1057.     lea shelline(a5),a0
  1058.     tst.b    mult_comm_flag(a5)    SKIP PROMPT IF SCRIPT OR MULT COMMANDS
  1059.     bne.s    1$
  1060.     tst.b scflag(a5)
  1061.     bne.s    2$
  1062.     bsr pr_prompt
  1063. 2$    bsr type_in    NOTE HISTORY STUFF ASSUMES SHELLINE HOLDS THE LINE
  1064.     cmp.b    #';',(a0)        ;is 1st character a ';'
  1065.     beq.s    3$
  1066.     cmp.b    #'*',(a0)
  1067.     beq.s    3$
  1068.     cmp.b    #'#',(a0)
  1069.     bne.s    1$
  1070. 3$    move.l    (sp)+,d0        ;kill return address
  1071.     bra    chorus        ;do next line if comment
  1072. 1$    bsr    handle_mult_comms    MAYBE ALTER A0
  1073.     bsr    handle_command_alias
  1074. *    move.l    a0,-(sp)        TEST STUFF
  1075. *    move.l    a0,a1
  1076. *    bsr    pr_string
  1077. *    move.l    (sp)+,a0
  1078.     bsr    handle_redirection
  1079. gl16    lea parm1(a5),a2        ;do 1st parm seperate to establish CLI residue
  1080.     bsr get_parm
  1081.     move.l a0,d7
  1082.     tst.l d2
  1083.     beq.s gl3            if no parms at all
  1084.     tst.b    goto_flag(a5)    CHECK IF IN GOTO SEARCH MODE
  1085.     beq.s    test_ifs
  1086.     move.l    a0,-(sp)
  1087.     lea    label_tx(pc),a0
  1088.     bsr    lf_compare_strings
  1089.     bne    skipline
  1090.     move.l    (sp)+,a0
  1091.     
  1092. test_ifs    tst.b    if_flag(a5)    0 if if encountered earlier
  1093.     beq.s    no_ifs
  1094.     tst.b    if_condition_flag(a5)    0 if condition TRUE
  1095.     beq    no_ifs
  1096. if_false    move.l    a0,-(sp)        push ptr to next
  1097.     lea    else_tx(pc),a0
  1098.     bsr    lf_compare_strings
  1099.     bne.s    try_endif
  1100.     not.b    if_condition_flag(a5)    flip condition flag
  1101. skipline    movem.l    (sp)+,d0-d1    get rid of last plus return address
  1102.     bra    chorus
  1103. try_endif    lea    endif_tx(pc),a0
  1104.     bsr    lf_compare_strings
  1105.     bne.s    skipline
  1106.     clr.b    if_flag(a5)
  1107.     bra.s    skipline
  1108.     
  1109. no_ifs    move.l a1,(a2)+        save address of parm1
  1110.     
  1111.     lea CLIbuf(a5),a1
  1112.     bra.s    1$
  1113. 2$    move.b    d0,(a1)+
  1114. 1$    move.b    (a0)+,d0        copy sudoCLIresidue out
  1115.     cmp.b    #10,d0        only look for LF end
  1116.     bne.s    2$
  1117.     clr.b    (a1)        null end the copy
  1118.     move.l d7,a0
  1119.     lea endofparms(a5),a4        ;establish end of parms block
  1120. gl4    bsr get_parm        
  1121.     tst.l d2
  1122.     beq.s gl3
  1123.     move.l a1,(a2)+
  1124.     cmp.l a2,a4        ;get out if more than 10 parms
  1125.     bne.s gl4
  1126.     clr.b (a0)        ;make sure parm6 ends in 0
  1127. gl3    rts
  1128.  
  1129. endifz    clr.b    if_flag(a5)
  1130.     moveq    #RETURN_OK,d0
  1131.     rts
  1132. elsez    not.b    if_condition_flag(a5)
  1133.     moveq    #RETURN_OK,d0
  1134.     rts
  1135.  
  1136. *******************************
  1137. *        GOTO COMMAND    *
  1138. *******************************
  1139.     
  1140. gotoz    move.l    parm2(a5),d1
  1141.     bne    test_gs
  1142. goto_err    lea    goto_error_tx(pc),a1
  1143.     bsr    pr_string
  1144.     moveq    #RETURN_ERROR,d0
  1145.     rts
  1146. test_gs    tst.b    scflag(a5)    CAN ONLY GOTO FROM WITHIN SCRIPT
  1147.     beq    goto_err
  1148.  
  1149.     move.l    d1,a0
  1150.     lea    dest_label(a5),a1
  1151. 2$    move.b    (a0)+,(a1)+
  1152.     bne.s    2$
  1153.     move.l    scaddr(a5),scptr(a5)  RESET TO START OF SCRIPT
  1154.     move.b    #$ff,goto_flag(a5)
  1155.     clr.b    if_flag(a5)    MAKE SURE IF IS TERMINATED
  1156.     moveq    #RETURN_OK,d0
  1157.     rts
  1158.     
  1159. ** LABEL COMMAND. DOES NOTHING IF NOT IN GOTO SEARCH MODE
  1160. labelz    tst.b    goto_flag(a5)
  1161.     bne.s    1$
  1162. 2$    moveq    #RETURN_OK,D0
  1163.     RTS
  1164. 1$    move.l    parm2(a5),d0
  1165.     beq    2$
  1166.     move.l    d0,a0
  1167.     lea    dest_label(a5),a1
  1168.     bsr    compare_strings
  1169.     bne    2$
  1170.     clr.b    goto_flag(a5)
  1171.     bra    2$
  1172.     
  1173.     
  1174. *ENTRY A0=shelline    ONLY HANDLES ALIASES OF FIRST KEYWORD.
  1175. handle_command_alias
  1176.     movem.l    a1-a4/d0-d2,-(sp)
  1177.     cmp.b    #10,(a0)
  1178.     beq    hca_nothing_typed
  1179.     move.l    a0,a1
  1180.     lea    tempbuf(a5),a3
  1181.     move.b    #10,(a3)
  1182.     clr.b    1(a3)    must be null end string
  1183.     lea    set_search_string(a5),a2    COPY PARM AT A0 TO SEARCH STR
  1184. 2$    move.b    (a1)+,(a2)+
  1185.     cmp.b    #10,(a1)
  1186.     beq.s    4$        hca_one_parm
  1187.     cmp.b    #$20,(a1)
  1188.     bne.s    2$
  1189. 4$    move.b    (a1)+,(a3)+    COPY FROM SPACE ONWARDS to tempbuf
  1190.     bne.s    4$    WHOLE LINE ENDS IN NULL.
  1191. hca_one_parm
  1192.     clr.b    (a2)    null end search string
  1193.  
  1194. hca_find_it
  1195.     move.l    a0,-(sp)
  1196.     bsr    search_sets
  1197.     move.l    (sp)+,a0
  1198.     tst.l    d0
  1199.     beq    hca_nothing_typed
  1200.     move.l    d0,a2
  1201.  
  1202.     lea    set_defn(a2),a2    A2=set defn
  1203.     lea    tempbuf(a5),a3    A3=line after alias
  1204.     move.l    a0,a1        A1=shelline ptr
  1205.     moveq    #7,d0
  1206. 6$    clr.l    -(sp)        push down eight times 0=no entry.
  1207.     dbra    d0,6$
  1208. 5$    move.b    (a2)+,d0        handle %1...$1
  1209.     beq    not_much_of_an_alias
  1210.     cmp.b    #$20,d0        skip spaces
  1211.     beq.s    5$
  1212.     cmp.b    #'%',d0
  1213.     bne.s    no_extra_parms
  1214.     move.b    (a2)+,d0
  1215.     and.w    #$0007,d0        only allow %0 --> %7
  1216. 1$    move.b    (a3)+,d1        find where the next param starts
  1217.     cmp.b    #10,d1
  1218.     beq.s    3$        if no param then pt A3 to lf again
  1219.     cmp.b    #$20,d1
  1220.     beq.s    1$
  1221. 4$    lsl.w    #2,d0        x 4
  1222.     move.l    a3,0(a7,d0.w)
  1223.     subq.l    #1,0(a7,d0.w)    put address of param on stack
  1224. 2$    move.b    (a3)+,d1        get a3 to pt to next space
  1225.     cmp.b    #10,d1
  1226.     beq    3$
  1227.     cmp.b    #$20,d1
  1228.     bne.s    2$
  1229. 3$    lea    -1(a3),a3        a3 ts to space
  1230.     bra.s    5$        do for more params
  1231. get_next_character
  1232.     move.b    (a2)+,d0
  1233. no_extra_parms
  1234.     cmp.b    #'$',d0
  1235.     bne.s    1$
  1236.     move.b    (a2)+,d0        grab number after $
  1237.     beq.s    not_much_of_an_alias
  1238.     and.w    #$0007,d0
  1239.     lsl.w    #2,d0        x 4
  1240.     move.l    0(a7,d0.w),d1
  1241.     beq.s    get_next_character
  1242.     move.l    d1,a4
  1243. 2$    move.b    (a4)+,(a1)+    copy param N
  1244.     cmp.b    #10,(a4)
  1245.     beq.s    3$
  1246.     cmp.b    #$20,(a4)
  1247.     bne.s    2$
  1248. 3$    bra.s    get_next_character
  1249. 1$    move.b    d0,(a1)+        copy DEFN -> SHELLINE
  1250.     tst.b    d0
  1251.     bne.s    get_next_character
  1252.  
  1253.     lea    -1(a1),a1
  1254. not_much_of_an_alias
  1255.     lea    32(sp),sp        ** NOTE STACK CHANGE
  1256. 4$    move.b    (a3)+,(a1)+    copy tempbuf onto end
  1257.     bne.s    4$
  1258.     clr.b    mult_comm_flag(a5)
  1259.     bsr    handle_mult_comms
  1260.     bsr    handle_command_alias
  1261.     clr.b    mult_comm_flag(a5)
  1262.     bsr    handle_mult_comms    put LF at end Allow for aliases with ;'s
  1263.     
  1264. hca_nothing_typed
  1265.     movem.l    (sp)+,a1-a4/d0-d2
  1266.     rts
  1267.  
  1268.  
  1269.     
  1270. clr_parms    movem.l    a0-a1,-(sp)
  1271.     lea    parm1(a5),a0
  1272.     lea    endofparms(a5),a1
  1273. clr_loop1    clr.l    (a0)+
  1274.     cmp.l    a0,a1
  1275.     bne.s    clr_loop1
  1276.     movem.l    (sp)+,a0-a1
  1277.     rts
  1278.  
  1279. * GET PARM line pted to by A0
  1280. * LINE MUST END IN LF THEN 0
  1281. * returns A1 pointing to the address where the parm starts
  1282. * puts a 0 over the space or lf where it ends .A0 pts to next bit on end
  1283. * return d2=0 if got all possible commands from line
  1284. get_parm    moveq    #$20,d2    D2=delimiter
  1285. get_parm1    move.l    a0,a1    ;make sure we can get the address before
  1286.     move.b    (a0)+,d1    ;skip spaces
  1287.     cmp.b    #$20,d1
  1288.     beq.s    get_parm1
  1289.     cmp.b    #$9,d1    skip tabs
  1290.     beq.s    get_parm1
  1291.     cmp.b    #$0a,d1    ;handle idiots who type spaces at end of line
  1292.     beq.s    last_parm
  1293.     cmp.b    #'"',d1    ;handle double quotes
  1294.     bne.s    gp2
  1295.     lea    1(a1),a1
  1296.     moveq    #'"',d2    SET DELIMITER = "
  1297. gp4    move.b    (a0)+,d1    ;make sure pts to after quotes d1 is dummy
  1298. gp2    move.b    (a0)+,d1    ;a0 pts to after the space on exit
  1299.     cmp.b    #$0a,d1
  1300.     beq.s    gp3
  1301.     cmp.b    #'\',d1    allow for \" (nested quotes)
  1302.     beq.s    gp4
  1303.     cmp.b    d2,d1
  1304.     bne.s    gp2
  1305.     clr.b -1(a0)    ;make sure last byte is 0
  1306.     rts
  1307. last_parm    clr.b -1(a0)
  1308.     moveq #0,d2    ;signify the end
  1309.     rts
  1310. gp3    lea -1(a0),a0    if ends in LF then dont null end, catch that next time
  1311.     rts
  1312.  
  1313. close_redirection
  1314.     tst.b    nonstdin(a5)
  1315.     beq    cls_outred
  1316.     move.l    thistask(a5),a0
  1317.     move.l    pr_CIS(a0),d1
  1318.     move.l    stdin(a5),pr_CIS(a0)    restore old stdin
  1319.     move.l    stdin(a5),inhandle(a5)
  1320.     jsr    _LVOClose(a6)
  1321.     clr.b    nonstdin(a5)
  1322. cls_outred
  1323.     tst.b    nonstdout(a5)
  1324.     beq    cls_nothing
  1325.     move.l    thistask(a5),a0
  1326.     move.l    pr_COS(a0),d1
  1327.     move.l    stdout(a5),pr_COS(a0)    restore old stdout
  1328.     move.l    stdout(a5),outhandle(a5)    
  1329.     jsr    _LVOClose(a6)
  1330.     clr.b    nonstdout(a5)
  1331. cls_nothing
  1332.     rts
  1333.     
  1334. * entry A0 pts to shelline
  1335. handle_redirection
  1336.     movem.l    a0-a2/d0,-(sp)
  1337. redir_2    move.b    (a0)+,d0    CHECK FOR REDIRECTION CHARS < >
  1338.     cmp.b    #$0A,d0
  1339.     beq    redir_fin
  1340.     cmp.b    #'"',d0    HANDLE QUOTES
  1341.     bne.s    1$
  1342. *    bsr    new_print
  1343. 2$    move.b    (a0)+,d0
  1344.     cmp.b    #10,d0
  1345.     beq    redir_fin
  1346.     cmp.b    #'"',d0
  1347.     bne.s    2$
  1348. 1$    cmp.b    #$20,d0
  1349.     bne.s    redir_2
  1350.     move.b    (a0),d0    TEST CHAR AFTER SPACE.
  1351.     cmp.b    #'>',d0
  1352.     beq.s    redir_out
  1353.     cmp.b    #'<',d0
  1354.     bne.s    redir_2
  1355. redir_in    lea    nonstdin(a5),a2
  1356.     move.l    #MODE_OLDFILE,d2
  1357.     bsr    redir_open
  1358.     move.l    thistask(a5),a0
  1359.     move.l    d0,pr_CIS(a0)    MAKE STDIN DIFFERENT.
  1360.     move.l    d0,inhandle(a5)
  1361.     move.l    a3,a0
  1362.     bra    redir_2        KEEP SEARCHING
  1363. redir_out    cmp.b    #'>',1(a0)
  1364.     beq.s    redir_append
  1365.     lea    nonstdout(a5),a2
  1366.     move.l    #MODE_NEWFILE,d2
  1367.     bsr    redir_open
  1368.     move.l    thistask(a5),a0
  1369.     move.l    d0,pr_COS(a0)
  1370.     move.l    d0,outhandle(a5)
  1371.     move.l    a3,a0
  1372.     bra    redir_2
  1373. redir_append
  1374.     lea    nonstdout(a5),a2
  1375.     move.l    #MODE_OLDFILE,d2
  1376.     bsr    redir_open
  1377.     move.l    thistask(a5),a0
  1378.     move.l    d0,pr_COS(a0)
  1379.     move.l    d0,outhandle(a5)
  1380.     move.l    d0,d1
  1381.     moveq    #0,d2    set position
  1382.     moveq    #1,d3    set mode
  1383.     jsr    _LVOSeek(a6)
  1384.     move.l    a3,a0
  1385.     bra    redir_2
  1386.     
  1387. redir_fin
  1388.     movem.l    (sp)+,a0-a2/d0
  1389.     rts
  1390.  
  1391. redir_open
  1392.     lea    -1(a0),a3        ALIGN WITH SPACE
  1393.     bsr    copy_redirector
  1394.     move.l    a2,d1
  1395.     jsr    _LVOOpen(a6)
  1396.     tst.l    d0
  1397.     bne.s    redopefin
  1398.     clr.b    (a2)
  1399.     bra    DOSerr
  1400. redopefin    rts
  1401.     
  1402. ** ENTRY A0 pts redirection symbol. A2 pts to area to save redirection name
  1403. ** EXIT A2 area holds null end string and redirection name is deleted from
  1404. **      shelline
  1405. copy_redirector
  1406.     movem.l    a0-a2,-(sp)
  1407.     move.l    a0,a1    SAVE START OF REDIRECTION STRING
  1408.     move.b    (a0)+,d0    BUMP PAST '<' or '>'
  1409. cpred3    move.b    (a0)+,d0
  1410.     cmp.b    #$20,d0
  1411.     beq.s    cpredsp
  1412.     cmp.b    #$0A,d0
  1413.     beq.s    cpredlf
  1414.     cmp.b    #'>',d0    HANDLE APPEND REDIRECTION PROPERLY
  1415.     beq.s    cpred3
  1416.     move.b    d0,(a2)+    COPY NEWSTDIN/OUT TO NONSTDIN/OUT
  1417.     bra.s    cpred3
  1418. cpredlf    lea    -1(a0),a0
  1419.     lea    -1(a1),a1
  1420. cpredsp    clr.b    (a2)+    A0 should point to after the space or lf
  1421.     lea    shelline+SHELLINE_SIZE(a5),a2
  1422.     move.l    a1,d0
  1423.     sub.l    a0,d0
  1424.     add.l    d0,next_comm_ptr(a5)    offset next_comm_ptr
  1425. cpred5    move.b    (a0)+,(a1)+    delete redirection string from shelline
  1426.     cmp.l    a0,a2
  1427.     bhi.s    cpred5
  1428.     movem.l    (sp)+,a0-a2
  1429.     rts
  1430.  
  1431. ** V1.14 multiple commands on command line. Delimit by ';'
  1432. * ENTRY A0 pts to shelline, EXIT A0 pts to start of next bit on line.
  1433. handle_mult_comms
  1434.     movem.l    a1/d0,-(sp)
  1435.     tst.b    mult_comm_flag(a5)
  1436.     beq.s    1$
  1437.     move.l    next_comm_ptr(a5),a0
  1438. 1$    move.l    a0,a1
  1439. 2$    move.b    (a1)+,d0
  1440.     cmp.b    #'"',d0    ignore semi-colons between quotes
  1441.     bne.s    3$
  1442. 4$    move.b    (a1)+,d0
  1443.     beq.s    endofline    END OF LINE IS NULL.
  1444.     cmp.b    #10,d0
  1445.     beq.s    fndret
  1446.     cmp.b    #'"',d0
  1447.     bne.s    4$
  1448. 3$    cmp.b    #';',d0
  1449.     beq    fndsemi
  1450.     cmp.b    #10,d0
  1451.     bne.s    2$
  1452. fndret    tst.b    (a1)    IF NULL FOLLOWS LF THEN AT END OF LINE
  1453.     bne.s    fndsemi
  1454. endofline    clr.b    mult_comm_flag(a5)
  1455.     movem.l    (sp)+,a1/d0
  1456.     rts
  1457. fndsemi    move.b    #10,-1(a1)    REPLACE ; or LF WITH LF
  1458.     move.l    a1,next_comm_ptr(a5)
  1459.     move.b    #1,mult_comm_flag(a5)
  1460.     movem.l    (sp)+,a1/d0
  1461.     rts
  1462.     
  1463.     
  1464. *DOSERRor but Unlock first using D7 as the lock
  1465. DOSerrUL    move.l d7,d1        ;Assume D7=lock
  1466.     jsr _LVOUnLock(a6)        ;NB the last DOS error may be destroyed
  1467. ;DON'T PUT ANYTHING HERE
  1468. *DOSERRor handler D0=0 on entry
  1469. DOSerr    jsr _LVOIoErr(a6)
  1470.     cmp.l #232,d0
  1471.     bne.s dse1
  1472.     moveq #0,d0
  1473.     rts            ;Return if ERROR_NO_MORE_ENTRIES
  1474. dse1    bsr    pr_DOSerr
  1475. galactic    move.l    errorstack(a5),a7    ;restore stack
  1476.     moveq    #RETURN_ERROR,d0
  1477.     bra    com_fail        ;reenter shell loop
  1478.  
  1479. * ENTRY D0=dos error number
  1480. pr_DOSerr    lea    doserrtx(pc),a1
  1481.     bsr    pr_string
  1482.     lea    doserror_text(pc),a1    v1.21 handle textual errors
  1483.     bra.s    3$
  1484. 2$    tst.b    (a1)+
  1485.     bne.s    2$
  1486. 3$    move.b    (a1)+,d1
  1487.     beq.s    1$
  1488.     cmp.b    d1,d0
  1489.     bne.s    2$
  1490.     bsr    pr_string
  1491. 1$    bsr    print10
  1492.     bra    pr_lf
  1493.     
  1494. * fix up parameters that exist or not
  1495. fixpam32    move.l parm3(a5),d0
  1496.     move.l d0,a1
  1497.     bne.s fixpam2
  1498.     lea null(pc),a1
  1499. fixpam2    move.l parm2(a5),d0
  1500.     move.l d0,a0
  1501.     bne.s fxpam
  1502.     lea null(pc),a0
  1503. fxpam    rts
  1504.     
  1505. renamez    bsr fixpam32
  1506. ;DON'T PUT ANYThING HERE
  1507. *RENAME  A0-> oldname  A1-> newname
  1508. rename    move.l a0,d1
  1509.     move.l a1,d2
  1510.     jsr _LVORename(a6)
  1511.     tst.l d0
  1512.     beq DOSerr
  1513.     moveq    #RETURN_OK,d0
  1514.     rts
  1515.  
  1516. mkdirz    lea    parm2(a5),a4
  1517. 1$    move.l    (a4)+,d1
  1518.     beq.s    2$
  1519.     bsr.s    mkdir
  1520.     bra.s    1$
  1521. 2$    moveq    #RETURN_OK,d0
  1522.     rts
  1523.     
  1524. *MAKEDIR D1-> directory name
  1525. mkdir    jsr    _LVOCreateDir(a6)
  1526.     tst.l    d0
  1527.     beq    DOSerr
  1528.     move.l    d0,d1
  1529.     jsr    _LVOUnLock(a6)
  1530. *    moveq    #0,d0
  1531.     rts
  1532.  
  1533. ** CHECK DIRECTORY DESCRIPTION IN (A0) AND CONVERTS INTO DIRNAME[0] AND PUTS
  1534. ** THE WILD CARD IN WILD_STRING. ALSO SETS WILD_FLAG
  1535. handle_wild_dirs
  1536.     clr.b    wild_flag(a5)
  1537.     bsr    check_wild
  1538.     tst.b    d0
  1539.     bne.s    1$
  1540.     lea    wild_string(a5),a1
  1541.     bsr    split_wild
  1542.     move.b    #1,wild_flag(a5)
  1543. 1$    rts    
  1544.  
  1545. deletez    lea    parm2(a5),a4    v1.21 delete as many as you like.
  1546.     move.l    (a4),a0
  1547.     bsr    check_recurs
  1548.     tst.b    recurs_flag(a5)
  1549.     beq.s    1$
  1550.     move.l    (a4)+,d1        dummy bump
  1551. 1$    move.l    (a4)+,d1
  1552.     beq.s    del_end
  1553.     bsr.s    delete2
  1554.     bra.s    1$
  1555. del_end    moveq    #RETURN_OK,d0
  1556.     rts
  1557.     
  1558. ;DON'T PUT ANYTING HERE
  1559. *DELETE FILE D1-> filename
  1560. delete2    clr.w    indent_count(a5)
  1561.     move.l    d1,-(sp)            ;NOTE D1 is pushed
  1562.     move.l    d1,a0
  1563.     bsr    handle_wild_dirs
  1564.     bsr    fibexam            LOCK DIRECTORY OR FILE
  1565.     tst.l    fib_DirEntryType(a5)
  1566.     bpl.s    delete_dir
  1567.     move.l    d7,d1
  1568.     jsr    _LVOUnLock(a6)        
  1569.     move.l    (sp)+,d1            ;FIXED V1.05
  1570.     move.l    d1,a1
  1571.     bsr    prindent        PRINT NAME OF SINGLE FILE TO GO
  1572.     bra    del1file
  1573. delete_dir
  1574.     moveq    #0,d6            ;init cd count
  1575. delete_dir2
  1576.     move.l    d7,d1
  1577.     jsr    _LVOCurrentDir(a6)        CD to the directory
  1578.     tst.l    d6
  1579.     bne.s    this_is_a_sub_dir
  1580.     move.l    d0,temp2(a5)        ;save original directory lock
  1581.     bra.s    dd3        DONT UNLOCK THE ORIGINAL LOCK (YET)
  1582. this_is_a_sub_dir
  1583.     move.l    d0,d1            ;unlock old entry dir.
  1584.     jsr    _LVOUnLock(a6)
  1585. dd3    bsr    check_c
  1586.     bne    del_die_safely
  1587.     bsr    fibexnx
  1588.     tst.l    d0
  1589.     beq    del_dir_finished
  1590.  
  1591.     tst.b    wild_flag(a5)
  1592.     beq.s    ddx500
  1593.     lea    fib_FileName(a5),a0
  1594.     lea    wild_string(a5),a1
  1595.     bsr    wildmatch
  1596.     tst.b    d0
  1597.     bne.s    dd3
  1598.  
  1599. ddx500    lea    fib_FileName(a5),a0
  1600.     lea    tempbuf(a5),a1
  1601.     bsr    cp_string            ;copy filename to tempbuf
  1602.     move.l    fib_DirEntryType(a5),temp1(a5) ;save type
  1603. delete_d2    bsr    check_c
  1604.     bne    del_die_safely
  1605.     bsr    fibexnx            ;get next entry
  1606.     tst.l    d0
  1607.     beq.s    ddx501
  1608.     tst.b    wild_flag(a5)
  1609.     beq.s    ddx501
  1610.     move.l    d0,d4
  1611.     lea    fib_FileName(a5),a0
  1612.     lea    wild_string(a5),a1
  1613.     bsr    wildmatch
  1614.     tst.b    d0
  1615.     bne.s    delete_d2
  1616.     move.l    d4,d0
  1617. ddx501    move.l    d0,-(sp)        push exnext result
  1618.     lea    -84(sp),sp        ;alloc 84 bytes on stack
  1619.     lea    fib_FileName(a5),a0
  1620.     lea    4(sp),a1
  1621.     bsr    cp_string        ;copy filename to stack
  1622.     move.l    fib_DirEntryType(a5),(sp)
  1623.  
  1624.     bsr    del_filet        DELETE PRIOR ENTRY
  1625.     
  1626.     move.l    (sp),temp1(a5)    grab dirtype
  1627.     lea    4(sp),a0
  1628.     lea    tempbuf(a5),a1
  1629.     bsr    cp_string        ;copy stack to temp
  1630.     lea    84(sp),sp        ;dealloc 84 bytes on stack
  1631.     move.l    (sp)+,d0
  1632.     tst.l    d0
  1633.     beq.s    del_dir_finished
  1634.     bra    delete_d2
  1635.  
  1636. del_filet    lea    tempbuf(a5),a1    delete file (in tempbuf) or enter new dir
  1637.     tst.l    temp1(a5)
  1638.     bmi.s    del_print_file
  1639.     tst.b    recurs_flag(a5)
  1640.     bne.s    1$
  1641.     rts
  1642. 1$    lea    newcol(pc),a1
  1643.     bsr    pr_string
  1644.     lea    tempbuf(a5),a1
  1645. del_print_file
  1646.     bsr    prindent        PRINT FILE OR DIR NAME
  1647.     lea    tempbuf(a5),a1
  1648.     move.l    a1,d1
  1649.     tst.l    temp1(a5)            ;check dir type
  1650.     bmi.s    dft2
  1651. del_new_dir
  1652.     bsr    pr_tab
  1653.     lea    dirtext(pc),a1    PRINT "DIR"
  1654.     bsr    pr_string
  1655.     bsr    pr_lf
  1656.     addq.w    #1,indent_count(a5)
  1657.     addq.l    #1,d6
  1658.     lea    tempbuf(a5),a0        A0=tempbuf
  1659.     bsr    fibexam
  1660.     lea    -80(sp),sp
  1661.     lea    (sp),a1
  1662.     lea    fib_FileName(a5),a0
  1663.     bsr    cp_string        ;copy dirname to stack
  1664.     bra    delete_dir2    recurs
  1665.     
  1666. dft2    bra    del1file
  1667.  
  1668.  
  1669. * IF CTRLC CHECKING CALLS HERE IT WELL ONLY BREAK THE DELETION IN THE CURRENT DIR
  1670. del_dir_finished
  1671.     tst.l    d6
  1672.     bne.s    not_back_enough
  1673.     move.l    temp2(a5),d1
  1674.     jsr    _LVOCurrentDir(a6)
  1675.     move.l    d0,d1            ;unlock old.
  1676.     jsr    _LVOUnLock(a6)
  1677.     move.l    (sp)+,d1
  1678.     jsr    _LVODeleteFile(a6)        ;delete directory name
  1679.     bra    pr_lf
  1680.  
  1681. not_back_enough
  1682.     subq.l    #1,d6
  1683.     subq.w    #1,indent_count(a5)
  1684.     lea    backslash(pc),a0
  1685.     bsr    fibexam
  1686.     move.l    d7,d1
  1687.     jsr    _LVOCurrentDir(a6)
  1688.     move.l    d0,d1            ;unlock old.
  1689.     jsr    _LVOUnLock(a6)
  1690.     lea    (sp),a1
  1691.     move.l    a1,d1
  1692.     jsr    _LVODeleteFile(a6)        ;delete directory name
  1693.     lea    80(sp),sp
  1694.     move.l    d7,d0
  1695.     bsr    fibexam2
  1696.     bra    fibexnx
  1697.  
  1698.     
  1699. del1file    jsr _LVODeleteFile(a6)
  1700.     tst.l d0
  1701.     beq.s    1$
  1702.     lea    deletedtx(pc),a1    PRINT "...DELETED"
  1703.     bsr    pr_string
  1704.     rts
  1705. 1$    jsr    _LVOIoErr(a6)    IF FILE IS PROTECTED OR SOMETHING
  1706.     bsr    pr_DOSerr        THEN GET OUT TO OLD DIRECTLY LEVEL
  1707. del_die_safely
  1708. 3$    tst.l    d6        CLEANLY.
  1709.     bne.s    2$
  1710.     move.l    temp2(a5),d1
  1711.     jsr    _LVOCurrentDir(a6)
  1712.     move.l    d0,d1            ;unlock old.
  1713.     jsr    _LVOUnLock(a6)
  1714.     bsr    pr_lf
  1715.     bra    galactic        GET BACK TO ORIGINAL STACK LEVEL
  1716. *                AND GET TO MAIN LOOP
  1717. 2$    subq.l    #1,d6
  1718.     lea    backslash(pc),a0
  1719.     bsr    fibexam
  1720.     move.l    d7,d1
  1721.     jsr    _LVOCurrentDir(a6)
  1722.     move.l    d0,d1            ;unlock old.
  1723.     jsr    _LVOUnLock(a6)
  1724.     bra.s    3$
  1725.  
  1726. init_prompt
  1727.     lea    prompt_args_tx(pc),a0
  1728.     lea    prompt_args(a5),a1
  1729. init_pr2    move.b    (a0)+,(a1)+
  1730.     bne.s    init_pr2
  1731.     rts
  1732.     
  1733. compose_prompt
  1734.     lea    prompt_string(a5),a1
  1735.     lea    newcol(pc),a0
  1736. cpro4    move.b    (a0)+,(a1)+    copy highlight colour
  1737.     bne.s    cpro4
  1738.     lea    -1(a1),a1
  1739.     lea    prompt_args(a5),a0
  1740. cpro3    move.b    (a0)+,d0
  1741.     beq    composer3
  1742.     cmp.b    #'\',d0
  1743.     bne.s    1$
  1744.     move.b    (a0)+,d0
  1745.     bra.s    composer2
  1746. 1$    cmp.b    #'%',d0
  1747.     bne.s    composer2
  1748.     move.b    (a0)+,d0
  1749.     cmp.b    #'p',d0        check if %p
  1750.     bne.s    try_task_num
  1751.     lea    CD_string(a5),a2
  1752. cpro2    move.b    (a2)+,(a1)+    copy cd_string to prompt_string
  1753.     bne.s    cpro2
  1754.     lea    -1(a1),a1
  1755.     bra    cpro3
  1756. try_task_num
  1757.     cmp.b    #'n',d0
  1758.     bne.s    composer2
  1759.     move.l    thistask(a5),a2
  1760.     move.l    pr_TaskNum(a2),d0
  1761.     add.b    #$30,d0
  1762. composer2    move.b    d0,(a1)+
  1763.     bra    cpro3
  1764. composer3    lea    oldcol(pc),a0
  1765. cpro5    move.b    (a0)+,(a1)+
  1766.     bne.s    cpro5
  1767.     rts
  1768.  
  1769.  
  1770. *** PROMPT COMMAND
  1771. promptz    tst.l    parm2(a5)
  1772.     beq.s    promptz2
  1773.     move.l    parm2(a5),a0
  1774.     lea    prompt_args(a5),a1
  1775. promptz3    move.b    (a0)+,(a1)+
  1776.     bne.s    promptz3
  1777.     MOVEQ    #RETURN_OK,D0
  1778.     rts
  1779. promptz2    lea    prompt_args(a5),a1
  1780.     bsr    pr_string
  1781.     moveq    #RETURN_OK,d0
  1782.     bra    pr_lf
  1783.     
  1784.     
  1785. *FILL FIB WITH EXAMINE A0-> directory name ,D7=filelock on return
  1786. fibexam    move.l a0,-(sp)
  1787.     moveq #ACCESS_READ,d2
  1788. fibexam3    move.l a0,d1
  1789.     jsr _LVOLock(a6)
  1790.     tst.l d0
  1791.     beq DOSerr
  1792.     bsr fibexam2
  1793.     move.l (sp)+,a0
  1794.     rts
  1795. fibexam2    move.l d0,d7
  1796.     move.l d0,d1
  1797.     move.l a5,d2
  1798.     jsr _LVOExamine(a6)
  1799.     tst.l d0
  1800.     beq DOSerrUL
  1801.     rts
  1802.  
  1803. chdirz    tst.l    parm2(a5)
  1804.     beq    querycd
  1805.     move.l    parm2(a5),a0
  1806. ;DON'T PUT ANYTHING HERE    
  1807. *CHANGE DIRECTORY A0-> new current directory
  1808. chdir    bsr    fibexam
  1809.     tst.l    fib_DirEntryType(a5)    ;check entry OK
  1810.     bpl.s    cd123
  1811.     lea    cderrtx(pc),a1
  1812.     bsr    pr_string
  1813.     bsr    unlockOK
  1814.     moveq    #RETURN_ERROR,d0
  1815.     rts
  1816. cd123    move.l    d7,d1
  1817.     jsr    _LVOCurrentDir(a6)
  1818.     move.l    d0,d1        ;unlock the old directory
  1819.     jsr    _LVOUnLock(a6)
  1820.     bsr    eval_CD        ;update cd string
  1821.     moveq    #RETURN_OK,d0
  1822.     rts
  1823.     
  1824. querycd    bsr    eval_CD
  1825.     lea    CD_string(a5),a0
  1826.     bsr    new_print
  1827.     moveq    #RETURN_OK,d0
  1828.     bra    pr_lf
  1829.  
  1830.  
  1831. ** Evaluate entire name of current directory and put in CD_string
  1832. eval_CD    clr.b    CD_string(a5)
  1833.     lea    null(pc),a0
  1834.     move.l    a0,d1
  1835.     moveq    #ACCESS_READ,d2
  1836.     jsr    _LVOLock(a6)
  1837.     tst.l    d0
  1838.     beq.s    1$
  1839.     move.l    d0,a0
  1840.     add.l    a0,a0
  1841.     add.l    a0,a0
  1842.     move.l    fl_Key(a0),cd_block(a5)
  1843.     move.l    fl_Volume(a0),cd_volnode(a5)
  1844.     lea    CD_string(a5),a0
  1845.     bsr    eval_full_path
  1846.     jsr    _LVOUnLock(a6)
  1847. 1$    rts
  1848.     
  1849. ** evaluate entire name associated with lock in D0, store string in A0
  1850. ** Return D1 = last lock to unlock
  1851. ** Reg usage:a0,d0,d1,d2,a3 (must not use A2)
  1852. eval_full_path
  1853.     lea    -88(sp),sp
  1854.     move.l    a0,4(sp)        save address of string
  1855.     move.l    d0,(sp)        save original lock on stack
  1856.     move.l    d0,d1
  1857.     move.l    a5,d2
  1858.     jsr    _LVOExamine(a6)
  1859.     move.l    4(sp),a1
  1860.     lea    fib_FileName(a5),a0
  1861. evx1    move.b    (a0)+,(a1)+    COPY FILENAME TO deststring
  1862.     bne.s    evx1
  1863.     lea    -1(a1),a3
  1864. evcd2    move.l    (sp),d1        get lock
  1865.     jsr    _LVOParentDir(a6)
  1866.     tst.l    d0
  1867.     beq.s    root_found
  1868.     move.l    (sp),d1
  1869.     move.l    d0,(sp)
  1870.     jsr    _LVOUnLock(a6)    unlock last
  1871.     move.l    (sp),d1
  1872.     move.l    a5,d2
  1873.     jsr    _LVOExamine(a6)
  1874.     lea    fib_FileName(a5),a0
  1875.     lea    8(sp),a1
  1876. evx2    move.b    (a0)+,(a1)+    stackbuf = filename
  1877.     bne.s    evx2
  1878.     move.b    #'/',-1(a1)
  1879.     move.l    4(sp),a0
  1880. evx3    move.b    (a0)+,(a1)+    stackbuf = filename/CD_string
  1881.     bne.s    evx3
  1882.     move.l    4(sp),a1
  1883.     lea    8(sp),a0
  1884. evx4    move.b    (a0)+,d0
  1885.     move.b    d0,(a1)+
  1886.     cmp.b    #'/',d0
  1887.     bne.s    evx4
  1888.     lea    -1(a1),a3
  1889. evx5    move.b    (a0)+,(a1)+    dest string = stackbuf
  1890.     bne.s    evx5
  1891.     bra    evcd2
  1892. root_found
  1893.     move.l    (sp),d1
  1894.     tst.b    (a3)
  1895.     bne.s    root2
  1896.     clr.b    1(a3)
  1897. root2    move.b    #':',(a3)
  1898.     lea    88(sp),sp
  1899.     rts
  1900.  
  1901. *ADDPATH A0-> path  A1-> parameter  A2-> destination for string
  1902. ** eg. (A0)='df0:libs',0  (A1)='arp.library',0  (A2)='df0:libs/arp.library',0
  1903. addpath    movem.l a0-a2,-(sp)
  1904.     move.b (a0),d0
  1905.     beq.s addp4
  1906. addp1    move.b (a0)+,d0
  1907.     beq.s addp2
  1908.     move.b d0,(a2)+
  1909.     bra.s addp1
  1910. addp2    move.b -2(a0),d0
  1911.     cmp.b #':',d0
  1912.     beq.s addp4
  1913.     cmp.b #'/',d0
  1914.     beq.s addp4
  1915.     move.b #'/',(a2)+
  1916. addp4    move.l a1,a0
  1917.     move.l a2,a1
  1918.     bsr cp_string
  1919.     movem.l (sp)+,a0-a2
  1920.     rts
  1921.  
  1922. * path(a0) + parm1 -> tempbuf
  1923. loadmep    move.l    a4,a1
  1924.     lea    tempbuf(a5),a2        ;use temp buffer
  1925.     bsr    addpath
  1926.     move.l    a2,d1
  1927.     rts
  1928.  
  1929.  
  1930. * Search Resident list for command
  1931. * RETURN D0= seglist OR 0 if not found
  1932. *    A0= addr of node
  1933. ** Resi list structure -->[ lword link ][ lword seg ptr ][ 32 char name ] 
  1934. search_res
  1935.     move.l    parm1(a5),a4
  1936. search_res2
  1937.     move.l    resi_head(a5),d2
  1938.     beq.s    4$
  1939. 1$    move.l    a4,a1
  1940.     move.l    d2,a0
  1941.     move.l    d2,d4    D4=addr of current node
  1942.     move.l    (a0)+,d2    get link
  1943.     move.l    (a0)+,d3    get seglist
  1944.     bsr    compare_strings
  1945.     beq    3$
  1946.     tst.l    d2
  1947.     bne.s    1$
  1948. 4$    moveq    #0,d0
  1949.     rts
  1950. 3$    move.l    d3,d0
  1951.     move.l    d4,a0
  1952.     rts
  1953.     
  1954.  
  1955. *Search paths for command
  1956. spaths    MOVE.L    parm1(a5),a4    A4=parm1
  1957. spaths2    moveq    #-1,d1
  1958.     bsr    changeWindowPtr
  1959.     move.l    a4,d1        ;search current
  1960.     jsr    _LVOLoadSeg(a6)
  1961.     tst.l    d0
  1962.     bne.s    gotit
  1963.     lea    patharea(a5),a0
  1964. spa_3    tst.b    (a0)
  1965.     beq.s    no_more_paths    CHECK IF PATH LIST IS EMPTY
  1966. spa_2    move.l    a0,d4
  1967.     bsr    loadmep
  1968.     jsr    _LVOLoadSeg(a6)
  1969.     tst.l    d0
  1970.     bne.s    gotit
  1971.     move.l    d4,a0
  1972. spa_1    tst.b    (a0)+
  1973.     bne.s    spa_1
  1974.     bra.s    spa_3
  1975. no_more_paths
  1976.     moveq    #0,d0
  1977. gotit    moveq    #0,d1
  1978.     bra    changeWindowPtr
  1979.  
  1980. * ARCHIE 3 calls system0 to execute non internal commands
  1981. archie3    tst.l parm1(a5)    ;exit if nothing typed
  1982.     beq noarch31
  1983.     bsr    save_mem
  1984.     clr.b    resi_flag(a5)    =0 if resident
  1985.     bsr    search_res    search resident list first
  1986.     tst.l    d0
  1987.     bne.s    1$
  1988.     addq.b    #1,resi_flag(a5)    =1 if not resident
  1989.     bsr    spaths        ;load the command
  1990.     tst.l    d0
  1991.     beq    noarch32        ;could not load
  1992. 1$    move.l    d0,temp1(a5)        ;save the segment
  1993.     bsr    raw_off
  1994.     bsr    save_time
  1995.     lea    CLIbuf(a5),a0
  1996.     move.l    a0,-(sp)    ;push arg_args ptr.
  1997.     move.l    d0,-(sp)    ;push seglist
  1998.     move.l    parm1(a5),d0
  1999.     move.l    d0,-(sp)    ;push arg_name
  2000.     bsr    _System0    TAKES 3 PARMS(ARG_NAME,SEGLIST,ARGS)
  2001.     lea    12(sp),sp
  2002.     move.l    d0,-(sp)
  2003.     tst.b    resi_flag(a5)
  2004.     beq.s    2$
  2005.     move.l    better_seglist(pc),d1
  2006.     jsr    _LVOUnLoadSeg(a6)
  2007. 2$    tst.b    stat_mode_flag(a5)
  2008.     beq.s    no_status_disp
  2009.     bsr    show_status
  2010. no_status_disp
  2011.     bsr    raw_on
  2012.     move.l    (sp)+,d0    RESULT IN D0
  2013. noarch31    rts
  2014. noarch32    lea badcomm(pc),a1
  2015.     moveq    #RETURN_ERROR,d0    return d0 bad    V1.30
  2016.     bra pr_string
  2017.     
  2018. *SYSTEM0 execute command from disk from Sozobon C distribution.
  2019.  
  2020. _System0
  2021.     movem.l SAVED_REGS,-(sp)
  2022.  
  2023.     moveq   #NO_CLI,REG_Result      ;ERROR - not a CLI task
  2024.     
  2025.     movea.l _AbsExecBase,REG_SysBase
  2026.     move.l    thistask(a5),REG_Process    V1.03
  2027.     move.l  pr_CLI(REG_Process),d0
  2028.     beq     quit0
  2029.  
  2030. * build local stack frame & save some values
  2031.  
  2032.     lsl.l   #2,d0   ;BPTR to machine pointer
  2033.     movea.l d0,REG_CLI
  2034.  
  2035.     movea.l sp,REG_PrevStack        ;save old stack pointer
  2036.     move.l  sp,d0
  2037.     andi.b  #$fc,d0 ;make SP longword-aligned for BPTRs
  2038.     movea.l d0,sp
  2039.     suba.l  #sf_SIZEOF,sp        <<<***************
  2040.  
  2041.     move.l  REG_PrevStack,sf_PrevStack(sp)
  2042.     move.l  REG_Process,sf_Process(sp)
  2043.     move.l  REG_CLI,sf_CLI(sp)
  2044.  
  2045.     move.l  pr_ReturnAddr(REG_Process),sf_SaveReturnAddr(sp)
  2046.  
  2047. * allocate space for stack
  2048.  
  2049.     moveq   #NO_MEM,REG_Result      ;ERROR - no memory for STACK
  2050.  
  2051.     move.l  cli_DefaultStack(REG_CLI),d0    ;in longwords for "VEC"
  2052.     lsl.l   #2,d0
  2053.     move.l  d0,sf_PushSize(sp)
  2054.     addq.l  #4,d0   ;one additional longword
  2055.     move.l  d0,sf_StackSize(sp)
  2056.     moveq   #0,d1   ;intentionally NOT "MEMF_PUBLIC"!
  2057.     callsys AllocMem
  2058.     tst.l   d0
  2059.     beq     quit1
  2060.  
  2061.     move.l  d0,sf_StackBase(sp)     ;save result
  2062.  
  2063. * save old command pointer, build new BCPL command name
  2064.  
  2065.     move.l  cli_CommandName(REG_CLI),sf_SaveCommandName(sp)
  2066.  
  2067.     movea.l ARG_NAME(REG_PrevStack),a0      ;first parameter to "System0()"
  2068.     lea     sf_CommandName+1(sp),a1 ;first char location for BSTR
  2069.     move.l  a1,d0
  2070.     lsr.l   #2,d0   ;will ignore (+1), BPTR as result
  2071.     move.l  d0,cli_CommandName(REG_CLI)
  2072.  
  2073.     move.w  #MAXBSTR,d0
  2074.     bra.s   2$
  2075.  
  2076. 1$    move.b  d1,(a1)+
  2077. 2$    move.b  (a0)+,d1
  2078.     dbeq    d0,1$
  2079.  
  2080.     suba.l  ARG_NAME(REG_PrevStack),a0      ;subtract original source
  2081.     move.l  a0,d0
  2082.     subq.l  #1,d0   ;terminating null-byte
  2083.     move.b  d0,sf_CommandName(sp)   ;to first location in BSTR
  2084.  
  2085. * save contents of Current Input Stream
  2086.  
  2087.     move.l  pr_CIS(REG_Process),d0
  2088.     lsl.l   #2,d0
  2089.     movea.l d0,REG_CIS      ;contains APTR to CIS
  2090.     move.l  REG_CIS,sf_CIS(sp)
  2091.  
  2092.     move.l  fh_Buf(REG_CIS),sf_SCB_Buf(sp)
  2093.     move.l  fh_Pos(REG_CIS),sf_SCB_Pos(sp)
  2094.     move.l  fh_End(REG_CIS),sf_SCB_End(sp)
  2095.  
  2096. * convert argument to LF-terminated string
  2097.  
  2098.     movea.l ARG_ARGS(REG_PrevStack),a0      ;third argument to "System0()"
  2099.     lea     sf_CommandArgs(sp),a1   ;first buffer location
  2100.     move.l  a1,d0
  2101.     lsr.l   #2,d0   ;make buffer pointer a BPTR
  2102.     move.l  d0,fh_Buf(REG_CIS)
  2103.  
  2104.     move.w  #MAXBSTR,d0     ;leave some room for terminating LF
  2105.     bra.s   4$
  2106.  
  2107. 3$    move.b  d1,(a1)+
  2108. 4$    move.b  (a0)+,d1
  2109.     dbeq    d0,3$
  2110.  
  2111.     move.b  #LF,(a1)
  2112.     suba.l  ARG_ARGS(REG_PrevStack),a0      ;subtract first position
  2113.     move.l  a0,d0   ;do NOT subtract, LF need this byte
  2114.  
  2115. * setup start/end indices in Stream Control Block
  2116.  
  2117.     clr.l   fh_Pos(REG_CIS)
  2118.     move.l  d0,fh_End(REG_CIS)
  2119.  
  2120. * misc setup
  2121.  
  2122.     clr.l   pr_Result2(REG_Process) ;clear secondary result
  2123.  
  2124.     moveq   #0,d0
  2125.     move.l  #SIGBREAKF_CTRL_C,d1
  2126.     callsys SetSignal       ;clear CTRL-C flag
  2127.  
  2128. * handle seglist and start address
  2129.  
  2130.     move.l  cli_Module(REG_CLI),sf_SaveModule(sp)
  2131.  
  2132.     move.l  ARG_SEGLIST(REG_PrevStack),d0   ;second argument to "System0()"
  2133.     move.l  d0,cli_Module(REG_CLI)
  2134.     lsl.l   #2,d0
  2135.     movea.l d0,a3   ;make it a machine pointer in A3
  2136.  
  2137. * setup processor registers & C-interface
  2138.  
  2139.     lea     sf_CommandArgs(sp),a0
  2140.     move.l  fh_End(REG_CIS),d0
  2141.  
  2142. * setup processor registers, BCPL-interface, stack & return address for "Exit()"
  2143.  
  2144.     movea.l sf_StackBase(sp),a1     ;BCPL stack, low end
  2145.     move.l  sf_PushSize(sp),d2
  2146.     lea     4(a1,d2.l),a4   ;must not destroy REG_Process!
  2147.     move.l  sp,-(a4)        ;previous stack frame
  2148.     move.l  d2,-(a4)        ;stack size in bytes
  2149.     move.l  a4,pr_ReturnAddr(REG_Process)
  2150.     movea.l a4,sp
  2151.  
  2152.     movea.l _DOSBase,a4     ;large data memory model!
  2153.     movem.l dl_A2(a4),a2/a5/a6
  2154.  
  2155. * now call the command at its entry point
  2156.  
  2157.     jsr     4(a3)   ;code starts one longword behind segment pointer
  2158.  
  2159.     move.l  d0,REG_Result   ;save return code
  2160.  
  2161. * get old stackframe & reload old register contents
  2162.  
  2163.     movea.l 4(sp),sp        ;old stack frame
  2164.  
  2165.     movea.l sf_Process(sp),a0
  2166.     move.l  sf_SaveReturnAddr(sp),pr_ReturnAddr(a0)
  2167.  
  2168.     movea.l sf_CLI(sp),a0
  2169.     move.l  sf_SaveCommandName(sp),cli_CommandName(a0)
  2170. * Next line makes powerpacker programs deallocate memory properly
  2171.     move.l  cli_Module(a0),better_seglist        NEW V1.05
  2172.     move.l  sf_SaveModule(sp),cli_Module(a0)
  2173.  
  2174. * restore original contents of Current Input Stream
  2175.  
  2176.     movea.l sf_CIS(sp),a0
  2177.     lea     sf_CommandArgs(sp),a1
  2178.     move.l  a1,d0
  2179.     lsr.l   #2,d0
  2180.     cmp.l   fh_Buf(a0),d0   ;still the same?
  2181.     bne.s   5$      ;no: don't restore
  2182.     move.l  sf_SCB_Buf(sp),fh_Buf(a0)
  2183. 5$    move.l  sf_SCB_Pos(sp),fh_Pos(a0)
  2184.     tst.l   fh_End(a0)      ;end index set?
  2185.     beq.s   6$      ;no: don't restore
  2186.     move.l  sf_SCB_End(sp),fh_End(a0)
  2187.  
  2188. * free temporary stack
  2189.  
  2190. 6$    movea.l _AbsExecBase,REG_SysBase
  2191.     movea.l sf_StackBase(sp),a1
  2192.     move.l  sf_StackSize(sp),d0
  2193.     callsys FreeMem
  2194.  
  2195. quit1    movea.l sf_PrevStack(sp),sp     ;UNLINK local variables
  2196.  
  2197. quit0    move.l  REG_Result,d0
  2198.  
  2199.     movem.l (sp)+,SAVED_REGS
  2200. quitx    rts
  2201.  
  2202. *******************************
  2203. *    HELP COMMAND    *
  2204. *******************************
  2205. helpmez    lea    comtext(pc),a4
  2206.     lea    tempbuf(a5),a3
  2207.     
  2208. 4$    moveq    #5,d3
  2209. 3$    move.l    a3,a2
  2210.     tst.b    (a4)        
  2211.     beq    help_fin
  2212.     moveq    #12,d2
  2213. 2$    subq.l    #1,d2
  2214.     move.b    (a4)+,(a2)+
  2215.     bne.s    2$
  2216.     tst.b    -(a2)    bump    back
  2217. 1$    move.b    #$20,(a2)+
  2218.     dbra    d2,1$
  2219.     clr.b    (a2)
  2220.     move.l    a3,a1
  2221.     bsr    pr_string
  2222.     dbra    d3,3$
  2223.     bsr    pr_lf
  2224.     bra    4$
  2225. help_fin    bsr    pr_lf
  2226.     moveq    #RETURN_OK,D0
  2227.     rts
  2228.     
  2229. * PRINT A STRING BUT PUT A TAB AFTER IT
  2230. showittab    bsr pr_string
  2231.     bra pr_tab
  2232.  
  2233. showpath    lea    patharea(a5),a1
  2234. sh_p3    tst.b    (a1)
  2235.     beq.s    sh_p1
  2236.     move.l    a1,d4
  2237.     bsr    showittab
  2238.     move.l    d4,a1
  2239. sh_p2    tst.b    (a1)+
  2240.     bne.s    sh_p2
  2241.     bra.s    sh_p3
  2242. sh_p1    moveq    #RETURN_OK,d0
  2243.     bra    pr_lf
  2244.  
  2245.     
  2246. *PATH COMMAND Assign path or show it.
  2247. pathcomz    tst.l parm2(a5)        ;see whether any parameters
  2248.     beq.s showpath
  2249.     move.l    parm2(a5),a0
  2250.     bsr    return_dash_option
  2251.     lea    parm2(a5),a0
  2252.     lea    patharea(a5),a1
  2253.     cmp.b    #'A',d0
  2254.     bne.s    pc_x2
  2255. 1$    tst.b    (a1)+
  2256.     bne.s    1$
  2257.     tst.b    (a1)        test if 2 nulls
  2258.     bne.s    1$
  2259.     tst.l    (a0)+        dummy bump
  2260. pc_x2    move.l    (a0),a2        go through each additional parameter
  2261.     tst.l    (a0)+
  2262.     beq.s    pc_x3
  2263.     
  2264. pc_x1    move.b    (a2)+,(a1)+
  2265.     bne.s    pc_x1
  2266.     bra.s    pc_x2
  2267. pc_x3    clr.b    (a1)
  2268.     moveq    #RETURN_OK,d0
  2269.     rts
  2270.  
  2271.  
  2272.  
  2273. *INFO COMMAND prints out no. of bytes free
  2274. infoz    moveq    #ACCESS_READ,d2
  2275.     bsr    fixpam2
  2276.     move.l    a0,d1
  2277.     jsr    _LVOLock(a6)
  2278.     tst.l    d0
  2279.     beq    DOSerr
  2280.     move.l    d0,-(sp)        ;push the lock
  2281.     move.l    d0,d1
  2282.     move.l    a5,d2
  2283.     jsr    _LVOInfo(a6)
  2284.     tst.l    d0
  2285.     beq    DOSerrUL
  2286.     bsr    do_forbid
  2287.     move.l    id_NumBlocks(a5),d0
  2288.     sub.l    id_NumBlocksUsed(a5),d0    ;work out blocks free
  2289.     moveq    #0,d1
  2290. hammy    subq.l    #1,d0            ;work out bytes free
  2291.     bmi.s    johnny
  2292.     add.l    id_BytesPerBlock(a5),d1
  2293.     bra.s    hammy
  2294. johnny    move.l    d1,d7            ;D7= no. of bytes
  2295.     move.l    id_VolumeNode(a5),a0
  2296.     add.l    a0,a0
  2297.     add.l    a0,a0
  2298.     move.l    40(a0),a0
  2299.     add.l    a0,a0
  2300.     add.l    a0,a0
  2301.     moveq    #0,d0
  2302.     move.b    (a0)+,d0
  2303. wilma    lea    tempbuf(a5),a1
  2304. Ifo2    move.b    (a0)+,(a1)+
  2305.     dbra    d0,Ifo2
  2306.     clr.b    (a1)
  2307.     bsr    do_permit
  2308.     move.l    d7,-(sp)
  2309.     pea    tempbuf(a5)
  2310.     lea    (a7),a1
  2311.     lea    volytx(pc),a0
  2312.     bsr    new_print
  2313.     movem.l    (sp)+,d0-d1
  2314.     move.l    (sp)+,d7
  2315.     bra    unlockOK
  2316.  
  2317.  
  2318.  
  2319. *EXIT FROM ZSHELL TO CLI. IF WE EXIT FROM SCRIPT THEN FREE SCRIPT MEMORY
  2320. exitz    tst.b scflag(a5)
  2321.     beq.s byebye
  2322.     bsr    kill_script
  2323. byebye    move.l (sp)+,d0    ;kill return address on stack
  2324.     rts
  2325.  
  2326. ** SPLIT STRING(A0) INTO DIRECTORY PATH AND WILDCARD DESCRIPTION
  2327. ** NULL END THE PATH, AND MOVE THE WILDCARD TO (A1)
  2328. * eg. ram:c/*.info -> ram:c0 + *.info0
  2329.     
  2330. split_wild
  2331.     movem.l    a0-a2/d0-d1,-(sp)
  2332.     move.l    a0,d1
  2333. sp_w2    move.l    a0,a2    a2=temp
  2334. sp_w3    move.b    (a0)+,d0
  2335.     beq.s    sp_w4
  2336.     cmp.b    #':',d0
  2337.     beq.s    sp_w2    A0= 1 after :
  2338.     cmp.b    #'/',d0
  2339.     beq.s    sp_w2
  2340.     bra.s    sp_w3
  2341. sp_w4    cmp.l    a2,d1
  2342.     beq.s    sp_mis
  2343.     cmp.b    #':',-1(a2)
  2344.     bne.s    sp_w5
  2345. sp_mis    move.l    a2,d1    SAVE POSITION
  2346. sp_w6    move.b    (a2)+,(a1)+
  2347.     bne.s    sp_w6
  2348.     move.l    d1,a2
  2349.     clr.b    (a2)
  2350.     movem.l    (sp)+,a0-a2/d0-d1
  2351.     rts
  2352. sp_w5    clr.b    -1(a2)
  2353. sp_w7    move.b    (a2)+,(a1)+
  2354.     bne.s    sp_w7
  2355.     movem.l    (sp)+,a0-a2/d0-d1
  2356.     rts
  2357.     
  2358. ** CHECK STRING(A0) IF IT CONTAINS WILDCARD SPECIFIC CHARS
  2359. ** RETURN D0=0 IF WILDS FOUND
  2360. check_wild
  2361.     move.l    a0,-(sp)
  2362. chk_w3    move.b    (a0)+,d0
  2363.     beq.s    chk_w2
  2364.     cmp.b    #'*',d0
  2365.     beq.s    chk_w4
  2366.     cmp.b    #'~',d0    special not char
  2367.     beq.s    chk_w4
  2368.     cmp.b    #'[',d0
  2369.     beq.s    chk_w4
  2370.     cmp.b    #']',d0
  2371.     beq.s    chk_w4
  2372.     cmp.b    #'?',d0
  2373.     bne.s    chk_w3
  2374. chk_w4    moveq    #0,d0
  2375.     move.l    (sp)+,a0
  2376.     rts
  2377. chk_w2    moveq    #1,d0
  2378.     move.l    (sp)+,a0
  2379.     rts
  2380.  
  2381. * NOTE this wildmatcher only handles cases where the wildcard has one * in it.
  2382. ** WILDCARD MATCHER. CHECK IF STRING(A0) MATCHES WILDCARD(A1)
  2383. ** RETURN D0=0 IF MATCH
  2384. wildmatch    cmp.b    #'~',(a1)        check for NOT specifier
  2385.     bne.s    wm_1
  2386.     move.b    (a1)+,d0
  2387.     bsr.s    wm_1
  2388.     subq.l    #1,d0    0 --> -1     1 --> 0
  2389.     rts
  2390.     
  2391. wm_1    move.b    (a0)+,d0
  2392.     beq    source_fin1
  2393.     move.b    (a1)+,d1
  2394.     cmp.b    #'*',d1
  2395.     beq.s    wild_run
  2396.     cmp.b    #'[',d1        handle character classes
  2397.     bne.s    1$
  2398. 2$    move.b    (a1)+,d1
  2399.     beq.s    wild_fail
  2400.     cmp.b    #']',d1
  2401.     beq.s    wild_fail
  2402.     bsr    compD1D0nocase
  2403.     bne.s    2$
  2404. 3$    move.b    (a1)+,d1
  2405.     beq.s    wild_fail
  2406.     cmp.b    #']',d1
  2407.     bne.s    3$
  2408.     bra.s    wm_1
  2409. 1$    cmp.b    #'?',d1
  2410.     beq.s    wm_1
  2411.     bsr    compD1D0nocase
  2412.     beq.s    wm_1
  2413.     
  2414. wild_fail    moveq    #1,d0
  2415.     rts
  2416. wild_run    
  2417. wr_3    tst.b    (a0)+    GOTO END OF STRING
  2418.     bne.s    wr_3
  2419. wr_4    tst.b    (a1)+    GOTO END OF WILDCARD
  2420.     bne.s    wr_4
  2421. wr_5    move.b    -(a1),d0    get tail of wildcard (1st should be null)
  2422.     move.b    -(a0),d1
  2423.     cmp.b    #'*',d0
  2424.     beq.s    source_fin2
  2425.     cmp.b    #']',d0        handle class [xyz]
  2426.     bne.s    1$
  2427. 2$    move.b    -(a1),d0
  2428.     cmp.b    #'*',d0
  2429.     beq.s    wild_fail
  2430.     cmp.b    #'[',d0
  2431.     beq.s    wild_fail
  2432.     bsr    compD1D0nocase
  2433.     bne.s    2$
  2434. 3$    move.b    -(a1),d0
  2435.     beq.s    wild_fail        should never happen but should leave in
  2436.     cmp.b    #'[',d0
  2437.     bne.s    3$
  2438.     bra.s    wr_5
  2439. 1$    cmp.b    #'?',d0
  2440.     beq.s    wr_5
  2441.     bsr    compD1D0nocase
  2442.     beq.s    wr_5
  2443.     bra.s    wild_fail
  2444. source_fin1
  2445.     tst.b    (a1)
  2446.     beq.s    source_fin2
  2447.     cmp.b    #'*',(a1)
  2448.     bne.s    wild_fail
  2449. source_fin2
  2450.     moveq    #0,d0
  2451.     rts
  2452.  
  2453. compD1D0nocase
  2454.     cmp.b    #'a',d1
  2455.     blo.s    D1_OK
  2456.     cmp.b    #'z',d1
  2457.     bhi.s    D1_OK
  2458.     sub.b    #$20,d1
  2459. D1_OK    cmp.b    #'a',d0
  2460.     blo.s    D0_OK
  2461.     cmp.b    #'z',d0
  2462.     bhi.s    D0_OK
  2463.     sub.b    #$20,d0
  2464. D0_OK    cmp.b    d1,d0
  2465.     rts
  2466.     
  2467. fibexnx    move.l d7,d1
  2468.     move.l a5,d2
  2469.     jmp _LVOExNext(a6)
  2470.  
  2471.  
  2472. *WIDE DIRECTORY LISTER
  2473. dirwz    bsr fixpam2
  2474.     moveq #1,d0
  2475.     move.l d0,temp2(a5)
  2476.     bsr    raw_off        V0.15
  2477.     bra.s directory
  2478.     
  2479. dirz    bsr fixpam2
  2480.     clr.l temp2(a5)            ;clear wide flag
  2481.     bsr    raw_off
  2482. ;DON'T PUT ANYTHING HERE    
  2483. *PRINT DIRECTORY A0-> name of directory
  2484. directory    clr.l    temp1(a5)            ;init total size
  2485.     bsr    handle_wild_dirs
  2486.     bsr    pr_dir            ;print the dir
  2487.     bsr    pr_size            ;show total size
  2488.     moveq    #RETURN_OK,d0
  2489.     rts
  2490.  
  2491. pr_dir    bsr    fibexam
  2492.     tst.l    fib_DirEntryType(a5)    ;check entry OK
  2493.     bpl.s    prd20            ;Directory V1.05
  2494.     lea    fib_FileName(a5),a1    V1.05 EXTRAS FOR 'DIR FILENAME'
  2495.     bsr     pr_string            ;print filename
  2496.     lea    seq(pc),a1
  2497.     bsr    pr_string            ;print some tabs
  2498.     move.l    fib_Size(a5),d0
  2499.     add.l    d0,temp1(a5)        ;increase total size
  2500.     bsr    print10            ;print file size
  2501.     bra    unlock            ;make sure to unlock
  2502. prd20    lea dirof(pc),a1
  2503.     bsr pr_string
  2504.     lea fib_FileName(a5),a1
  2505.     bsr pr_string            ;print dircetory's name
  2506.     bsr pr_lf
  2507. prd2
  2508.     bsr    check_c
  2509.     bne    unlock
  2510.     bsr    fibexnx
  2511.     tst.l    d0
  2512.     beq    unlock
  2513.     tst.b    wild_flag(a5)
  2514.     beq.s    zelma
  2515.     lea    fib_FileName(a5),a0
  2516.     lea    wild_string(a5),a1
  2517.     bsr    wildmatch
  2518.     tst.b    d0
  2519.     bne.s    prd2
  2520. zelma    tst.l    fib_DirEntryType(a5)    ;check whether is dir
  2521.     bmi.s    paulx            ;if plus,is directory
  2522.     lea    newcol(pc),a1        ;change foregnd colour
  2523.     bsr    pr_string
  2524. paulx    move.l fib_Size(a5),d0
  2525.     add.l    d0,temp1(a5)        ;increase total size
  2526.     lea    fib_FileName(a5),a1
  2527. paul1    bsr     pr_string            ;print filename
  2528.     move.l temp2(a5),d0
  2529.     beq.s paul5
  2530.     btst.l #0,d0
  2531.     bne.s paul5
  2532.     lea seqwide(pc),a1
  2533.     bra.s paul17
  2534. paul5    lea    seq(pc),a1
  2535. paul17    bsr    pr_string            ;print some tabs
  2536.     tst.l    fib_DirEntryType(a5)    ;check whether is dir
  2537.     bmi.s    paul2            ;if plus,is directory
  2538.     lea    dirtext(pc),a1        ;print '(dir)'
  2539.     bsr    pr_string
  2540.     bra.s    paul3
  2541. paul2    move.l    fib_Size(a5),d0
  2542.     bsr    print10            ;print file size
  2543. paul3    tst.l temp2(a5)            ;are we printing wide
  2544.     beq.s paul6
  2545.     addq.l #1,temp2(a5)
  2546.     move.l temp2(a5),d0
  2547.     btst.l #0,d0
  2548.     bne.s paul6
  2549.     lea widetx(pc),a1
  2550.     bsr pr_string
  2551.     bra    prd2
  2552. paul6    bsr    pr_lf            ;send return
  2553.     bra    prd2
  2554.     
  2555. unlock    move.l    d7,d1
  2556.     jsr    _LVOUnLock(a6)
  2557.     move.l    temp1(a5),d0
  2558. getoutd    rts
  2559.  
  2560. unlockOK    move.l    d7,d1
  2561.     jsr    _LVOUnLock(a6)
  2562.     moveq    #RETURN_OK,d0
  2563.     rts
  2564.  
  2565. pr_size    lea    totfiles(pc),a1
  2566.     bsr    pr_string
  2567.     bsr    print10        ;expects no. in D0
  2568.     bra    pr_lf
  2569.  
  2570. *** CHECK CTRL_C
  2571. ** RETURN NE if ctrl c, EQ if not
  2572. check_c    movem.l    d0-d1/a0-a1/a6,-(sp)    checks if CTRL_C pressed
  2573.     moveq    #0,d0
  2574.     moveq    #0,d1
  2575.     move.l    _AbsExecBase,a6
  2576.     jsr    _LVOSetSignal(a6)
  2577.     btst    #SIGBREAKB_CTRL_C,d0
  2578.     beq.s    ck_nostop
  2579.     moveq    #0,d0
  2580.     moveq    #0,d1
  2581.     bset    #SIGBREAKB_CTRL_C,d1
  2582.     jsr    _LVOSetSignal(a6)
  2583.     move.l    dosbase(a5),a6
  2584.     lea    breaktx(pc),a0
  2585.     bsr    new_print
  2586.     moveq    #1,d0            NE: STOP!!!
  2587.     move.b    d0,ctrl_c_flag(a5)
  2588.     movem.l    (sp)+,d0-d1/a0-a1/a6
  2589.     rts
  2590. ck_nostop
  2591.     clr.b    ctrl_c_flag(a5)
  2592.     moveq    #0,d0            EQ: no stop
  2593.     movem.l    (sp)+,d0-d1/a0-a1/a6
  2594.     rts
  2595.  
  2596.  
  2597. *ALLOCATE MEMORY D0=size D1=type
  2598. iwantmem    movem.l a0-a1/d1,-(sp)
  2599.     move.l _AbsExecBase,a6
  2600.     jsr _LVOAllocMem(a6)
  2601.     move.l dosbase(a5),a6
  2602.     movem.l (sp)+,a0-a1/d1
  2603.     rts
  2604. *FREEMEM A1=ptr to mem block D0=size
  2605. givemem    move.l _AbsExecBase,a6
  2606.     jsr _LVOFreeMem(a6)
  2607.     move.l dosbase(a5),a6
  2608.     rts
  2609.     
  2610.  
  2611. *REMOVE PATH A0-> source A1->destination
  2612. rempath    movem.l a0-a2/d0,-(sp)
  2613. rempath1    move.l a0,a2
  2614. rempath2    move.b (a0)+,d0
  2615.     cmp.b #'/',d0
  2616.     beq.s rempath1
  2617.     cmp.b #':',d0
  2618.     beq.s rempath1
  2619.     tst.b d0
  2620.     bne.s rempath2
  2621.     move.l a2,a0
  2622.     bsr cp_string
  2623.     movem.l (sp)+,a0-a2/d0
  2624.     rts
  2625.  
  2626.  
  2627. ** PRINT STRING (A1) USING indent_count(a5) AS A SPACE INDENT COUNT
  2628. prindent    movem.l    d7/a0-a1,-(sp)
  2629.     move.w    indent_count(a5),d7
  2630.     move.l    a1,a0
  2631.     and.w    #$3f,d7
  2632.     beq.s    1$
  2633.     bra.s    2$
  2634. 3$    bsr    pr_space    print d7 spaces
  2635. 2$    dbra    d7,3$
  2636.     move.l    a0,a1
  2637. 1$    bsr    pr_string
  2638.     movem.l    (sp)+,d7/a0-a1
  2639.     rts
  2640.  
  2641. ** ENTRY A0 pts to parameter.
  2642. ** EXIT D0=lower case char after dash OR 0 if no dash command.
  2643. return_dash_option
  2644.     moveq    #0,d0
  2645.     cmp.b    #'-',(a0)
  2646.     bne.s    2$
  2647. 1$    move.b    1(a0),d0
  2648.     cmp.b    #'a',d0
  2649.     blo.s    2$
  2650.     cmp.b    #'z',d0
  2651.     bhi.s    2$
  2652.     sub.b    #$20,d0
  2653. 2$    rts
  2654.     
  2655. ** ENTRY A0 pts to parameter. If it is -r then set recurs_flag, otherwise clr it
  2656. check_recurs
  2657.     move.l    d0,-(sp)
  2658.     clr.b    recurs_flag(a5)
  2659.     bsr    return_dash_option
  2660.     cmp.b    #'R',d0
  2661.     bne.s    1$
  2662.     move.b    #1,recurs_flag(a5)
  2663. 1$    move.l    (sp)+,d0
  2664.     rts
  2665.  
  2666.     
  2667. *THE COPY COMMAND
  2668. ** V1.23 major alterations to allow recursive file copying
  2669. copyz    lea    parm2(a5),a2
  2670.     tst.l    4(a2)        check if only 2 parameters
  2671.     beq.s     copy_fail
  2672.     move.l    (a2),a0
  2673.     bsr    check_recurs
  2674.     tst.b    recurs_flag(a5)
  2675.     beq.s    1$
  2676.     move.l    (a2)+,d0        bump the pointer
  2677. 1$    tst.l    8(a2)        CHECK PARM4 IF DOING MULTIPLE FILE COPY
  2678.     beq.s    2$
  2679. 4$    move.l    (a2)+,a3        multiple files to directory copy
  2680.     lea    -4(a2),a1
  2681. 3$    move.l    (a1)+,d0        search for end
  2682.     bne.s    3$
  2683.     move.l    -8(a1),a4        grab dest directory
  2684.     cmp.l    a4,a3
  2685.     beq    copy_fin
  2686.     move.l    a2,-(sp)
  2687.     bsr.s    5$        do one copy
  2688.     move.l    (sp)+,a2
  2689.     tst.l    d0
  2690.     bne.s    copy_fail
  2691.     bra.s    4$
  2692.     
  2693. 2$    move.l    (a2)+,a3        SOURCE
  2694.     move.l    (a2),a4        DEST
  2695. 5$    moveq    #0,d6
  2696.     clr.w    indent_count(a5)
  2697.     bsr    perform_copy
  2698.     tst.l    d6
  2699.     bne.s    copy_fail
  2700. copy_fin    moveq    #RETURN_OK,D0
  2701.     rts
  2702. copy_fail    moveq    #RETURN_ERROR,D0
  2703.     rts
  2704.  
  2705. ***  SUPPLEMENTARY COPY ROUTINES ***
  2706. ** ENTRY A2=fib, RETURN D0=address
  2707. alloc_file_space
  2708.     move.l    fib_Size(a2),d0
  2709.     move.l    d0,4+cp_filesize(sp)
  2710.     moveq    #0,d1
  2711.     bsr    iwantmem        ALLOCATE SPACE FOR FILE
  2712.     move.l    d0,4+cp_fileaddr(sp)    save 0 if failure
  2713.     rts
  2714.     
  2715. ** ENTRY D1=name, RETURN D0=handle
  2716. open_read_file
  2717.     move.l    #MODE_OLDFILE,d2
  2718.     jsr    _LVOOpen(a6)    OPEN FILE
  2719.     move.l    d0,4+cp_ropen(sp)    save the handle
  2720.     rts
  2721.  
  2722. **ENTRY D0=handle
  2723. read_to_mem
  2724.     move.l    d0,d1
  2725.     move.l    4+cp_fileaddr(sp),d2
  2726.     move.l    4+cp_filesize(sp),d3
  2727.     jsr    _LVORead(a6)    READ FILE returns -1 if error
  2728.     rts
  2729.  
  2730. close_read_file
  2731.     move.l    4+cp_ropen(sp),d1
  2732.     jsr    _LVOClose(a6)    CLOSE FILE
  2733.     clr.l    4+cp_ropen(sp)        null it incase later dos errs
  2734.     rts
  2735.  
  2736. **ENTRY D1=name, RETURN D0=handle
  2737. open_write_file
  2738.     move.l    #MODE_NEWFILE,d2
  2739.     jsr    _LVOOpen(a6)    OPEN FILE
  2740.     move.l    d0,4+cp_wopen(sp)    save the handle
  2741.     rts
  2742.  
  2743. **ENTRY D0=handle
  2744. write_from_mem
  2745.     move.l    d0,d1
  2746.     move.l    4+cp_fileaddr(sp),d2
  2747.     move.l    4+cp_filesize(sp),d3
  2748.     jsr    _LVOWrite(a6)    WRITE FILE returns -1 if error
  2749.     rts
  2750.  
  2751. close_write_file
  2752.     move.l    4+cp_wopen(sp),d1
  2753.     jsr    _LVOClose(a6)    CLOSE FILE
  2754.     clr.l    4+cp_wopen(sp)
  2755.     rts
  2756.  
  2757. dealloc_file_space
  2758.     move.l    4+cp_fileaddr(sp),a1
  2759.     move.l    4+cp_filesize(sp),d0
  2760.     bsr    givemem        DEALLOCATE FILE SPACE
  2761.     clr.l    4+cp_fileaddr(sp)
  2762.     rts
  2763.  
  2764. print_copyOK
  2765.     lea    copyOK(pc),a1
  2766.     bsr    pr_string        ;print '...copied'
  2767.     rts
  2768.     
  2769. *STACK STUFF
  2770. cp_fibaddr    equ    0
  2771. cp_srclock    equ    cp_fibaddr+4
  2772. cp_fileaddr    equ    cp_srclock+4
  2773. cp_filesize    equ    cp_fileaddr+4
  2774. cp_ropen        equ    cp_filesize+4
  2775. cp_wopen        equ    cp_ropen+4
  2776. cp_fname        equ    cp_wopen+4    allow 128 bytes
  2777.     
  2778. cp_size        equ    cp_fname+128
  2779.  
  2780. ** RECURSIVE STACK FRAME
  2781. nth_srcname    equ    0
  2782. nth_destname    equ    128
  2783. nth_size        equ    256
  2784.     
  2785. ** ENTRY A3 = source   A4 = destination  D6=0 no errors yet, NE just exit
  2786. ** indent_count(a5) is used
  2787. perform_copy
  2788.     tst.l    d6
  2789.     beq.s    1$    exit if D6<>0
  2790.     rts
  2791. 1$    lea    -cp_size(sp),sp    ALLOCATE STACK SPACE
  2792.     move.l    sp,a0
  2793.     lea    cp_fname(sp),a1
  2794. 2$    clr.b    (a0)+        clear all parameters on stack
  2795.     cmp.l    a1,a0
  2796.     blo.s    2$
  2797.     move.l    a3,a0
  2798.     bsr    handle_wild_dirs
  2799.     move.l    a3,d1
  2800.     moveq    #ACCESS_READ,d2
  2801.     jsr    _LVOLock(a6)
  2802.     move.l    d0,cp_srclock(sp)    store 0 if failure
  2803.     tst.l    d0
  2804.     beq    kill_copyDOS
  2805. * ALLOCATE FILEINFOBLOCK
  2806.     move.l    #FIB,D0
  2807.     moveq    #0,d1
  2808.     bsr    iwantmem
  2809.     move.l    d0,cp_fibaddr(sp)    store 0 if failure ,save fib addr
  2810.     tst.l    d0
  2811.     beq    kill_copy
  2812. * EXAMINE SOURCE
  2813.     move.l    cp_srclock(sp),d1
  2814.     move.l    cp_fibaddr(sp),d2
  2815.     move.l    d2,a2        A2=fibaddr
  2816.     jsr    _LVOExamine(a6)    EXAMINE SOURCE
  2817.     tst.l    d0
  2818.     beq    kill_copyDOS
  2819.     lea    fib_FileName(a2),a1
  2820. *    bsr    pr_string
  2821.     tst.l    fib_DirEntryType(a2)
  2822.     bpl    next_dir_entry    if source is dir then attempt dir to dir
  2823.  
  2824. * HANDLE FILE TO FILE or FILE TO DIR
  2825.     move.l    a3,a1
  2826.  
  2827.     bsr    prindent        PRINT NAME OF FILE BEING COPIED
  2828.     move.l    cp_fibaddr(sp),a2    reset a2 to fibaddr
  2829.     bsr    alloc_file_space
  2830.  
  2831.     tst.l    d0
  2832.     beq    kill_copy
  2833.     move.l    a3,d1
  2834.     bsr    open_read_file
  2835.  
  2836.     tst.l    d0
  2837.     beq    kill_copyDOS
  2838.     bsr    read_to_mem
  2839.  
  2840.     tst.l    d0
  2841.     bmi    kill_copyDOS
  2842.     bsr    close_read_file
  2843.     
  2844.     move.l    a3,a0
  2845.     lea    cp_fname(sp),a1
  2846.     bsr    rempath        REMOVE PATH FROM SRC NAME
  2847.     move.l    a4,d1
  2848.     moveq    #ACCESS_READ,d2
  2849.     jsr    _LVOLock(a6)    LOCK DEST
  2850.     tst.l    d0
  2851.     beq    do_file_to_file
  2852.     move.l    d0,d1
  2853.     move.l    d0,d5        D5=lock temporary
  2854.     move.l    cp_fibaddr(sp),d2
  2855.     move.l    d2,a2        A2=fibaddr
  2856.     jsr    _LVOExamine(a6)    EXAMINE SOURCE  assume does not fail
  2857.     move.l    fib_DirEntryType(a2),d4
  2858.     move.l    d5,d1
  2859.     jsr    _LVOUnLock(a6)
  2860.     tst.l    d4
  2861.     bmi    do_file_to_file
  2862.     move.l    a4,a0        DO ONLY IF FILE TO DIR
  2863.     lea    cp_fname(sp),a1
  2864.     lea    fib_FileName(a2),a2    !!!! USING FIB AS TEMPORARY FOR NEW FNAME
  2865.     bsr    addpath
  2866.     move.l    a2,d1
  2867.     bra.s    go_open
  2868. do_file_to_file
  2869.     move.l    a4,d1        destination = new filename
  2870. go_open    bsr    open_write_file
  2871.     
  2872.     tst.l    d0
  2873.     beq    kill_copyDOS
  2874.     move.l    cp_fibaddr(sp),a2    reset a2 to fibaddr
  2875.     bsr    write_from_mem
  2876.  
  2877.     tst.l    d0
  2878.     bmi    kill_copyDOS
  2879.     bsr    close_write_file
  2880.     bsr    dealloc_file_space
  2881.     bsr    print_copyOK
  2882.     bra    exit_cp
  2883.  
  2884. ** MAIN LOOP FOR DIR TO DIR COPYING STARTS HERE
  2885. next_dir_entry
  2886.     bsr    check_c
  2887.     bne    kill_copy
  2888.     move.l    cp_srclock(sp),d1
  2889.     move.l    cp_fibaddr(sp),d2
  2890.     move.l    d2,a2        guarantee a2=fibaddr
  2891.     jsr    _LVOExNext(a6)    get next entry
  2892.     tst.l    d0
  2893.     beq.s    exit_cp
  2894.     
  2895.     tst.b    wild_flag(a5)
  2896.     beq    test_if_file
  2897.     lea    fib_FileName(a2),a0
  2898.     lea    wild_string(a5),a1
  2899.     bsr    wildmatch
  2900.     tst.b    d0
  2901.     bne.s    next_dir_entry
  2902.     bra    test_if_file
  2903.  
  2904. exit_cp    move.l    cp_srclock(sp),d1    if no more entries then exit
  2905.     jsr    _LVOUnLock(a6)
  2906.     move.l    cp_fibaddr(sp),a1
  2907.     move.l    #FIB,d0
  2908.     bsr    givemem
  2909.     lea    cp_size(sp),sp
  2910.     rts            EXIT BACK
  2911. test_if_file
  2912.     tst.l    fib_DirEntryType(a2)
  2913.     bpl    must_be_dir
  2914.     move.l    a3,a0        *** COPY A FILE ***
  2915.     lea    fib_FileName(a2),a1
  2916.     lea    cp_fname(sp),a2
  2917.     bsr    addpath        add src dir path to filename
  2918.     move.l    a2,a1
  2919.     bsr    prindent        PRINT NAME OF FILE BEING COPIED
  2920.     move.l    cp_fibaddr(sp),a2    reset a2 to fibaddr
  2921.     bsr    alloc_file_space
  2922.  
  2923.     tst.l    d0
  2924.     beq    kill_copy
  2925.     lea    cp_fname(sp),a0
  2926.     move.l    a0,d1
  2927.     bsr    open_read_file
  2928.     tst.l    d0
  2929.     beq    kill_copyDOS
  2930.     bsr    read_to_mem
  2931.     tst.l    d0
  2932.     bmi    kill_copyDOS
  2933.     bsr    close_read_file
  2934.     
  2935.     move.l    a4,a0        dest name
  2936.     lea    fib_FileName(a2),a1
  2937.     lea    cp_fname(sp),a2
  2938.     bsr    addpath        add dest dir path to filename
  2939.     
  2940.     move.l    a2,d1
  2941.     bsr    open_write_file
  2942.  
  2943.     tst.l    d0
  2944.     beq    kill_copyDOS
  2945.     move.l    cp_fibaddr(sp),a2    reset a2 to fibaddr
  2946.     bsr    write_from_mem
  2947.  
  2948.     tst.l    d0
  2949.     bmi    kill_copyDOS
  2950.     bsr    close_write_file
  2951.     bsr    dealloc_file_space
  2952.     bsr    print_copyOK
  2953.     BRA    next_dir_entry
  2954. must_be_dir
  2955.     tst.b    recurs_flag(a5)
  2956.     beq    next_dir_entry
  2957.     lea    -nth_size(sp),sp
  2958.     move.l    a4,a0
  2959.     lea    fib_FileName(a2),a1
  2960.     lea    nth_destname(sp),a2    NEW DESTINATION DIRECTORY
  2961.     bsr    addpath        add dest dir path to filename
  2962.     
  2963.     move.l    a2,d1
  2964.     jsr    _LVOCreateDir(a6)    dont care if error is reported (will be picked up later)
  2965.     move.l    d0,d1
  2966.     beq.s    1$
  2967.     jsr    _LVOUnLock(a6)
  2968. 1$    move.l    cp_fibaddr+nth_size(sp),a2
  2969.     move.l    a3,a0
  2970.     lea    fib_FileName(a2),a1
  2971.     lea    nth_srcname(sp),a2    NEW SOURCE DIRECTORY
  2972.     bsr    addpath
  2973.     move.l    a2,a1
  2974.     bsr    prindent        PRINT NAME OF NEW DIR
  2975.     bsr    pr_lf
  2976.     addq.w    #1,indent_count(a5)
  2977.     MOVEM.L    a3-a4,-(sp)    save old source and dest
  2978.     lea    8+nth_srcname(sp),a3
  2979.     lea    8+nth_destname(sp),a4
  2980.     bsr    perform_copy    RECURSION!!!!
  2981.     MOVEM.L    (SP)+,A3-A4
  2982.     lea    nth_size(sp),sp
  2983.     subq.w    #1,indent_count(a5)
  2984.     tst.l    d6
  2985.     bne    kill_copy
  2986.     bra    next_dir_entry
  2987.  
  2988.     
  2989. *** SAFELY HANDLE ERRORS
  2990. kill_copyDOS
  2991.     jsr    _LVOIoErr(a6)
  2992.     bsr    pr_DOSerr        print error
  2993. kill_copy    move.l    cp_fibaddr(sp),d0
  2994.     beq.s    1$
  2995.     move.l    d0,a1
  2996.     move.l    #FIB,d0
  2997.     bsr    givemem
  2998. 1$    move.l    cp_srclock(sp),d1
  2999.     beq.s    2$
  3000.     jsr    _LVOUnLock(a6)
  3001. 2$    move.l    cp_fileaddr(sp),d0
  3002.     beq.s    3$
  3003.     move.l    d0,a1
  3004.     move.l    cp_filesize(sp),d0
  3005.     bsr    givemem
  3006. 3$    move.l    cp_ropen(sp),d1
  3007.     beq.s    4$    open return D0=0 if failure
  3008.     jsr    _LVOClose(a6)
  3009. 4$    move.l    cp_wopen(sp),d1
  3010.     beq.s    5$
  3011.     jsr    _LVOClose(a6)
  3012. 5$    MOVEQ    #1,D6        SET THE ERROR FLAG!!!!!
  3013.     lea    cp_size(sp),sp
  3014.     rts            EXIT BACK
  3015.  
  3016. ** ENTRY A0=name
  3017. ** EXIT  D0=address, D1=size
  3018. readfile    movem.l    a0/d2-d6,-(sp)
  3019.     move.l    a0,d1
  3020.     move.l    #MODE_OLDFILE,d2
  3021.     jsr    _LVOOpen(a6)    OPEN FILE
  3022.     move.l    d0,d4    d4=handle
  3023.     beq    readerr
  3024.     moveq    #1,d3
  3025.     moveq    #0,d2
  3026.     move.l    d4,d1
  3027.     jsr    _LVOSeek(a6)
  3028.     moveq    #-1,d3
  3029.     moveq    #0,d2
  3030.     move.l    d4,d1
  3031.     jsr    _LVOSeek(a6)
  3032.     move.l    d0,d5    d5=size
  3033.     moveq    #0,d1
  3034.     bsr    iwantmem
  3035.     tst.l    d0
  3036.     beq    readerr2
  3037.     move.l    d0,d6    d6=addr
  3038.     move.l    d6,d2
  3039.     move.l    d5,d3
  3040.     move.l    d4,d1
  3041.     jsr    _LVORead(a6)
  3042.  
  3043.     tst.l    d0
  3044.     bmi    readerr3
  3045.     move.l    d4,d1
  3046.     jsr    _LVOClose(a6)
  3047.     move.l    d6,d0
  3048.     move.l    d5,d1
  3049.     movem.l    (sp)+,a0/d2-d6
  3050.     rts
  3051. readerr3    move.l    d6,a1
  3052.     move.l    d5,d0
  3053.     bsr    givemem    NB won't work correctly if memory fail occurs. Will try to print DOS error for this
  3054. readerr2    move.l    d4,d1
  3055.     jsr    _LVOClose(a6)
  3056. readerr    move.l    please_close_me(a5),d1    V1.29 Allows for additional
  3057.     beq.s    1$            file closure. Needed for
  3058.     jsr    _LVOClose(a6)        JOIN command
  3059.     clr.l    please_close_me(a5)
  3060. 1$    bra    DOSerr
  3061.  
  3062. ** MORE TYPE COMMAND
  3063. morez    tst.l    parm2(a5)
  3064.     bne.s    1$
  3065.     moveq    #RETURN_ERROR,d0
  3066.     rts
  3067. 1$    moveq    #23,d4
  3068.     tst.l    parm3(a5)
  3069.     beq    3$
  3070.     move.l    parm3(a5),a1
  3071.     bsr    convert_ASCII_to_num
  3072.     tst.b    d1
  3073.     beq    3$
  3074.     cmp.w    #20,d0
  3075.     blo.s    3$
  3076.     move.l    d0,d4
  3077. 3$    subq.w    #1,d4
  3078.     move.w    d4,line_count(a5)
  3079.  
  3080.     move.l    parm2(a5),a0
  3081.     bsr    readfile
  3082.     move.l    d0,-(sp)    push address
  3083.     move.l    d1,-(sp)    push size
  3084.     moveq    #1,d4
  3085.     move.l    d0,d5    d5=start
  3086.     move.l    d0,a4    a4=ptr
  3087.     move.l     d0,d6
  3088.     add.l    d1,d6    d6=end addr
  3089. 2$    bsr    make_screen
  3090.     tst.l    d4
  3091.     bne.s    2$
  3092.     move.l    (sp)+,d0
  3093.     move.l    (sp)+,a1
  3094.     bsr    givemem
  3095.     bsr    pr_lf
  3096.     moveq    #RETURN_OK,D0
  3097.     RTS
  3098.  
  3099. make_screen
  3100.     lea    clstx(pc),a1
  3101.     bsr    pr_string
  3102.     move.w    line_count(a5),d1
  3103.     move.w    d1,d2
  3104.     sub.w    #19,d2
  3105.     move.l    a4,-(sp)
  3106.     bra.s    1$
  3107. 3$    bsr    pr_lf    PRINT SCREEN FULL OF LINES
  3108. 1$    bsr    pr_line
  3109. 2$    cmp.l    d6,a4    check against end
  3110.     beq.s    9$
  3111.     move.b    (a4)+,d0
  3112.     cmp.b    #10,d0
  3113.     bne.s    2$
  3114.     cmp.w    d2,d1
  3115.     bne.s    8$
  3116.     move.l    a4,a3    A3 points to end of page marker
  3117. 8$    dbra    d1,3$
  3118.     
  3119. 9$    move.l    a4,d7    D7 points to end
  3120.     move.l    (sp)+,a4    
  3121. waitabit    move.l    inhandle(a5),d1
  3122.     lea    tempbytes(a5),a0
  3123.     move.l    a0,d2
  3124.     moveq    #1,d3
  3125.     jsr    _LVORead(a6)        wait for space key
  3126.     moveq    #0,d0        ;clear top bytes
  3127.     move.b    tempbytes(a5),d0    ;test byte of input line
  3128.     cmp.b    #'a',d0
  3129.     blo.s    go_upper
  3130.     sub.b    #$20,d0
  3131. go_upper    cmp.b    #13,d0        IS THIS A CARRIAGE RETURN?
  3132.     bne.s    ck_space
  3133.     lea    scroll_up_tx(pc),a1
  3134.     bsr    pr_string        SCROLL UP ONE LINE
  3135.     lea    carriage_tx(pc),a1
  3136.     bsr    pr_string        SEND CURSOR TO START OF LINE
  3137.  
  3138. 2$    cmp.l    d6,a4    advance one line
  3139.     beq.s    3$
  3140.     move.b    (a4)+,d0
  3141.     cmp.b    #10,d0
  3142.     bne.s    2$
  3143.  
  3144. 3$    cmp.l    d6,a3    move a3 down one line too
  3145.     beq.s    4$
  3146.     move.b    (a3)+,d0
  3147.     cmp.b    #10,d0
  3148.     bne.s    3$
  3149. 4$    move.l    a4,-(sp)
  3150.     move.l    d7,a4
  3151.     cmp.l    d7,d6
  3152.     beq.s    1$
  3153.     bsr    pr_line    print line from d7
  3154. 1$    cmp.l    d6,a4    advance D7 one line
  3155.     beq.s    5$
  3156.     move.b    (a4)+,d0
  3157.     cmp.b    #10,d0
  3158.     bne.s    1$
  3159. 5$    move.l    a4,d7
  3160.     move.l    (sp)+,a4
  3161.     bra.s    waitabit
  3162. ck_space    cmp.b    #32,d0    
  3163.     bne.s    ck_top
  3164.     move.l    a3,a4
  3165.     moveq    #1,d4
  3166.     rts
  3167. ck_top    cmp.b    #'T',d0
  3168.     bne.s    ck_bot
  3169.     move.l    d5,a4
  3170.     moveq    #1,d4
  3171.     rts
  3172. ck_bot    cmp.b    #'B',d0
  3173.     bne.s    ck_back
  3174.     move.l    d6,a4
  3175.     bra.s    look_back
  3176. ck_back    cmp.b    #8,d0
  3177.     bne.s    unknown_key
  3178. look_back    move.w    #20,d1
  3179. 6$    cmp.l    d5,a4    check against start
  3180.     beq.s    5$
  3181.     move.b    -(a4),d0
  3182.     cmp.b    #10,d0
  3183.     bne.s    6$
  3184.     dbra    d1,6$
  3185.     lea    1(a4),a4
  3186. 5$    moveq    #-1,d4
  3187.     rts
  3188. unknown_key
  3189.     moveq    #0,d4
  3190.     rts
  3191.  
  3192. find_end_of_line
  3193. 2$    cmp.l    d6,a0    check against end
  3194.     beq.s    1$
  3195.     move.b    (a0)+,d0
  3196.     cmp.b    #10,d0
  3197.     bne.s    2$
  3198.     lea    -1(a0),a0
  3199. 1$    rts
  3200.  
  3201. ** PRINT STRING AT A4 ENDING IN LF
  3202. pr_line    movem.l    d0-d3/a0,-(sp)
  3203.     move.l    a4,d2
  3204.     move.l    outhandle(a5),d1
  3205.     move.l    a4,a0
  3206.     bsr    find_end_of_line
  3207.     sub.l    a4,a0
  3208.     move.l    a0,d3
  3209.     beq.s    3$    don't print if 0
  3210.     jsr    _LVOWrite(a6)
  3211. 3$    movem.l    (sp)+,d0-d3/a0
  3212.     rts
  3213.  
  3214.  
  3215. ** ENTRY D6=end of file A4=current pos
  3216. pr_screen    bsr    check_c
  3217.     bne    type_break
  3218.     bsr    pr_line
  3219.     bsr    pr_lf
  3220. 2$    cmp.l    d6,a4    check against end
  3221.     beq.s    type_break
  3222.     move.b    (a4)+,d0
  3223.     cmp.b    #10,d0
  3224.     bne.s    2$
  3225.     bra.s    pr_screen
  3226. type_break
  3227.     rts
  3228.     
  3229. *Type out ASCII file command    
  3230. typez    tst.l    parm2(a5)
  3231.     bne.s    1$
  3232.     rts
  3233. 1$    move.l    parm2(a5),a0
  3234.     bsr    readfile
  3235.     bsr    raw_off    MAKE SURE YOU CAN PRESS SPACE TO HOLD IT
  3236.     move.l    d0,-(sp)    push address
  3237.     move.l    d1,-(sp)    push size
  3238.     move.l    d0,a4    a4=ptr
  3239.     move.l     d0,d6
  3240.     add.l    d1,d6    d6=end addr
  3241. next_scr    bsr    pr_screen
  3242.     bsr    raw_on
  3243. freef1    move.l    (sp)+,d0
  3244.     move.l    (sp)+,a1
  3245.     bsr    givemem
  3246.     moveq    #RETURN_OK,D0
  3247.     RTS
  3248.  
  3249.  
  3250. *EXECUTE SCRIPT FILE COMMAND
  3251. xz    tst.l    parm2(a5)
  3252.     bne.s    xz_oh
  3253.     rts
  3254. xz_oh    bsr fixpam2
  3255. xz2    bsr    readfile        ;A0 pts to filename
  3256.     move.l    d1,scsize(a5)
  3257.     move.l    d0,scaddr(a5)
  3258.     move.l    d0,scptr(a5)
  3259.     move.b    #1,scflag(a5)        ;make shell think text lines are in memory
  3260.     move.l    (sp)+,d0        ;kill return address
  3261.     clr.b    mult_comm_flag(a5)
  3262.     bra chorus
  3263.  
  3264. echo_parm    bsr    fixpam2
  3265.     move.l    a0,a1
  3266.     move.l    a0,a2
  3267.     bra.s    3$
  3268. 2$    move.b    d0,(a2)+
  3269. 3$    move.b    (a0)+,d0
  3270.     beq.s    1$
  3271.     cmp.b    #'\',d0
  3272.     bne.s    4$
  3273.     move.b    (a0)+,d0
  3274.     bra.s    2$
  3275. 4$    cmp.b    #'^',d0
  3276.     bne.s    2$
  3277.     move.b    (a0)+,d0
  3278.     and.b    #$3f,d0
  3279.     bra.s    2$
  3280. 1$    clr.b    (a2)+
  3281.     bsr pr_string
  3282.     rts
  3283.  
  3284. *ECHO COMMAND
  3285. echoz    bsr    echo_parm
  3286.     bsr    pr_lf
  3287.     moveq    #RETURN_OK,d0
  3288.     rts
  3289.     
  3290. ** MEM INFO :RETURN 3 LONGWORDS AT A0 -> FREE CHIP,FAST,TOTAL
  3291. memory_info
  3292.     move.l    _AbsExecBase,a6
  3293.     jsr    _LVOForbid(a6)    ; don't let 'em change while we ask
  3294.     move.l    #MEMF_CHIP,d1    ; ok, check free chip
  3295.     jsr    _LVOAvailMem(a6)    ; ask system how much there is
  3296.     move.l    d0,(A0)
  3297.     move.l    #MEMF_FAST,d1    ; check fast mem avail
  3298.     jsr    _LVOAvailMem(a6)
  3299.     move.l    d0,4(a0)
  3300.     move.l    #MEMF_PUBLIC,d1     ; get all available memory
  3301.     jsr    _LVOAvailMem(a6)
  3302.     move.l    d0,8(a0)
  3303.     jsr    _LVOPermit(a6)
  3304.     move.l    dosbase(a5),a6    ;restore dosbase
  3305.     rts
  3306.  
  3307. *AVAIL COMMAND
  3308. availz    lea    -12(sp),sp
  3309.     lea    (a7),a0
  3310.     bsr    memory_info
  3311.     move.l    a0,a1
  3312.     lea    memess(pc),a0
  3313.     bsr    new_print
  3314.     lea    12(sp),sp
  3315.     moveq    #RETURN_OK,d0
  3316.     rts
  3317.  
  3318. * ALTER WINDOW PTR FOR THIS PROCESS. USE TO DISABLE REQUESTERS POPPING UP.
  3319. * ENTRY D1=0 (NORMAL)  D1=-1 (SUBNORMAL).
  3320. changeWindowPtr
  3321.     movem.l    d1/a0,-(sp)
  3322.     move.l    thistask(a5),a0
  3323.     move.l    d1,pr_WindowPtr(a0)
  3324.     movem.l    (sp)+,d1/a0
  3325.     rts
  3326.  
  3327. get_task
  3328.     sub.l    a1,a1
  3329.     move.l    _AbsExecBase,a6
  3330.     jsr    _LVOFindTask(a6)
  3331.     move.l    d0,thistask(a5)    ;save this task address
  3332.     move.l dosbase(a5),a6    ;restore dosbase
  3333.     rts
  3334.     
  3335.  
  3336. dp_Link        EQU  $00   ;DosPacket Structure
  3337. dp_Port        EQU  $04
  3338. dp_Type        EQU  $08
  3339. dp_Arg1        EQU  $14
  3340. dp_SIZEOF        EQU  $30
  3341.  
  3342. sp_Msg        EQU  $00   ;StandardPacket Structure
  3343. sp_Pkt        EQU  $14
  3344. sp_SIZEOF        EQU  $44
  3345.  
  3346. LH_TAIL        EQU  $04
  3347.  
  3348. LN_PRED        EQU  $04
  3349. LN_TYPE        EQU  $08
  3350. LN_NAME        EQU  $0A
  3351.  
  3352. NT_MSGPORT    EQU  4
  3353.  
  3354. MP_FLAGS        EQU  $0E   ;Message Port Structure
  3355. MP_SIGBIT        EQU  $0F   ;Signal bit number
  3356. MP_SIGTASK    EQU  $10   ;Task to be signalled
  3357. MP_MSGLIST    EQU  $14   ;Message linked list
  3358. MP_SIZE        EQU  $22
  3359.  
  3360. PA_SIGNAL        EQU  0       ;PutAction messages
  3361.  
  3362. clearArgs
  3363.     movem.l    a0/d0,-(sp)
  3364.     lea    myArg1(a5),a0
  3365.     moveq    #6,d0
  3366. 1$    clr.l    (a0)+
  3367.     dbra    d0,1$
  3368.     movem.l    (sp)+,a0/d0
  3369.     rts
  3370.     
  3371. raw_on
  3372.     moveq    #-1,d6
  3373.     bra.s    raw_switch
  3374. raw_off
  3375.     moveq    #0,d6
  3376.     bra.s    raw_switch
  3377.     nop
  3378.  
  3379. *WINDOW TYPE CHANGER    
  3380. raw_switch
  3381.     move.l    a1,-(sp)
  3382.     move.l    thistask(a5),a1
  3383.     move.l    pr_ConsoleTask(a1),packettask(a5)
  3384.     bsr    clearArgs
  3385.     move.l    #ACTION_SCREEN_MODE,packettype(a5)
  3386.     move.l    d6,myArg1(a5)
  3387.     bsr    sendpacket
  3388.     move.l    (sp)+,a1
  3389.     rts
  3390.     
  3391. ** ENTRY Uses myArg1-myArg7, and packettask, packettype
  3392. sendpacket
  3393.     movem.l    d0-d1/a0-a3,-(sp)
  3394.     move.l    _AbsExecBase,a6
  3395.     moveq    #MP_SIZE+sp_SIZEOF+1,d0
  3396.     lea    myport,a2
  3397.     move.l    a2,a0
  3398. 1$    clr.b    (a0)+    clear bss section
  3399.     dbra    d0,1$
  3400.     moveq    #-1,d0
  3401.     jsr    _LVOAllocSignal(a6)
  3402.     move.b    d0,MP_SIGBIT(a2)
  3403.     bmi.s    creaporte        -> no sigbit
  3404.     move.l    thistask(a5),MP_SIGTASK(a2)
  3405.     move.b    #NT_MSGPORT,LN_TYPE(a2)
  3406.     move.b    #PA_SIGNAL,MP_FLAGS(a2)
  3407.     lea    MP_MSGLIST(a2),a0
  3408. *newlist
  3409.     move.l    a0,(a0)
  3410.     addq.l    #LH_TAIL,(a0)
  3411.     clr.l    LH_TAIL(a0)
  3412.     move.l    a0,(LH_TAIL+LN_PRED)(a0)
  3413. packetstuff
  3414.     lea    mypacket,a3        A3=packet
  3415.     lea    dp_Arg1+sp_Pkt(a3),a0
  3416.     lea    myArg1(a5),a1
  3417.     moveq    #6,d0
  3418. 1$    move.l    (a1)+,(a0)+
  3419.     dbra    d0,1$
  3420.  
  3421. *    move.l    d6,dp_Arg1+sp_Pkt(a3)    1
  3422.  
  3423. *    move.l    thistask(a5),a1
  3424. *    move.l    pr_ConsoleTask(a1),d6    D6=pid
  3425.     
  3426.     lea    sp_Msg(a3),a1
  3427.     move.l    a1,sp_Pkt(a3)        2
  3428.     lea    sp_Pkt(a3),a1
  3429.     move.l    a1,LN_NAME(a3)        3
  3430.     move.l    a2,dp_Port+sp_Pkt(a3)    4
  3431.     move.l    packettype(a5),dp_Type+sp_Pkt(a3)
  3432. *    move.l    #994,dp_Type+sp_Pkt(a3)    5
  3433. *    move.l    d6,a0
  3434.     move.l    packettask(a5),a0
  3435.     move.l    a3,a1
  3436.     jsr    _LVOPutMsg(a6)    EXEC
  3437.  
  3438.     move.l    a2,a0
  3439.     jsr    _LVOWaitPort(a6)    EXEC
  3440.  
  3441.     move.l    a2,a0
  3442.     jsr    _LVOGetMsg(a6)    EXEC
  3443. delportnpacket
  3444.     moveq    #0,d0
  3445.     move.b    MP_SIGBIT(a2),d0
  3446.     bmi.s    creaporte        -> no sigbit to free
  3447.     jsr    _LVOFreeSignal(a6)
  3448. creaporte    move.l    dosbase(a5),a6    ;restore dosbase
  3449.     movem.l    (sp)+,d0-d1/a0-a3
  3450.     rts
  3451.  
  3452.  
  3453. *****************************************
  3454. *    RELABEL COMMAND        *
  3455. *****************************************
  3456. relabelz    tst.l    parm3(a5)
  3457.     bne.s    2$
  3458. 5$    moveq    #RETURN_ERROR,D0
  3459.     rts
  3460. 2$    move.l    parm2(a5),a0
  3461.     bsr    check_for_colon
  3462.     beq.s    4$
  3463.     lea    no_colon_tx(pc),a1
  3464.     bsr    pr_string
  3465.     bra    5$
  3466. 4$    move.l    parm2(a5),d1    PARM2=DF0: etc
  3467.     jsr    _LVODeviceProc(a6)
  3468.     tst.l    d0
  3469.     beq    DOSerr
  3470.     move.l    d0,packettask(a5)
  3471.     move.l    #256,d0
  3472.     moveq    #0,d1
  3473.     bsr    iwantmem        ASSUME GETS 256 BYTES
  3474.     move.l    d0,a2        A2=destination
  3475.     lsr.l    #2,d0
  3476.     bsr    clearArgs
  3477.     move.l    d0,myArg1(a5)    BPTR to my string
  3478.     move.l    parm3(a5),a0    NewName
  3479.     lea    1(a2),a1        A1=after count
  3480.     moveq    #0,d0
  3481. 1$    move.b    (a0)+,(a1)+
  3482.     addq.l    #1,d0
  3483.     cmp.b    #':',(a0)        ALLOW FOR IDIOTS WHO PUT : ON END
  3484.     beq.s    3$
  3485.     tst.b    (a0)
  3486.     bne.s    1$
  3487. 3$    move.b    d0,(a2)
  3488.     move.l    #ACTION_RENAME_DISK,packettype(a5)    TYPE=RENAME_DISK
  3489.     bsr    sendpacket
  3490.     move.l    a2,a1
  3491.     move.l    #256,d0
  3492.     bsr    givemem
  3493.     bsr    changedisk
  3494. *    bsr    eval_CD        -IS MORE ELEGANT IF I LEAVE OUT.
  3495.     moveq    #RETURN_OK,d0    USER WILL HAVE TO TYPE CD TO CHANGE
  3496.     rts            PROPER.
  3497.  
  3498. ** USes task in packettask
  3499. changedisk
  3500.     bsr    clearArgs
  3501.     move.l    #ACTION_INHIBIT,packettype(a5)
  3502.     move.l    #1,myArg1(a5)
  3503.     bsr    sendpacket
  3504.     clr.l    myArg1(a5)
  3505.     bsr    sendpacket
  3506.     rts
  3507.  
  3508.  
  3509. *****************************************
  3510. *    ADDBUFFERS COMMAND        *
  3511. *****************************************
  3512. addbuffersz
  3513.     tst.l    parm3(a5)
  3514.     bne.s    1$
  3515.     moveq    #RETURN_ERROR,d0
  3516.     rts
  3517.     
  3518. 1$    bsr    clearArgs
  3519.     move.l    parm3(a5),a1
  3520.     bsr    convert_ASCII_to_num
  3521.     tst.b    d1
  3522.     beq    bad_number_error
  3523.     cmp.l    #32767,d0
  3524.     bhi    bad_number_error
  3525.     move.l    d0,myArg1(a5)
  3526.     move.l    parm2(a5),d1    PARM2=DF0: etc
  3527.     jsr    _LVODeviceProc(a6)
  3528.     tst.l    d0
  3529.     beq    DOSerr
  3530.     move.l    d0,packettask(a5)
  3531.     move.l    #ACTION_MORE_CACHE,packettype(A5)
  3532.     bsr    sendpacket
  3533.     moveq    #RETURN_OK,d0
  3534.     rts
  3535.  
  3536.  
  3537. *****************************************
  3538. *    VERSION COMMAND        *
  3539. *****************************************
  3540. versionz    lea    hello(pc),a1
  3541.     moveq    #RETURN_OK,d0
  3542.     bra    pr_string
  3543.  
  3544.  
  3545. *****************************************
  3546. *    UNSET VARIABLE COMMAND    *
  3547. *****************************************
  3548. unsetz    lea    parm2(a5),a3
  3549. 1$    tst.l    (a3)
  3550.     beq    no_more_unsets
  3551.     move.l    (a3)+,a0
  3552.     bsr    check_if_set_already_there
  3553.     tst.l    d0
  3554.     beq    unset_failure
  3555.     move.l    d0,a1
  3556.     move.l    (a1),d2    GRAB NEXT SET POINTER
  3557.     move.l    set_size(a1),d0
  3558.     move.l    d1,a0    D1=prior set
  3559.     move.l    d2,(a0)    SKIP OVER SET TO DELETE
  3560.     bsr    givemem
  3561.     bra    1$
  3562. no_more_unsets
  3563.     moveq    #RETURN_OK,d0
  3564.     rts
  3565. unset_failure
  3566.     lea    set_search_string(a5),a1
  3567.     bsr    pr_string
  3568.     lea    bad_unset_tx(pc),a1
  3569.     bsr    pr_string
  3570.     moveq    #RETURN_ERROR,d0
  3571.     rts
  3572.  
  3573.  
  3574. *****************************************
  3575. *    SET VARIABLE KEY COMMAND    *
  3576. *****************************************
  3577. set_funcz    tst.l    parm2(a5)        SEE IF ANY PARAMETERS TYPED
  3578.     beq    show_current_sets
  3579.     bsr    fixpam32        A0=parm2 A1=parm3
  3580.     bsr    check_if_set_already_there
  3581.     tst.l    d0
  3582.     beq    create_new_set
  3583.     bra    update_old_set
  3584.  
  3585. create_new_set
  3586.     bsr    allocate_temp_space    GET BIG BLOCK
  3587.     tst.l    d0
  3588.     beq.s    end_set_func
  3589.     bsr    copy_func_defn_to_space
  3590.     move.l    a1,d4        D4=after end
  3591.     sub.l    a3,a1        WORK OUT HOW BIG IS ACTUALLY
  3592.     move.l    a1,d0
  3593.     moveq    #0,d1
  3594.     bsr    iwantmem        allocate block big enough for everything
  3595.     tst.l    d0
  3596.     beq.s    1$
  3597.     move.l    d0,a2
  3598.     move.l    a1,set_size(a2)
  3599.     bsr    insert_new_set
  3600.     lea    set_name(a2),a1    new block
  3601.     lea    set_name(a3),a0    temp block
  3602. 2$    move.b    (a0)+,(a1)+
  3603.     cmp.l    a0,d4
  3604.     bne.s    2$
  3605. 1$    move.l    a3,a1
  3606.     move.l    #temp_set_size,d0
  3607.     bsr    givemem
  3608. end_set_func
  3609.     moveq    #RETURN_OK,d0
  3610.     rts
  3611.     
  3612.  
  3613. check_if_set_already_there
  3614. * A0= set name
  3615.     movem.l    a0-a1,-(sp)
  3616.     lea    set_search_string(a5),a1
  3617.     bsr    cp_string
  3618.     bsr    search_sets
  3619.     movem.l    (sp)+,a0-a1
  3620.     rts
  3621.  
  3622. update_old_set
  3623. * first delete old one
  3624.     movem.l    a0-a1,-(sp)
  3625.     move.l    d0,a1
  3626.     move.l    (a1),d2    GRAB NEXT SET POINTER
  3627.     move.l    set_size(a1),d0
  3628.     move.l    d1,a0    D1=prior set
  3629.     move.l    d2,(a0)    SKIP OVER SET TO DELETE
  3630.     bsr    givemem
  3631.     movem.l    (sp)+,a0-a1
  3632. * and replace with new set
  3633.     bra    create_new_set
  3634.  
  3635. temp_set_size    equ    SHELLINE_SIZE+$60
  3636.  
  3637. allocate_temp_space
  3638.     move.l    #temp_set_size,d0
  3639.     moveq    #0,d1
  3640.     bra    iwantmem
  3641.     
  3642.  
  3643. deallocate_sets
  3644.     move.l    first_set_defn(a5),d3
  3645.     beq    no_sets_to_lose
  3646. lose_next_set
  3647.     move.l    d3,a1
  3648.     move.l    (a1),-(sp)
  3649.     move.l    set_size(a1),d0
  3650.     bsr    givemem
  3651.     move.l    (sp)+,d3
  3652.     bne    lose_next_set
  3653. no_sets_to_lose
  3654.     rts
  3655.  
  3656. insert_new_set
  3657.     move.l    a3,-(sp)
  3658.     move.l    d0,a3            A3=new space
  3659.     move.l    first_set_defn(a5),d1
  3660.     move.l    d1,(a3)            new pts to old
  3661.     move.l    a3,first_set_defn(a5)
  3662.     move.l    (sp)+,a3
  3663.     rts
  3664.  
  3665. set_size        equ    4
  3666. set_name        equ    8
  3667. set_defn        equ    24
  3668.  
  3669. ** ENTRY D0=space, A0=name, A1=defn
  3670. ** EXIT A1=after zero in dest, A3=space
  3671. copy_func_defn_to_space
  3672.     move.l    d0,a3
  3673.     move.l    a1,-(sp)
  3674.     lea    set_name(a3),a1
  3675.     bsr    cp_string        COPY SET NAME TO SPACE
  3676.     move.l    (sp)+,a0
  3677.     lea    set_defn(a3),a1
  3678.     bra    cp_string_special    COPY SET DEFN TO SPACE
  3679.  
  3680. * THIS STRING COPY COPYS A0->A1 BUT CONVERTS ALL \n to n
  3681. * RETURN A0 = after zero in src, A1 = after zero in dest
  3682. cp_string_special
  3683.     move.l    d0,-(sp)
  3684.     bra.s    2$
  3685. 1$    cmp.b    #'\',d0
  3686.     beq.s    2$
  3687.     move.b    d0,(a1)+
  3688. 2$    move.b    (a0)+,d0
  3689.     bne.s    1$
  3690.     move.b    d0,(a1)+
  3691.     move.l    (sp)+,d0
  3692.     rts
  3693.     
  3694.     
  3695. show_current_sets
  3696.     move.l    first_set_defn(a5),d0
  3697.     beq    no_sets_to_show
  3698. show_next_set
  3699.     move.l    d0,a3
  3700.     lea    set_name(a3),a1
  3701.     bsr    pr_string
  3702.     bsr    pr_tab
  3703.     lea    set_defn(a3),a1
  3704.     bsr    pr_string
  3705.     bsr    pr_lf
  3706.     move.l    (a3),d0        CHECK NEXT SET ADDRESS
  3707.     bne    show_next_set
  3708. no_sets_to_show
  3709.     moveq    #RETURN_OK,d0
  3710.     rts
  3711.  
  3712. *****************************************
  3713. *    RESIDENT COMMAND        *
  3714. *****************************************
  3715. residentz    move.l    parm2(a5),d0    SEE IF ANY PARAMETERS TYPED
  3716.     beq    show_current_residents
  3717.     lea    parm2(a5),a3
  3718. next_resi    move.l    (a3)+,d0
  3719.     beq    resi_no_more
  3720.     move.l    d0,a4        A4=parmN
  3721.     
  3722. make_resi    bsr    spaths2    SEARCH PATHS FOR THE COMMAND!
  3723.     tst.l    d0
  3724.     beq    resi_not_found
  3725.     move.l    d0,-(sp)    push seglist
  3726.     move.l    a4,a0
  3727.     move.l    a4,a1
  3728.     bsr    rempath    SRC = DEST is OK
  3729.     bsr    search_res2    find if same name is on resi list
  3730.     move.l    (sp)+,d3
  3731.     tst.l    d0
  3732.     beq    create_new_resident
  3733.     move.l    d0,d1
  3734.     move.l    d3,resi_seglist(a0)    new seglist
  3735.     jsr    _LVOUnLoadSeg(a6)    Unload old one with same name
  3736.     bra.s    next_resi
  3737.  
  3738. create_new_resident    
  3739.     bsr    allocate_resi_space
  3740.     tst.l    d0        D0=addr of resi_list_node
  3741.     beq    resi_no_mem
  3742.     bsr    insert_new_resi
  3743.     bra.s    next_resi
  3744. resi_no_more
  3745.     moveq    #RETURN_OK,d0
  3746.     rts
  3747. resi_not_found
  3748.     lea    resi_not_found_tx(pc),a1
  3749.     bsr    pr_string
  3750. resi_error
  3751.     moveq    #RETURN_ERROR,d0
  3752.     rts
  3753.     
  3754. resi_no_mem
  3755.     lea    resi_no_mem_tx(pc),a1
  3756.     bsr    pr_string
  3757.     bra    resi_error
  3758.  
  3759. insert_new_resi
  3760.     move.l    d0,a1
  3761.     move.l    resi_head(a5),d1
  3762.     move.l    d1,(a1)            new pts to old
  3763.     move.l    a1,resi_head(a5)
  3764.     move.l    d3,resi_seglist(a1)
  3765.     lea    resi_name(a1),a1
  3766.     move.l    a4,a0
  3767.     bsr    cp_string
  3768.     rts
  3769.  
  3770.  
  3771.     
  3772. deallocate_residents
  3773.     move.l    resi_head(a5),d3
  3774.     beq    no_resis_to_lose
  3775. 1$    move.l    d3,a1
  3776.     move.l    (a1),-(sp)
  3777.     move.l    resi_seglist(a1),d4        get seglist
  3778.     move.l    #resi_list_length,d0
  3779.     bsr    givemem
  3780.     move.l    d4,d1
  3781.     jsr    _LVOUnLoadSeg(a6)
  3782.     move.l    (sp)+,d3
  3783.     bne    1$
  3784. no_resis_to_lose
  3785.     rts
  3786.  
  3787. show_current_residents
  3788.     move.l    resi_head(a5),d0
  3789.     beq    no_resis_to_show
  3790. 1$    move.l    d0,a3
  3791.     lea    resi_name(a3),a1
  3792.     bsr    showittab
  3793.     move.l    (a3),d0        CHECK NEXT SET ADDRESS
  3794.     bne    1$
  3795.     bsr    pr_lf
  3796. no_resis_to_show
  3797.     moveq    #RETURN_OK,d0
  3798.     rts
  3799.     
  3800.  
  3801.  
  3802. resi_list_length    equ    4+4+32
  3803. resi_link        equ    0
  3804. resi_seglist    equ    4
  3805. resi_name        equ    8
  3806.  
  3807. allocate_resi_space
  3808.     move.l    #resi_list_length,d0
  3809.     moveq    #0,d1
  3810.     bra    iwantmem
  3811.     
  3812.     
  3813. *****************************************
  3814. *    SET PROTECTION COMMAND    *
  3815. *****************************************
  3816. setprotz    bsr    fixpam32
  3817.     tst.b    (a1)
  3818.     beq    check_existing_protection
  3819.     bsr    get_protection_bits
  3820.     bsr    alter_protection_bits
  3821.     moveq    #RETURN_OK,d0
  3822.     rts
  3823.  
  3824. alter_protection_bits
  3825. * A1-> rwed etc.   A2-> prot table  A0-> filename  D3=old prot bits.
  3826.     lea    prot_bits_table(pc),a2
  3827.     tst.b    (a1)
  3828.     beq    set_the_protection
  3829. apb_loop    move.b    (a2)+,d1    get letter from table
  3830.     bne.s    1$
  3831.     lea    bad_prot_bits_tx(pc),a1
  3832.     bsr    pr_string
  3833.     moveq    #RETURN_ERROR,D0
  3834.     RTS
  3835. 1$    move.b    (a2)+,d2    get code from table
  3836.     move.b    (a1),d0
  3837.     bsr    compD1D0nocase
  3838.     bne.s    apb_loop
  3839.     eor.b    d2,d3
  3840.     move.b    (a1)+,d1    dummy,bump ptr
  3841.     bra    alter_protection_bits
  3842. set_the_protection
  3843.     move.l    d3,d2
  3844.     move.l    a0,d1
  3845.     jmp    _LVOSetProtection(a6)
  3846.  
  3847.     
  3848. check_existing_protection
  3849.     bsr    get_protection_bits
  3850.     bsr    translate_prot_bits
  3851.     moveq    #RETURN_OK,d0
  3852.     rts
  3853.  
  3854.     
  3855. get_protection_bits
  3856.     movem.l    a0-a1,-(sp)
  3857.     bsr    fibexam
  3858.     move.l    fib_Protection(a5),d3
  3859.     bsr    unlock
  3860.     movem.l    (sp)+,a0-a1
  3861.     rts
  3862.     
  3863. translate_prot_bits
  3864.     lea    prot_bits_table(pc),a2
  3865.     lea    tempbuf(a5),a3
  3866.     eor.b    #$0F,d3
  3867. check_next_bit
  3868.     move.b    (a2)+,d0    get letter
  3869.     beq    exhausted_bits
  3870.     move.b    #'-',(a3)+
  3871.     move.l    d3,d2    get protection bits
  3872.     and.b    (a2)+,d2
  3873.     beq    check_next_bit
  3874.     move.b    d0,-1(a3)
  3875.     bra    check_next_bit
  3876. exhausted_bits
  3877.     move.b    #10,(a3)+
  3878.     clr.b    (a3)
  3879. *    bsr    pr_tab
  3880.     lea    fib_FileName(a5),a1
  3881.     bsr    pr_string
  3882.     bsr    pr_tab
  3883.     lea    tempbuf(a5),a1
  3884.     bra    pr_string
  3885.     
  3886.     
  3887. prot_bits_table
  3888.     dc.b    'h',$80
  3889.     dc.b    's',$40
  3890.     dc.b    'p',$20
  3891.     dc.b    'a',$10
  3892.     dc.b    'r',$08
  3893.     dc.b    'w',$04
  3894.     dc.b    'e',$02
  3895.     dc.b    'd',$01
  3896.     dc.w    0
  3897.  
  3898. *****************************************
  3899. *    RPN CALCULATOR COMMAND    *
  3900. *****************************************
  3901. rpnz    lea    parm2(a5),a4
  3902.     move.l    a7,d5        remember the stack ptr
  3903. rpn_loop1    move.l    (a4)+,d1
  3904.     beq    show_rpn_result
  3905.     lea    endofparms(a5),a1
  3906.     cmp.l    a1,a4
  3907.     bhi    show_rpn_result
  3908.     move.l    d1,a1
  3909.     lea    8(sp),a0
  3910.     cmp.l    a0,d5
  3911.     blo    not_poke32
  3912.  
  3913.     cmp.b    #'+',(a1)        
  3914.     bne.s    not_add        
  3915.     move.l    (sp)+,d0        DO ADD
  3916.     add.l    d0,(sp)
  3917.     bra    rpn_loop1
  3918. not_add    cmp.b    #'-',(a1)
  3919.     bne.s    not_sub
  3920.     move.l    (sp)+,d0
  3921.     sub.l    d0,(sp)
  3922.     bra    rpn_loop1
  3923.     
  3924. not_sub    cmp.b    #'*',(a1)
  3925.     bne.s    not_mult
  3926.     move.l    (sp)+,d0    last    DO MULT
  3927.     move.l    (sp)+,d1    2nd last
  3928.     bsr    mult_32x32
  3929.     move.l    d0,-(sp)
  3930.     bra    rpn_loop1
  3931. not_mult    cmp.b    #'/',(a1)
  3932.     bne.s    not_div
  3933.     move.l    (sp)+,d1    last    DO DIVIDE
  3934.     move.l    (sp)+,d0    2nd last
  3935.     tst.l    d1
  3936.     beq    rpn_error        NO DIVIDE BY ZERO
  3937.     bsr    div_32
  3938.     move.l    d0,-(sp)
  3939.     bra    rpn_loop1
  3940. not_div    cmp.b    #'&',(a1)
  3941.     bne.s    not_and
  3942.     move.l    (sp)+,d0
  3943.     and.l    d0,(sp)
  3944.     bra    rpn_loop1
  3945. not_and    cmp.b    #'|',(a1)
  3946.     bne.s    not_or
  3947.     move.l    (sp)+,d0
  3948.     or.l    d0,(sp)
  3949.     bra    rpn_loop1
  3950. not_or    cmp.b    #'!',(a1)
  3951.     bne.s    not_poke32
  3952.     move.l    (sp)+,d0    GET ADDR        DO POKE 32
  3953.     move.l    (sp)+,d1    GET VALUE
  3954.     and.b    #$fe,d0
  3955.     move.l    d0,a0
  3956.     move.l    d1,(a0)
  3957.     bra    rpn_loop1
  3958. not_poke32
  3959.     cmp.b    #'@',(a1)
  3960.     bne.s    not_peek32
  3961.     move.l    (sp)+,d0    ADDR    DO PEEK 32
  3962.     cmp.l    a7,d5
  3963.     blo    rpn_error
  3964.     and.b    #$fe,d0
  3965.     move.l    d0,a0
  3966.     move.l    (a0),-(sp)
  3967.     bra    rpn_loop1
  3968.  
  3969. not_peek32
  3970.     bsr    convert_ASCII_to_num
  3971.     tst.b    d1
  3972.     beq    rpn_error
  3973.     move.l    d0,-(sp)
  3974.     bra    rpn_loop1
  3975. rpn_error    move.l    d5,a7
  3976.     rts
  3977.  
  3978. show_rpn_result
  3979.     move.l    (sp),-(sp)
  3980.     lea    (a7),a1
  3981.     lea    rpn_result_tx(pc),a0
  3982.     bsr    new_print
  3983.     move.l    d5,a7
  3984.     moveq    #RETURN_OK,d0
  3985.     rts
  3986.  
  3987. div_32    movem.l    d2-d4,-(sp)
  3988.     moveq    #0,d2
  3989.     moveq    #31,d4
  3990. _divu1    roxl.l    #1,d0    ; divident
  3991.     roxl.l    #1,d2    ; work accum
  3992.     cmp.l    d1,d2    ; cmp with divisor
  3993.     blo.s    _divu2
  3994.     sub.l    d1,d2
  3995.     ori    #16,ccr    ;setx
  3996. _divu2    roxl.l    #1,d3    ; result
  3997.     dbf    d4,_divu1
  3998.     move.l    d3,d0
  3999.     move.l    d2,d1
  4000.     movem.l    (sp)+,d2-d4
  4001.     rts
  4002.  
  4003.  
  4004. mult_32x32
  4005. * D1 = 32 bit, D0 = 32 bit (result)
  4006.     movem.l    d1-d3,-(sp)
  4007.     move.l    d0,d2
  4008.     move.l    d0,d3
  4009.     mulu    d1,d0    save intermediate result
  4010.     swap    d3
  4011.     mulu    d1,d3
  4012.     swap    d3
  4013.     clr.w    d3
  4014.     add.l    d3,d0
  4015.     swap    d1
  4016.     mulu    d1,d2
  4017.     swap    d2
  4018.     clr.w    d2
  4019.     add.l    d2,d0
  4020.     movem.l    (sp)+,d1-d3
  4021.     rts
  4022.     
  4023. * Convert null ending ASCII number(A1) to 32bit number in D0
  4024. * REturn D1=0 if bad number
  4025. convert_ASCII_to_num
  4026.     moveq    #0,d0    RESET RESULT
  4027.     moveq    #10,d1    SET THE BASE
  4028.     cmp.b    #'$',(a1)
  4029.     bne.s    other_base
  4030.     move.b    (a1)+,d2    DUMMY BUMP
  4031.     moveq    #16,d1    SET RADIX16
  4032.     bra    same_base
  4033.  
  4034. other_base
  4035.     cmp.b    #'%',(a1)
  4036.     bne.s    same_base
  4037.     move.b    (a1)+,d2
  4038.     moveq    #2,d1    SET RADIX2
  4039. same_base    moveq    #0,d2
  4040.     move.b    (a1)+,d2
  4041.     beq    conversion_finished
  4042.     bsr    convert_D2_to_num
  4043.     bsr    mult_32x32
  4044.     add.l    d2,d0
  4045.     bra    same_base
  4046. conversion_finished
  4047.     rts
  4048.     
  4049. convert_D2_to_num
  4050.     cmp.b    #'0',d2
  4051.     blo.s    bad_number
  4052.     cmp.b    #'9',d2
  4053.     bhi.s    check_hex
  4054.     sub.b    #'0',d2
  4055.     rts
  4056. check_hex    cmp.b    #16,d1
  4057.     bne.s    bad_number
  4058.     cmp.b    #'f',d2
  4059.     bhi.s    bad_number
  4060.     cmp.b    #'A',d2
  4061.     blo.s    bad_number
  4062.     cmp.b    #'F',d2
  4063.     bhi.s    check_upper_hex
  4064.     sub.b    #55,d2
  4065.     rts
  4066. check_upper_hex
  4067.     cmp.b    #'a',d2
  4068.     blo.s    bad_number
  4069.     sub.b    #87,d2
  4070.     rts
  4071. bad_number
  4072.     moveq    #0,d1    FLAG ERROR thru silly base
  4073.     rts
  4074.  
  4075.  
  4076. *****************************************
  4077. *    MEMORY EXAMINE COMMAND    *
  4078. *****************************************
  4079. memexamz    clr.l    mem_offset_addr(a5)
  4080.     moveq    #0,d7
  4081.     tst.l    parm2(a5)        CHECK IF NO ADDRESS.
  4082.     bne.s    5$
  4083.     moveq    #20,d7
  4084.     bra    show_mempage
  4085. 5$    bsr    fixpam32
  4086.     tst.b    (a1)
  4087.     beq.s    1$
  4088.     move.l    a0,-(sp)
  4089.     bsr    convert_ASCII_to_num    convert 2nd num
  4090.     move.l    (sp)+,a0
  4091.     tst.b    d1
  4092.     beq    bad_number_error
  4093.     move.l    d0,d7            D7=2nd num
  4094. 1$    move.l    a0,a1
  4095.     bsr    convert_ASCII_to_num    convert 1st num
  4096.     tst.b    d1
  4097.     beq    bad_number_error
  4098. 3$    tst.l    d7
  4099.     bne.s    4$
  4100.     moveq    #20,d7
  4101.     bra.s    memex2
  4102. 4$    sub.l    d0,d7
  4103.     lsr.l    #4,d7
  4104.     addq.l    #1,d7
  4105.  
  4106. memex2    move.l    d0,mem_addr(a5)
  4107. show_mempage
  4108.     and.b    #$fe,mem_addr+3(a5)    MAKE SURE EVEN ADDRESS
  4109. *    moveq    #19,d7        D7=count
  4110. shmem2    bsr    check_c
  4111.     bne    1$
  4112.     bsr    show_16_locs
  4113.     subq.l    #1,d7
  4114.     bne.s    shmem2
  4115. 1$    moveq    #RETURN_OK,d0
  4116.     rts
  4117.     
  4118. show_16_locs
  4119.     move.l    mem_addr(a5),a1
  4120.     lea    CLIbuf(a5),a3
  4121.     move.l    a3,a0
  4122.     moveq    #15,d0
  4123. sh_16_1    move.b    (a1)+,d1
  4124.     move.b    #'.',(a0)+
  4125.     move.b    d1,d2
  4126.     bclr    #7,d2
  4127.     cmp.b    #' ',d2
  4128.     blo.s    sh_16_2
  4129.     move.b    d1,-1(a0)
  4130. sh_16_2    dbra    d0,sh_16_1
  4131.     clr.b    (a0)
  4132.     move.l    a3,-(sp)        PUSH STRING ADDR
  4133.     move.l    -(a1),-(sp)    PUSH LAST BYTES
  4134.     move.l    -(a1),-(sp)
  4135.     move.l    -(a1),-(sp)
  4136.     move.l    -(a1),-(sp)    PUSH FIRST BYTES
  4137.     move.l    mem_addr(a5),d0
  4138.     sub.l    mem_offset_addr(a5),d0
  4139.     move.l    d0,-(sp)
  4140.     lea    mem_line(pc),a0
  4141.     lea    (sp),a1
  4142.     bsr    new_print
  4143.     movem.l    (sp)+,d0-d5    DUMMY
  4144.     add.l    #16,mem_addr(a5)
  4145.     rts
  4146.  
  4147. * ENTRY A0=FORMATSTRING A1=DATASTREAM.
  4148. new_print
  4149.     movem.l    d0-d7/a0-a6,-(sp)
  4150.     lea    -200(sp),sp
  4151.     move.l    sp,a3
  4152.     lea    KPutChar(pc),a2
  4153.     clr.l    char_count
  4154.     move.l    _AbsExecBase,a6
  4155.     jsr    _LVORawDoFmt(a6)
  4156.     move.l    dosbase(a5),a6
  4157.     move.l    outhandle(a5),d1
  4158.     lea    (sp),a0
  4159.     move.l    a0,d2
  4160.     move.l    char_count,d3
  4161.     subq.l    #1,d3
  4162.     jsr    _LVOWrite(a6)
  4163.     lea    200(sp),sp
  4164.     movem.l    (sp)+,d0-d7/a0-a6
  4165.     rts
  4166.  
  4167. KPutChar    move.b    d0,(a3)+
  4168.     addq.l    #1,char_count
  4169.     rts
  4170.  
  4171. resetz    move.l    (4).w,a6
  4172.     clr.l    $0026(A6)
  4173.     move.l    #$00FC00D2,$0080
  4174.     trap    #$00
  4175.  
  4176. eb_CoolCapture    equ    46
  4177. eb_ColdCapture    equ    42
  4178. eb_WarmCapture    equ    50
  4179. eb_KickMemPtr    equ    546
  4180. eb_KickTagPtr    equ    550
  4181. eb_KickCheckSum    equ    554
  4182.  
  4183. vecz    move.l    _AbsExecBase,a0
  4184.     move.l    eb_KickCheckSum(a0),-(sp)
  4185.     move.l    eb_KickMemPtr(a0),-(sp)
  4186.     move.l    eb_KickTagPtr(a0),-(sp)
  4187.     move.l    eb_ColdCapture(a0),-(sp)
  4188.     move.l    eb_CoolCapture(a0),-(sp)
  4189.     move.l    eb_WarmCapture(a0),-(sp)
  4190.     lea    (a7),a1
  4191.     lea    vec_line(pc),a0
  4192.     bsr    new_print
  4193.     movem.l    (sp)+,d0-d5    get rid of trash
  4194.     moveq    #RETURN_OK,d0
  4195.     rts
  4196.  
  4197. ** SAVE STATS store current time in date mark, and current memory use in mem mark
  4198. save_time
  4199.     movem.l    a0/d0-d1,-(sp)
  4200.     lea    date_mark(a5),a0
  4201.     bsr    get_time
  4202.     movem.l    (sp)+,a0/d0-d1
  4203.     rts
  4204. save_mem    movem.l    a0/d0-d1,-(sp)
  4205.     lea    mem_mark(a5),a0
  4206.     bsr    memory_info    
  4207.     movem.l    (sp)+,a0/d0-d1
  4208.     rts
  4209.  
  4210. ** DISPLAY TIME ELAPSED SINCE LAST CALL TO SAVE TIME AND
  4211. **  ALSO CHANGE IN MEMORY AVAILABLE. EXPECTS RETURN CODE TO BE ABOVE RETURN
  4212. **  ADDRESS ON STACK ie 4(sp)
  4213. show_status
  4214.     move.l    4(sp),d0
  4215.     lea    -28(sp),sp
  4216.     lea    (a7),a0        A0=time area
  4217.     move.l    d0,(a0)+
  4218.     bsr    get_time
  4219.     lea    date_mark(a5),a1
  4220.     move.l    ds_Tick(a0),d0
  4221.     sub.l    ds_Tick(a1),d0
  4222.     bpl.s    no_tick_carry
  4223.     add.l    #3000,d0
  4224.     subq.l    #1,ds_Minute(a0)
  4225. no_tick_carry
  4226.     move.l    d0,ds_Tick(a1)    store in datemark
  4227.     move.l    ds_Minute(a0),d0
  4228.     sub.l    ds_Minute(a1),d0
  4229.     move.l    d0,ds_Minute(a1)
  4230.     bsr    convert_time    A0=4 words of time
  4231. do_mem_deltas
  4232.     lea    8(a0),a0
  4233.     bsr    memory_info
  4234.     lea    mem_mark(a5),a1
  4235.     move.l    (a1),d0
  4236.     sub.l    d0,(a0)    subtract old from new
  4237.     move.l    4(a1),d0
  4238.     sub.l    d0,4(a0)
  4239.     move.l    8(a1),d0
  4240.     sub.l    d0,8(a0)
  4241.     lea    -12(a0),a1
  4242.     lea    stat_text(pc),a0
  4243.     bsr    new_print
  4244.     
  4245.     lea    28(sp),sp
  4246.     rts
  4247.     
  4248. * TIME command
  4249. timez    lea    date_mark(a5),a2
  4250.     move.l    a2,a0
  4251.     bsr    get_time
  4252.     move.l    a2,a1
  4253.     lea    -8(sp),sp
  4254.     lea    (a7),a0
  4255.     bsr    convert_time
  4256.     lea    (a7),a1
  4257.     lea    time_text(pc),a0
  4258.     bsr    new_print
  4259.     lea    8(sp),sp
  4260.     moveq    #RETURN_OK,d0
  4261.     rts
  4262.  
  4263. ** GET TIME STORE DAYS,MINUTES,TICKS AT A0
  4264. get_time    move.l    a0,-(sp)
  4265.     move.l    a0,d1
  4266.     jsr    _LVODateStamp(a6)
  4267.     move.l    (sp)+,a0
  4268.     rts
  4269.  
  4270. ** ENTRY A0 pts to 4 words of storage, A1 pts to date stamp
  4271. ** send time to A0 --> 7(A0)
  4272. convert_time
  4273.     move.l    ds_Tick(a1),d0
  4274.     divu    #50,d0
  4275.     move.w    d0,4(a0)        seconds
  4276.     swap    d0
  4277.     asl.w    #1,d0
  4278.     move.w    d0,6(a0)        hundredths
  4279.     move.l    ds_Minute(a1),d0
  4280.     divu    #60,d0
  4281.     move.w    d0,(a0)        hours
  4282.     swap    d0    
  4283.     move.w    d0,2(a0)        minutes
  4284.     rts
  4285.  
  4286. ** STATUS COMMAND ALLOWS DIS/ENABLING OF STATUS DISPLAY
  4287. statusz    tst.l    parm2(a5)
  4288.     beq.s    help_status
  4289.     move.l    parm2(a5),a0
  4290.     clr.b    stat_mode_flag(a5)    =00
  4291.     bsr    return_dash_option
  4292.     cmp.b    #'Y',d0
  4293.     bne.s    say_OK
  4294. stat_yes    not.b    stat_mode_flag(a5)    =FF
  4295. say_OK    lea    OK_text(pc),a0
  4296.     bsr    new_print
  4297.     moveq    #RETURN_OK,d0
  4298.     rts
  4299. help_status
  4300.     lea    status_help_text(pc),a0
  4301.     bsr    new_print
  4302.     moveq    #RETURN_OK,d0
  4303.     rts
  4304.  
  4305. ** STACK COMMAND
  4306. stackz    move.l    thistask(a5),a0
  4307.     move.l    pr_CLI(a0),a4
  4308.     add.l    a4,a4
  4309.     add.l    a4,a4        A4=cli ptr
  4310.  
  4311.     move.l    cli_DefaultStack(a4),d7
  4312.     asl.l    #2,d7
  4313.     tst.l    parm2(a5)
  4314.     beq.s    show_stack
  4315.     move.l    parm2(a5),a1
  4316.     bsr    convert_ASCII_to_num
  4317.     tst.b    d1
  4318.     beq    bad_number_error
  4319. stk_num_OK
  4320.     move.l    d0,d6
  4321.     cmpi.l    #1600,d6  
  4322.     blt.s    stoosmall
  4323.     move.l    d6,d0
  4324.     moveq    #1,d1   
  4325.     bsr    iwantmem 
  4326.     tst.l    d0
  4327.     beq.s    stoobig   
  4328.     move.l    d0,a1   
  4329.     move.l    d6,d0   
  4330.     bsr    givemem  
  4331.     
  4332.     asr.l    #2,d6
  4333.     move.l    d6,cli_DefaultStack(a4)
  4334.     moveq    #RETURN_OK,d0
  4335.     rts
  4336. stoosmall    lea    stk_too_small_tx(pc),a0
  4337.     moveq    #RETURN_ERROR,d0
  4338.     bra    new_print
  4339. stoobig    lea    stk_too_big_tx(pc),a0
  4340.     moveq    #RETURN_ERROR,d0
  4341.     bra    new_print
  4342. show_stack
  4343.     move.l    d7,-(a7)
  4344.     lea    (a7),a1
  4345.     lea    stk_size_tx(pc),a0
  4346.     bsr    new_print
  4347.     move.l    (a7)+,d0
  4348.     moveq    #RETURN_OK,d0
  4349.     rts
  4350.  
  4351. ** CHECK STRING A0 IF ENDING IN :
  4352. ** RETURN EQ IF DOES END IN COLON
  4353. check_for_colon
  4354. 1$    tst.b    (a0)+    MAKE SURE ENDS IN :
  4355.     bne.s    1$
  4356.     move.b    -2(a0),d0
  4357.     cmp.b    #':',d0
  4358.     rts
  4359.  
  4360. do_forbid    move.l    _AbsExecBase,a6
  4361.     jsr    _LVOForbid(a6)
  4362.     move.l    dosbase(a5),a6
  4363.     rts
  4364. do_permit    move.l    _AbsExecBase,a6
  4365.     jsr    _LVOPermit(a6)
  4366.     move.l    dosbase(a5),a6
  4367.     rts
  4368.     
  4369. *******************************
  4370. *    ASSIGN COMMAND    *
  4371. *******************************
  4372. dl_Root        equ    34    APTR
  4373. rn_Info        equ    24    BPTR
  4374. di_DevInfo    equ    4    BPTR
  4375. dvi_Next        equ    0    BPTR
  4376. dvi_Type        equ    4    LONG
  4377. dvi_Task        equ    8    APTR
  4378. dvi_Lock        equ    12    BPTR
  4379. dvi_Handler    equ    16
  4380. dvi_StackSize    equ    20
  4381. dvi_Priority    equ    24
  4382. dvi_Startup    equ    28
  4383. dvi_SegList    equ    32
  4384. dvi_GlobVec    equ    36
  4385.     
  4386. dvi_Name        equ    40    BSTR
  4387. dt_device        equ    0    <-- contents of dvi_Type
  4388. dt_dir        equ    1
  4389. dt_volume        equ    2
  4390. fl_Volume        equ    16
  4391. fl_Task        equ    12
  4392. fl_Key        equ    4
  4393.     
  4394. *pr_StackSize    equ    132
  4395. pr_SegList    equ    128
  4396. pr_GlobVec    equ    136
  4397.  
  4398. assignz    bsr    do_forbid        FORBID
  4399.     bsr    get_first_devinfo
  4400.     tst.l    parm2(a5)
  4401.     beq    show_assigns
  4402.     tst.l    parm3(a5)
  4403.     beq    exit_assignf    ONLY TWO PARMS TYPED (NEED 3)
  4404.     move.l    parm2(a5),a0
  4405.     bsr    check_for_colon
  4406.     beq    2$
  4407.     bsr    do_permit
  4408.     lea    no_colon_tx(pc),a1
  4409.     bsr    pr_string
  4410.     moveq    #RETURN_ERROR,d0
  4411.     rts
  4412.     
  4413. 2$    moveq    #dt_dir,d1    CREATE/MODIFY ASSIGN ******
  4414.     bsr    find_next_assign
  4415.     tst.l    d0
  4416.     bne    no_more_dir_assigns
  4417.     move.l    a0,d5
  4418.     move.l    parm2(a5),a0    A0=assigned name[0]
  4419.     moveq    #0,d2
  4420.     move.b    (a1)+,d2        get char count
  4421. 1$    move.b    (a1)+,d0
  4422.     move.b    (a0)+,d1
  4423.     beq.s    2$
  4424.     subq.l    #1,d2
  4425.     bmi.s    3$
  4426.     bsr    compD1D0nocase
  4427.     beq.s    1$
  4428. 4$    bra.s    2$
  4429.  
  4430. 3$    cmp.b    #':',d1    CHANGE EXISTING
  4431.     bne.s    4$
  4432.     bsr    do_permit        PERMIT
  4433.     move.l    d5,a2        GOT A MATCH
  4434.     moveq    #ACCESS_READ,d2
  4435.     move.l    parm3(a5),d1
  4436.     jsr    _LVOLock(a6)
  4437.     tst.l    d0
  4438.     beq    exit_assignp
  4439.     move.l    d0,a3
  4440.     bsr    do_forbid        FORBID
  4441.     move.l    dvi_Lock(a2),d4
  4442.     move.l    a3,dvi_Lock(a2)    new lock
  4443.     add.l    a3,a3
  4444.     add.l    a3,a3
  4445.     move.l    fl_Task(a3),dvi_Task(a2)
  4446.     clr.l    dvi_Handler(a2)
  4447.     clr.l    dvi_StackSize(a2)
  4448.     clr.l    dvi_Priority(a2)
  4449.     clr.l    dvi_Startup(a2)
  4450.     clr.l    dvi_SegList(a2)
  4451.     clr.l    dvi_GlobVec(a2)
  4452.     bsr    do_permit
  4453.     move.l    d4,d1
  4454.     jsr    _LVOUnLock(a6)
  4455.     bra    exit_assignp
  4456.     
  4457. no_more_dir_assigns
  4458.     bsr    do_permit        CREATE NEW ASSIGN
  4459.     moveq    #48,d0
  4460.     move.l    #MEMF_CLEAR,d1
  4461.     bsr    iwantmem
  4462.     tst.l    d0
  4463.     beq    exit_assignp
  4464.     move.l    d0,a4
  4465.     move.l    #48,(a4)+        save size byte
  4466.     move.l    parm2(a5),a0
  4467.     moveq    #3,d0    4 extra bytes for dos(nb: : is ignored)
  4468. 1$    addq.l    #1,d0
  4469.     tst.b    (a0)+
  4470.     bne.s    1$
  4471.     move.l    d0,d3    D3=size+5    (block size|char_count|chars)
  4472.     moveq    #0,d1
  4473.     bsr    iwantmem
  4474.     tst.l    d0
  4475.     beq    rem_dvi
  4476.     move.l    d0,a3
  4477.     move.l    d0,d4        D4=string ptr
  4478.     move.l    d3,(a3)+        save size byte
  4479.     subq.l    #5,d3
  4480.     move.b    d3,(a3)+        save char_count
  4481.     move.l    parm2(a5),a0
  4482.     bra.s    3$
  4483. 2$    move.b    d1,(a3)+        copy string to NAME
  4484. 3$    move.b    (a0)+,d1
  4485.     cmp.b    #':',d1
  4486.     bne.s    2$
  4487.     addq.l    #4,d0
  4488.     lsr.l    #2,d0    convert to bstr
  4489.     move.l    d0,dvi_Name(a4)
  4490.     move.l    #dt_dir,dvi_Type(a4)
  4491.     moveq    #ACCESS_READ,d2
  4492.     move.l    parm3(a5),d1
  4493.     jsr    _LVOLock(a6)
  4494.     tst.l    d0
  4495.     beq    rem_str
  4496.     move.l    d0,dvi_Lock(a4)
  4497.     asl.l    #2,d0        x 4
  4498.     move.l    d0,a0
  4499.     move.l    fl_Task(a0),dvi_Task(a4)
  4500.     bsr    do_forbid
  4501.     bsr    get_first_devinfo    RETURNS A1 pts info substr, A2 pts 1st devinfo
  4502.     move.l    a2,dvi_Next(a4)
  4503.     move.l    a4,d0
  4504.     lsr.l    #2,d0
  4505.     move.l    d0,di_DevInfo(a1)    Insert new top of chain
  4506.     bsr    do_permit
  4507.     
  4508.     bra.s    exit_assignp
  4509. rem_str    move.l    d4,a1
  4510.     move.l    (a1),d0
  4511.     bsr    givemem
  4512. rem_dvi    lea    -4(a4),a1
  4513.     moveq    #48,d0
  4514.     bsr    givemem
  4515. exit_assignp
  4516.     moveq    #RETURN_OK,d0
  4517.     rts
  4518. exit_assignf
  4519.     bsr    do_permit
  4520.     moveq    #RETURN_OK,d0
  4521.     rts
  4522.     
  4523. * SHOW ASSIGNS    ALREADY IN FORBID STATE
  4524. show_assigns
  4525.     lea    -8(sp),sp
  4526.     move.l    a2,(sp)        0(sp)= BPTR of first devinfo
  4527.     move.l    #1024,d0
  4528.     moveq    #0,d1
  4529.     bsr    iwantmem        allocate big block
  4530.     tst.l    d0
  4531.     beq    asg_fail
  4532.     move.l    d0,a4        A4 = string block
  4533.     move.l    d0,4(sp)        4(sp) = string block
  4534.     lea    volume_tx(pc),a0    PRINT VOLUMES:
  4535.     bsr    copy_name
  4536.     moveq    #dt_volume,d1
  4537. do_volumes
  4538. 5$    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  4539.     tst.l    d0         TO THE BIG STRING
  4540.     bne.s    do_devices
  4541.     bsr    copy_bstr
  4542.     move.b    #$20,(a4)+    seperate with spaces
  4543.     tst.l    dvi_Task(a0)
  4544.     beq.s    7$
  4545.     lea    mounted_tx(pc),a0
  4546.     bsr    copy_name
  4547. 7$    move.b    #$0a,(a4)+
  4548.     bra.s    5$
  4549. do_devices    
  4550.     move.l    (sp),a2        restart at first devinfo
  4551.     lea    device_tx(pc),a0    PRINT DEVICES:
  4552.     bsr    copy_name
  4553.     moveq    #dt_device,d1
  4554.     bsr    store_mult_entries
  4555.     move.l    (sp),a2
  4556. do_dirs
  4557.     lea    directory_tx(pc),a0    PRINT DIRECTORIES
  4558.     bsr    copy_name
  4559.     move.l    #-1,-(sp)        PUSH NEGATIVE ON STACK
  4560. 2$    moveq    #dt_dir,d1
  4561.     bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  4562.     tst.l    d0         TO THE BIG STRING
  4563.     bne.s    get_nxt_lock
  4564.     lea    -38(sp),sp    ALLOW 38 BYTES FOR STRING
  4565.     move.l    dvi_Lock(a0),-(sp)    push lock
  4566.     lea    4(sp),a0
  4567.     move.b    (a1)+,d0
  4568.     bra.s    8$
  4569. 7$    move.b    (a1)+,(a0)+    copy name onto stack
  4570. 8$    dbra    d0,7$
  4571.     clr.b    (a0)+
  4572.     bra.s    2$
  4573.  
  4574. get_nxt_lock
  4575.     move.l    (sp)+,d1        get lock
  4576.     bmi    1$
  4577.     lea    (sp),a0
  4578. 6$    move.b    (a0)+,(a4)+    copy name to store
  4579.     bne.s    6$
  4580.     lea    38(sp),sp
  4581.     move.b    #$9,-1(a4)
  4582.     tst.l    d1
  4583.     beq    3$        no lock
  4584.     move.l    d1,a0
  4585.     add.l    a0,a0
  4586.     add.l    a0,a0
  4587.     move.l    fl_Volume(a0),a0
  4588.     add.l    a0,a0
  4589.     add.l    a0,a0
  4590.     tst.l    dvi_Task(a0)
  4591.     bne.s    5$
  4592.     lea    unmounted_tx(pc),a0
  4593.     bsr    copy_name
  4594.     bra.s    get_nxt_lock
  4595. 5$    bsr    do_permit
  4596.     jsr    _LVODupLock(a6)    copy lock(D1) --> (D0)
  4597.     move.l    a4,a0
  4598.     bsr    eval_full_path
  4599.     jsr    _LVOUnLock(a6)
  4600.     bsr    do_forbid
  4601. 4$    tst.b    (a4)+
  4602.     bne.s    4$
  4603. 3$    move.b    #$0a,-1(a4)    overwrite null or tab
  4604.     bra.s    get_nxt_lock
  4605. 1$    move.b    #$0a,(a4)+    linefeed at end
  4606.  
  4607.     clr.b    (a4)+
  4608.     bsr    do_permit
  4609.     move.l    4(sp),a1
  4610.     bsr    pr_string
  4611.     move.l    4(sp),a1
  4612.     move.l    #1024,d0
  4613.     bsr    givemem
  4614.     bra.s    asg_fail2
  4615. asg_fail    bsr    do_permit
  4616. asg_fail2    lea    8(sp),sp
  4617.     moveq    #RETURN_OK,d0
  4618.     rts
  4619.  
  4620.  
  4621. store_mult_entries
  4622. 2$    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  4623.     tst.l    d0         TO THE BIG STRING
  4624.     bne.s    1$
  4625.     bsr    copy_bstr
  4626.     move.b    #$20,(a4)+    seperate with spaces
  4627.     move.b    #$20,(a4)+
  4628.     bra.s    2$
  4629. 1$    move.b    #$0a,(a4)+    linefeed at end
  4630.     rts
  4631.  
  4632. get_first_devinfo
  4633.     move.l    dl_Root(a6),a1
  4634.     move.l    rn_Info(a1),a1
  4635.     add.l    a1,a1
  4636.     add.l    a1,a1
  4637.     move.l    di_DevInfo(a1),a2    A2=BPTR to first devinfo
  4638.     rts
  4639.  
  4640. copy_name    move.b    (a0)+,(a4)+
  4641.     bne.s    copy_name
  4642.     lea    -1(a4),a4
  4643.     rts
  4644.  
  4645. **COPY BSTR FROM A1 TO A4, DONT NULL END
  4646. copy_bstr    move.b    (a1)+,d0
  4647.     bra.s    3$
  4648. 2$    move.b    (a1)+,(a4)+
  4649. 3$    dbra    d0,2$
  4650.     rts
  4651.     
  4652. **ENTRY: D1=type ,A2=Bptr of devinfo, EXIT: A2=Bptr to next ,D0=0 if found
  4653. **EXIT: D2=lock, D1=type, A1 pts to string, A0 pts devinfo struct
  4654. find_next_assign
  4655. 1$    add.l    a2,a2    FIND NEXT DEVINFO THAT MATCHES THE TYPE (D1)
  4656.     add.l    a2,a2        A2 pts to first devinfo structure
  4657.     move.l    a2,d0        tst.l    (a2)
  4658.     beq.s    2$
  4659.     move.l    a2,a0
  4660.     move.l    dvi_Name(a2),a1
  4661.     move.l    dvi_Lock(a2),d2
  4662.     move.l    dvi_Type(a2),d0
  4663.     move.l    (a2),a2
  4664.     cmp.l    d0,d1
  4665.     bne.s    1$
  4666.     add.l    a1,a1
  4667.     add.l    a1,a1
  4668.     moveq    #0,d0
  4669.     rts
  4670. 2$    moveq    #1,d0
  4671.     rts
  4672.  
  4673.  
  4674. bad_number_error
  4675.     move.l    a1,-(sp)
  4676.     lea    bad_number_tx(pc),a1
  4677.     bsr    pr_string
  4678.     move.l    (sp)+,a1
  4679.     moveq    #RETURN_ERROR,D0
  4680.     rts
  4681.  
  4682. *******************************
  4683. *    FAILAT COMMAND    *
  4684. *******************************
  4685. failatz    tst.l    parm2(a5)
  4686.     beq.s    show_failat
  4687.     move.l    parm2(a5),a1
  4688.     bsr    convert_ASCII_to_num
  4689.     tst.b    d1
  4690.     bne.s    failat_OK
  4691.     bra    bad_number_error
  4692. failat_OK    move.w    d0,failat_level(a5)
  4693.     moveq    #RETURN_OK,d0
  4694.     RTS
  4695. show_failat
  4696.     lea    failat_level(a5),a1
  4697.     lea    failat_tx(pc),a0
  4698.     bsr    new_print
  4699.     moveq    #RETURN_OK,d0
  4700.     rts
  4701.  
  4702. *******************************
  4703. *    IF COMMAND    *
  4704. *******************************
  4705. ifz    move.b    #$ff,if_flag(a5)
  4706.     move.b    #$ff,if_condition_flag(a5)    set FALSE
  4707.     lea    parm2(a5),a4
  4708.     moveq    #0,d4        not state
  4709. 3$    move.l    (a4)+,d0
  4710.     beq    if_fail
  4711.     move.l    d0,a0
  4712.     lea    not_tx(pc),a1
  4713.     bsr    compare_strings
  4714.     bne.s    2$
  4715.     not.b    d4        set D4=FF if not
  4716.     bra    3$
  4717. 2$    lea    exists_tx(pc),a1
  4718.     bsr    compare_strings
  4719.     bne.s    try_warn    IF NOT AN EXISTS TYPE COMPARE
  4720.     move.l    (a4)+,d1
  4721.     beq    if_fail
  4722.     moveq    #0,d3        d3=0    doesnt exist
  4723.     moveq    #ACCESS_READ,d2
  4724.     jsr    _LVOLock(a6)
  4725.     tst.l    d0
  4726.     beq.s    save_state
  4727.     move.l    d0,d1
  4728.     jsr    _LVOUnLock(a6)
  4729.     not.b    d3        d3=ff    exists
  4730. save_state
  4731.     not.b    d3        d3=0    true
  4732.     eor.b    d4,d3
  4733.     move.b    d3,if_condition_flag(a5)
  4734.     moveq    #RETURN_OK,D0
  4735.     RTS
  4736. try_warn    move.l    last_failcode(a5),d5
  4737.     moveq    #RETURN_WARN,d6
  4738.     lea    warn_tx(pc),a1    CHECK IF 'IF WARN'
  4739.     bsr    compare_strings
  4740.     bne    try_error
  4741. set_error_state
  4742.     moveq    #0,d3
  4743.     cmp.l    d6,d5
  4744.     bne    save_state
  4745.     not.b    d3
  4746.     bra    save_state
  4747. try_error    lea    error_tx(pc),a1
  4748.     bsr    compare_strings
  4749.     bne    try_fail
  4750.     moveq    #RETURN_ERROR,d6
  4751.     bra    set_error_state
  4752. try_fail    lea    fail_tx(pc),a1
  4753.     bsr    compare_strings
  4754.     bne    if_fail
  4755.     moveq    #RETURN_FAIL,d6
  4756.     bra    set_error_state
  4757. if_fail    not.b    if_flag(a5)    clear it
  4758.     lea    if_error_tx(pc),a1
  4759.     bsr    pr_string
  4760.     MOVEQ    #RETURN_ERROR,D0
  4761.     RTS
  4762.  
  4763. *******************************
  4764. *    ASK COMMAND    *
  4765. *******************************
  4766. askz    bsr    echo_parm        print the parm same as echo does
  4767.     bsr    raw_off
  4768.     move.l    inhandle(a5),d1
  4769.     lea    tempbuf(a5),a4
  4770.     clr.b    (a4)
  4771.     move.l    a4,d2
  4772.     move.l    #SHELLINE_SIZE,d3    MAKE SURE READ ANY EXCESS CRAP TOO
  4773.     jsr    _LVORead(a6)
  4774.     bsr    raw_on
  4775.     moveq    #RETURN_WARN,d0
  4776.     cmp.b    #'y',(a4)
  4777.     beq    1$
  4778.     cmp.b    #'Y',(a4)
  4779.     beq    1$
  4780.     moveq    #RETURN_OK,D0
  4781. 1$    RTS
  4782.  
  4783. *******************************
  4784. *    SLEEP COMMAND    *
  4785. *******************************
  4786. sleepz    move.l    parm2(a5),d0
  4787.     bne    1$
  4788. 2$    moveq    #RETURN_ERROR,D0
  4789.     RTS
  4790. 1$    move.l    d0,a1
  4791.     bsr    convert_ASCII_to_num
  4792.     tst.b    d1
  4793.     beq    bad_number_error
  4794.     move.l    d0,d4
  4795. 3$    bsr    check_c
  4796.     bne.s    5$
  4797.     moveq    #50,d1        one second
  4798.     jsr    _LVODelay(a6)
  4799.     subq.l    #1,d4
  4800.     bne.s    3$
  4801. 5$    moveq    #RETURN_OK,D0
  4802.     RTS
  4803.  
  4804. *******************************
  4805. *    RETURN COMMAND    *
  4806. *******************************
  4807. * only returns from script files.
  4808. returnz    tst.b    scflag(a5)
  4809.     bne.s    1$
  4810.     moveq    #RETURN_OK,D0
  4811.     RTS
  4812. 1$    move.l    parm2(a5),d0
  4813.     beq    2$
  4814.     move.l    d0,a1
  4815.     bsr    convert_ASCII_to_num
  4816.     tst.b    d1
  4817.     bne    2$
  4818.     bsr    bad_number_error
  4819. 2$    move.l    d0,-(sp)
  4820.     bsr    kill_script    guarantee that script is dead
  4821.     move.l    (sp)+,d0
  4822.     rts
  4823.     
  4824. *******************************
  4825. *    JOIN COMMAND    *
  4826. *******************************
  4827. joinz    lea    parm2(a5),a4
  4828.     move.l    a4,a3
  4829.     tst.l    4(a3)    must have at least 2 parameters
  4830.     beq    join_failure
  4831. 1$    tst.l    (a3)+        FIND LAST PARAMETER
  4832.     bne.s    1$
  4833.     lea    -8(a3),a3        A3=last parm ie the write file
  4834.     move.l    (a3),d1
  4835.     move.l    #MODE_NEWFILE,D2
  4836.     jsr    _LVOOpen(a6)
  4837.     tst.l    d0
  4838.     beq    DOSjoin_failure
  4839.     move.l    d0,please_close_me(a5)    write handle
  4840.     
  4841. 2$    cmp.l    a4,a3
  4842.     beq    finish_join
  4843.     move.l    (a4)+,a0
  4844.     bsr    readfile
  4845.     move.l    d0,d2
  4846.     move.l    d0,d5    D5=addr
  4847.     move.l    d1,d3
  4848.     move.l    d1,d6    D6=size
  4849.     move.l    please_close_me(a5),d1
  4850.     jsr    _LVOWrite(a6)
  4851.     tst.l    d0
  4852.     bmi    DOSjoin_failure3
  4853.     bsr    free_joiner
  4854.     bra    2$
  4855. finish_join
  4856.     bsr    close_the_joined
  4857.     moveq    #RETURN_OK,D0
  4858.     RTS
  4859.     
  4860. DOSjoin_failure3
  4861.     bsr    free_joiner        dealloc readfile
  4862.     bsr    close_the_joined
  4863. DOSjoin_failure
  4864.     bra    DOSerr
  4865. join_failure
  4866.     lea    join_error_tx(pc),a1
  4867.     bsr    pr_string
  4868.     moveq    #RETURN_ERROR,D0
  4869.     RTS
  4870.  
  4871. free_joiner
  4872.     move.l    d5,a1
  4873.     move.l    d6,d0
  4874.     bra    givemem        dealloc readfile
  4875.  
  4876. close_the_joined
  4877.     move.l    please_close_me(a5),d1
  4878.     jsr    _LVOClose(a6)    close write file
  4879.     clr.l    please_close_me(a5)
  4880.     rts
  4881.  
  4882. *******************************
  4883. *    HTYPE COMMAND    *
  4884. *******************************
  4885. htypez    move.l    parm2(a5),d1
  4886.     bne.s    1$
  4887.     moveq    #RETURN_ERROR,d0
  4888.     rts
  4889. 1$    move.l    d1,a0
  4890.     bsr    readfile
  4891.     move.l    d0,mem_addr(a5)
  4892.     move.l    d0,mem_offset_addr(a5)
  4893.     move.l    d1,temp1(a5)
  4894.     add.l    d0,d1
  4895.     move.l    d1,d7        end marker
  4896.     bsr    raw_off
  4897. 2$    bsr    check_c
  4898.     bne    htype_end
  4899.     bsr    show_16_locs
  4900.     cmp.l    mem_addr(a5),d7
  4901.     bhi    2$
  4902. htype_end    move.l    mem_offset_addr(a5),a1
  4903.     move.l    temp1(a5),d0
  4904.     bsr    givemem
  4905.     bsr    raw_on
  4906.     moveq    #RETURN_OK,D0
  4907.     RTS
  4908.  
  4909.  
  4910. *******************************
  4911. *    STRINGS COMMAND    *
  4912. *******************************
  4913. stringsz    move.l    parm2(a5),d0
  4914.     bne    1$
  4915. 3$    moveq    #RETURN_ERROR,D0
  4916.     RTS
  4917. 1$    moveq    #10,d7        default 10
  4918.     move.l    parm3(a5),d0
  4919.     beq.s    2$
  4920.     move.l    d0,a1
  4921.     bsr    convert_ASCII_to_num
  4922.     tst.b    d1
  4923.     beq    bad_number_error
  4924.     
  4925.     move.l    d0,d7        D7=min_string
  4926. 2$    move.l    parm2(a5),a0
  4927.     bsr    readfile
  4928.     move.l    d0,a4        A4=addr of file
  4929.     move.l    a4,a3
  4930.     move.l    d1,d6        D6=size of file
  4931.     add.l    d0,d1
  4932.     move.l    d1,d4        D4=max addr
  4933.     movem.l    d4-d7/a3-a4,-(sp)
  4934.     bsr    raw_off
  4935.     movem.l    (sp)+,d4-d7/a3-a4
  4936. str_next    bsr    check_c
  4937.     bne    kill_string_file
  4938.     moveq    #0,d5        D5=current string size
  4939.     move.l    a3,a2
  4940. valid_ch    cmp.l    a3,d4
  4941.     beq    string_fin
  4942.     move.b    (a3)+,d0
  4943.     cmp.b    #' ',d0
  4944.     blo.s    not_valid_char
  4945.     cmp.b    #$7f,d0
  4946.     bhi.s    not_valid_char
  4947.     addq.l    #1,d5
  4948.     bra    valid_ch
  4949. not_valid_char
  4950.     cmp.l    d7,d5
  4951.     blo    str_next
  4952.     bsr    write_my_string
  4953.     bra    str_next
  4954.  
  4955. string_fin
  4956.     cmp.l    d7,d5
  4957.     blo    kill_string_file
  4958.     bsr    write_my_string
  4959. kill_string_file
  4960.     move.l    a4,a1
  4961.     move.l    d6,d0
  4962.     bsr    givemem
  4963.     bsr    raw_on
  4964.     moveq    #RETURN_OK,D0
  4965.     RTS
  4966.     
  4967. write_my_string
  4968.     move.l    outhandle(a5),d1
  4969.     move.l    a2,d2
  4970.     move.l    d5,d3
  4971.     jsr    _LVOWrite(a6)
  4972.     bra    pr_lf
  4973.  
  4974.  
  4975. _DOSBase        dc.l    0
  4976. char_count    dc.l    0
  4977. oldstack        dc.l    0
  4978. membase        dc.l    0
  4979. entryA0        dc.l    0
  4980. entryD0        dc.l    0
  4981. better_seglist    dc.l    0
  4982.  
  4983. doserror_text
  4984.     dc.b    103,'NO FREE STORE',0
  4985.     dc.b    121,'FILE NOT OBJECT',0
  4986.     dc.b    202,'OBJECT IN USE',0
  4987.     dc.b    203,'OBJECT EXISTS',0
  4988.     dc.b    205,'OBJECT NOT FOUND',0
  4989.     dc.b    210,'INVALID COMPONENT NAME',0
  4990.     dc.b    211,'INVALID LOCK',0
  4991.     dc.b    212,'OBJECT WRONG TYPE',0
  4992.     dc.b    213,'DISK NOT VALIDATED',0
  4993.     dc.b    214,'DISK WRITE PROTECTED',0
  4994.     dc.b    215,'RENAME ACROSS DEVICES',0  
  4995.     dc.b    216,'DIRECTORY NOT EMPTY',0
  4996.     dc.b    218,'DEVICE NOT MOUNTED',0
  4997.     dc.b    219,'SEEK ERROR',0
  4998.     dc.b    221,'DISK FULL',0
  4999.     dc.b    222,'DELETE PROTECTED',0
  5000.     dc.b    223,'WRITE PROTECTED',0
  5001.     dc.b    224,'READ PROTECTED',0
  5002.     dc.b    225,'NOT A DOS DISK',0
  5003.     dc.b    226,'NO DISK',0
  5004.     dc.b    0
  5005.  
  5006. bad_number_tx    dc.b    'Cannot understand number!',10,0
  5007. join_error_tx    dc.b    'Not enough parameters',10,0
  5008. goto_error_tx    dc.b    'GOTO statement error!',10,0
  5009. if_error_tx    dc.b    'IF statement error!',10,0
  5010. warn_tx        dc.b    'warn',0
  5011. error_tx        dc.b    'error',0
  5012. fail_tx        dc.b    'fail',0
  5013. not_tx        dc.b    'not',0
  5014. exists_tx        dc.b    'exists',0
  5015. bad_prot_bits_tx    dc.b    'Unknown protection bit',10,0
  5016. no_colon_tx    dc.b    'Name MUST end in :',10,0
  5017. resi_not_found_tx    dc.b    'Could not find resident!',10,0
  5018. resi_no_mem_tx    dc.b    'Not enough memory for resident list',10,0
  5019. rpn_result_tx    dc.b    'RESULT: Dec %ld  Hex $%08lx',10,0    
  5020. failat_tx        dc.b    'Failat: %d',10,0
  5021. defscript1    dc.b    's:'    DONT SEPERATE FROM NEXT LINE -,
  5022. defscript2    dc.b    'login.z',0             <----"
  5023. unmounted_tx    dc.b    '[UnMounted]',10,0
  5024. mounted_tx    dc.b    '[Mounted]',0
  5025. directory_tx    dc.b    10,'Directories:',10,0
  5026. volume_tx        dc.b    'Volumes:',10,0
  5027. device_tx        dc.b    10,'Devices:',10,0
  5028. bad_unset_tx    dc.b    ' could not be unset!!',10,0
  5029. breaktx        dc.b    10,'*** BREAK ***',10,0
  5030. prompt_args_tx    dc.b    '%p> ',0
  5031. stk_too_small_tx    dc.b    'Too Small!',10,0
  5032. stk_too_big_tx    dc.b    'Too Big!',10,0
  5033. stk_size_tx    dc.b    'Current Stack = %ld bytes',10,0
  5034. OK_text        dc.b    "O.K..",10,0
  5035. status_help_text
  5036.     dc.b    "Usage:  status [-y|-n]",10,0
  5037. time_text    dc.b    "TIME = %02d:%02d:%02d.%02d",10,0
  5038. stat_text    dc.b    27,"[33mRETURN = %ld  time = %02d:%02d:%02d.%02d"
  5039.     dc.b    "  changes ->chip :%ld  fast :%ld  total :%ld",27,"[31m",10,0
  5040.  
  5041. mem_line    dc.b    "%08lx: %08lx %08lx %08lx %08lx   '%s'",10,0
  5042. vec_line    dc.b    "WarmCapture  $%08lx",10,"CoolCapture  $%08lx",10
  5043.     dc.b    "ColdCapture  $%08lx",10,"KickTagPtr   $%08lx",10
  5044.     dc.b    "KickMemPtr   $%08lx",10,"KickCheckSum $%08lx",10,0
  5045. format    dc.b    '%8ld',0    ;print a longw right justified
  5046. totfiles    dc.b    10,'Total bytes = ',0
  5047. lf    dc.b    10,0
  5048. seq    dc.b    $0d,$9b,'25C',0
  5049. seqwide    dc.b    $0d,$9b,'65C',0
  5050. widetx    dc.b    $0d,$9b,'40C',0
  5051. dosname    dc.b    'dos.library',0    
  5052. newcol    dc.b    27,'[33m',0
  5053. oldcol    dc.b    27,'[31m',0
  5054. dirtext    dc.b    'Dir',27,'[31m',0
  5055. cderrtx    dc.b    'Where?',10,0
  5056. dirof    dc.b    27,'[33mDirectory of -> ',27,'[31m',0
  5057. defpath1    dc.b    'vd0:',0
  5058.     dc.b    'vd0:c',0
  5059.     dc.b    'rad:',0
  5060.     dc.b    'rad:c',0
  5061.     dc.b    'ram:',0
  5062.     dc.b    'ram:c',0
  5063.     dc.b    'df0:',0
  5064.     dc.b    'df0:c',0
  5065.     dc.b    'c:',0
  5066.     dc.b    'df1:',0
  5067.     dc.b    'df1:c',0
  5068. hello    dc.b    10,'ZShell V1.30 '
  5069.     dc.b    '(C)1990,91 Paul Hayter',10,10,0
  5070. tab    dc.b    '    ',0
  5071. badcomm    dc.b    'Command not found!',10,0
  5072. volytx    dc.b    'Volume "%s:" has %ld bytes free.',10,0
  5073. copyOK    dc.b    '...copied!',10,0
  5074. deletedtx    dc.b    '...deleted!',10,0
  5075. memess    dc.b    "CHIP = %ld   FAST = %ld   TOTAL FREE = %ld",10,0
  5076. backspace_it    dc.b    8        DON'T SEPERATE
  5077. delete_it        dc.b    $9b,'P',0        THESE LINES
  5078. return_it        dc.b    $d,$a,0
  5079. insert_it        dc.b    $9b,'@',0,0    3rd char is char to be inserted
  5080. left_cursor    dc.b    $9b,'D',0
  5081. right_cursor    dc.b    $9b,'C',0
  5082. delete_line    dc.b    $0d,$9b,'M',0
  5083. delete_line2    dc.b    $9b,'M',$0d,0
  5084. backslash        dc.b    '/',0    
  5085. help_ret        dc.b    'help^M',0
  5086. clstx        dc.b    $0c,0
  5087. scroll_up_tx    dc.b    $9b,'S',0
  5088. carriage_tx    dc.b    13,0
  5089.     
  5090. doserrtx    dc.b    'ERROR:'        ;DON'T SEPERATE
  5091. space    dc.b    ' '
  5092. null    dc.b    0        ;THESE 3 LINES
  5093.  
  5094.  
  5095. *********************************************
  5096.  
  5097. comtext    dc.b    'addbuffers',0    V1.27
  5098.     dc.b    'ask',0        V1.28
  5099.     dc.b    'assign',0
  5100.     dc.b    'cd',0
  5101.     dc.b    'copy',0
  5102.     dc.b    'delete',0
  5103.     dc.b    'dir',0
  5104.     dc.b    'diw',0
  5105.     dc.b    'echo',0
  5106. else_tx    dc.b    'else',0        V1.28
  5107. endif_tx    dc.b    'endif',0        V1.28
  5108.     dc.b    'exec',0
  5109.     dc.b    'exit',0
  5110.     dc.b    'failat',0
  5111.     dc.b    'goto',0        V1.29
  5112.     dc.b    'help',0
  5113.     dc.b    'htype',0        V1.29
  5114.     dc.b    'if',0        V1.28
  5115.     dc.b    'info',0
  5116.     dc.b    'join',0        V1.29
  5117. label_tx    dc.b    'label',0        V1.29
  5118.     dc.b    'm',0
  5119.     dc.b    'mem',0
  5120.     dc.b    'mkdir',0
  5121.     dc.b    'more',0        V1.23
  5122.     dc.b    'path',0
  5123.     dc.b    'prompt',0
  5124.     dc.b    'relabel',0    V1.27
  5125.     dc.b    'rename',0
  5126.     dc.b    'reset',0
  5127.     dc.b    'resident',0    V1.25
  5128.     dc.b    'return',0    V1.29
  5129.     dc.b    'rpn',0
  5130.     dc.b    'set',0
  5131.     dc.b    'setprot',0
  5132.     dc.b    'sleep',0        V1.29
  5133.     dc.b    'stack',0
  5134.     dc.b    'status',0
  5135.     dc.b    'strings',0    V1.29
  5136.     dc.b    'time',0
  5137.     dc.b    'type',0
  5138.     dc.b    'unset',0
  5139.     dc.b    'vec',0
  5140.     dc.b    'version',0
  5141.     dc.b    0
  5142.     
  5143.     
  5144.     cnop    0,2
  5145. comoffs
  5146.     dc.w    addbuffersz-start
  5147.     dc.w    askz-start
  5148.     dc.w    assignz-start
  5149.  
  5150.     dc.w    chdirz-start
  5151.     dc.w    copyz-start
  5152.  
  5153.     dc.w    deletez-start
  5154.     dc.w    dirz-start
  5155.     dc.w    dirwz-start
  5156.  
  5157.     dc.w    echoz-start
  5158.     dc.w    elsez-start    V1.28
  5159.     dc.w    endifz-start    V1.28
  5160.     dc.w    xz-start
  5161.     dc.w    exitz-start
  5162.  
  5163.     dc.w    failatz-start
  5164.  
  5165.     dc.w    gotoz-start
  5166.  
  5167.     dc.w    helpmez-start
  5168.     dc.w    htypez-start    V1.29
  5169.     
  5170.     dc.w    ifz-start        V1.28
  5171.     dc.w    infoz-start
  5172.  
  5173.     dc.w    joinz-start    V1.29
  5174.     
  5175.     dc.w    labelz-start
  5176.     
  5177.     dc.w    memexamz-start
  5178.     dc.w    availz-start
  5179.     dc.w    mkdirz-start
  5180.     dc.w    morez-start
  5181.  
  5182.     dc.w    pathcomz-start
  5183.     dc.w    promptz-start
  5184.  
  5185.     dc.w    relabelz-start
  5186.     dc.w    renamez-start
  5187.     dc.w    resetz-start
  5188.     dc.w    residentz-start
  5189.     dc.w    returnz-start
  5190.     dc.w    rpnz-start
  5191.  
  5192.     dc.w    set_funcz-start
  5193.     dc.w    setprotz-start
  5194.     dc.w    sleepz-start
  5195.     dc.w    stackz-start
  5196.     dc.w    statusz-start
  5197.     dc.w    stringsz-start
  5198.  
  5199.     dc.w    timez-start
  5200.     dc.w    typez-start
  5201.  
  5202.  
  5203.     dc.w    unsetz-start
  5204.  
  5205.     dc.w    vecz-start
  5206.     dc.w    versionz-start
  5207.  
  5208.     section    raw_stuff,bss
  5209.  
  5210. myport    ds.b    MP_SIZE
  5211. here    ds.b    2  MAKE SURE MYPACKET IS LONGWORD ALIGNED.
  5212. mypacket    ds.b    sp_SIZEOF
  5213.     
  5214.     end
  5215.