home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 1 / GoldFishApril1994_CD1.img / d1xx / d162 / cli_utilities / tree / tree.s < prev   
Text File  |  1988-10-02  |  8KB  |  397 lines

  1. ; ********************************************************************
  2. ; *                                                                  *
  3. ; *  Tree V1.3    (C) 1988 by M.Stoll & M.Zepf & H.E.Stöffler        *
  4. ; *  ---------                                                       *
  5. ; *               Program is placed in PUBLIC DOMAIN and may be      *
  6. ; *               freely distributed with sourcecode and docu-       *
  7. ; *               mentation.                                         *
  8. ; *                         Files included in Achive:                *
  9. ; *  Use Seka-Assembler.                              - Tree.S       *
  10. ; *                                                   - Tree.Doc     *
  11. ; *  To contact us: - Write to: Matthias Zepf         - Tree         *
  12. ; *                             Riegeläckerstr. 27                   *
  13. ; *                      D-7250 Leonberg                             *
  14. ; *                             West Germany                         *
  15. ; *                                                                  *
  16. ; *     - Call:     (+49) 7152 41917 (West Germany)                  *
  17. ; *                                                                  *
  18. ; *     - Electronic Mail:  (+49) 7031 44788 (ELIAS)                 *
  19. ; *                         (+49) 7031 36339 (dateMail)              *
  20. ; *                         (+49) 0711 813480 (microTalk/FNet)       *
  21. ; *                                                                  *
  22. ; *     - UUCP:  Smart:  Agnus@Aragon.UUCP                           *
  23. ; *             Domain:  ...!{uunet!mcvax}!unido!altger!aragon!agnus *
  24. ; *                                                                  *
  25. ; *   Bitte zuerst Tree.doc lesen!     Please read Tree.doc first!   *
  26. ; *                                                                  *
  27. ; ********************************************************************
  28.  
  29.     openlib =    -408
  30.     output =    -60
  31.     input =        -54
  32.     read =        -42
  33.     write =        -48
  34.     exit =        -144
  35.     lock =        -84
  36.     unlock =    -90
  37.     waitforchar =    -204
  38.     currentdir =    -126
  39.     examine =    -102
  40.     exnext =    -108
  41.     allocmem =    -198
  42.     freemem =    -210
  43.     parentdir =    -210
  44.     findtask =    -294
  45.     Setsignal =    -306
  46.  
  47.     move.l    a0,adresse
  48.     move.l    d0,comlang
  49.     move.l    4,a6
  50.     lea    dosname,a1
  51.     jsr    openlib(a6)
  52.     move.l    d0,dosbase
  53.     move.l    d0,a6
  54.     jsr    output(a6)
  55.     move.l    d0,outhandle
  56.     jsr    input(a6)
  57.     move.l    d0,inhandle
  58.     clr.l    d1
  59.     move.l    adresse,a0
  60.     cmp.l    #0,a0
  61.     beq    fehler1
  62.     move.l    comlang,d0
  63.     cmp.l    #1,d0
  64.     beq    Current
  65. lab1:    cmp.b    #" ",(a0)+
  66.     bne    lab3
  67.     subq.l    #1,d0
  68.     bne    lab1
  69.     bra    fehler1
  70. lab3:    sub.l    #1,a0
  71.     cmp.b    #"?",(a0)
  72.     beq    fehler2
  73.     lea    name,a1
  74. lab2:    move.b    (a0)+,(a1)+
  75.     cmp.b    #":",-1(a1)
  76.     beq    lab4
  77.     subq.l    #1,d0
  78.     bne    lab2
  79.     bra    fehler1
  80. lab4:    clr.b    (a1)
  81.     lea    name,a1
  82.     move.l    a1,d1
  83.     move.l    #-2,d2
  84.     move.l    dosbase,a6
  85.     jsr    lock(a6)
  86.     tst.l    d0
  87.     beq    fehler3
  88.     move.l    d0,actlock
  89. lab_weiter:
  90.     move.w    #1,lockcount
  91.     move.l    #270,d0
  92.     move.l    #$10001,d1
  93.     move.l    4,a6
  94.     jsr    allocmem(a6)
  95.     move.l    d0,actpuff
  96.     move.l    d0,d2
  97.     move.l    actlock,d1
  98.     move.l    dosbase,a6
  99.     jsr    examine(a6)
  100.     jsr    infoname
  101.     lea    name,a0
  102.     lea    zeile,a1
  103.     lea    Pfad,a2
  104. su1:    move.b    (a0)+,(a1)+
  105.     move.b    -1(a0),(a2)+
  106.     bne    su1
  107.     move.b    #":",-1(a1)
  108.     move.b    #":",-1(a2)
  109.     clr.b    (a1)
  110.     clr.b    (a2)
  111.     jsr    gebaus
  112. schleife:
  113.     move.l    actlock,d1
  114.     move.l    actpuff,d2
  115.     move.l    dosbase,a6
  116.     jsr    exnext(a6)
  117. stop:    tst.l    d0
  118.     beq    pop
  119.     move.l    actpuff,a0
  120.     tst.l    4(a0)
  121.     bmi    schleife
  122. push:    add.w    #1,lockcount
  123.     jsr    appendname
  124.     jsr    zeilaus
  125.     sub.w    #1,lockcount
  126. pushi:    move.l    actlock,d1
  127.     move.l    actpuff,d2
  128.     move.l    dosbase,a6
  129.     jsr    exnext(a6)
  130.     move.l    d0,success
  131.     tst.l    d0
  132.     beq    push_setbit
  133.     move.l    actpuff,a0
  134.     tst.l    4(a0)
  135.     bmi    pushi
  136.     clr.l    d0
  137.     move.w    lockcount,d0
  138.     clr.l    d1
  139.     bset    d0,d1
  140.     not.l    d1
  141.     and.l    d1,bitter
  142.     bra    pushwei
  143. push_setbit:
  144.     clr.l    d0
  145.     move.w    lockcount,d0
  146.     clr.l    d1
  147.     bset    d0,d1
  148.     or.l    d1,bitter
  149. pushwei:
  150.     add.w    #1,lockcount
  151.     move.l    actlock,-(a7)
  152.     move.l    actpuff,-(a7)
  153.     move.l    success,-(a7)
  154.     move.l    #Pfad,d1
  155.     move.l    #-2,d2
  156.     move.l    dosbase,a6
  157.     jsr    lock(a6)
  158.     move.l    d0,actlock
  159.     move.l    #270,d0
  160.     move.l    #$10001,d1
  161.     move.l    4,a6
  162.     jsr    allocmem(a6)
  163.     move.l    d0,actpuff
  164.     move.l    d0,d2
  165.     move.l    actlock,d1
  166.     move.l    dosbase,a6
  167.     jsr    examine(a6)
  168.     clr.l    d0
  169.     clr.l    d1
  170.     move.l    4,a6
  171.     jsr    SetSignal(a6)
  172.     btst    #12,d0
  173.     bne    unlockall
  174.     bra    schleife
  175. pop:    move.l    actpuff,a1
  176.     move.l    #270,d0
  177.     move.l    4,a6
  178.     jsr    freemem(a6)
  179.     tst.w    unlockflag
  180.     beq    unlockes
  181.     cmp.w    #1,lockcount
  182.     beq    ende
  183. unlockes:
  184.     move.l    actlock,d1
  185.     move.l    dosbase,a6
  186.     jsr    unlock(a6)
  187.     sub.w    #1,lockcount
  188.     beq    ende
  189.     move.l    (a7)+,success
  190.     move.l    (a7)+,actpuff
  191.     move.l    (a7)+,actlock
  192.     jsr    removename
  193.     tst.l    success
  194.     beq    pop
  195.     bra    push
  196. Current:move.w    #"CU",unlockflag
  197.     sub.l    a1,a1
  198.     move.l    4,a6
  199.     jsr    findtask(a6)
  200.     move.l    d0,a0
  201.     move.l    152(a0),d1
  202.     move.l    d1,actlock
  203.     move.l    dosbase,a6
  204. cu_loop:jsr    parentdir(a6)
  205.     tst.l    d0
  206.     beq    cu_end
  207.     tst.l    userlock
  208.     beq    cu_nix
  209.     move.l    d0,-(a7)
  210.     move.l    userlock,d1
  211.     jsr    unlock(a6)
  212.     move.l    (a7)+,d0
  213. cu_nix:    clr.w    unlockflag
  214.     move.l    d0,d1
  215.     move.l    d0,actlock
  216.     move.l    d0,userlock
  217.     bra    cu_loop
  218. cu_end:    bra    lab_weiter
  219. infoname:
  220.     move.l    actpuff,a0
  221.     lea    8(a0),a0
  222.     lea    name,a1
  223. inf1:    move.b    (a0)+,(a1)+
  224.     bne    inf1
  225.     rts
  226. leerzeile:
  227.     lea    zeile,a0
  228.     move.w    #$0a00,(a0)
  229. gebaus:    lea    zeile,a0
  230. allgaus:move.l    outhandle,d1
  231.     move.l    a0,d2
  232.     clr.l    d3
  233. lab7:    addq.l    #1,d3
  234.     tst.b    (a0)+
  235.     bne    lab7
  236.     move.b    #10,-1(a0)
  237.     move.l    dosbase,a6
  238.     jmp    write(a6)
  239. unlockall:
  240.     move.l    actpuff,a1
  241.     move.l    #270,d0
  242.     move.l    4,a6
  243.     jsr    freemem(a6)
  244.     tst.w    unlockflag
  245.     beq    un1_all
  246.     cmp.w    #1,lockcount
  247.     beq    endeI
  248. un1_all:move.l    actlock,d1
  249.     move.l    dosbase,a6
  250.     jsr    unlock(a6)
  251.     sub.w    #1,lockcount
  252.     beq    endeI
  253. unlocki:move.l    (a7)+,a1
  254.     move.l    (a7)+,a1
  255.     move.l    #270,d0
  256.     move.l    4,a6
  257.     jsr    freemem(a6)
  258.     move.l    (a7)+,d1
  259.     tst.w    unlockflag
  260.     beq    un2_all
  261.     cmp.w    #1,lockcount
  262.     beq    endeI
  263. un2_all:move.l    dosbase,a6
  264.     jsr    unlock(a6)
  265.     sub.w    #1,lockcount
  266.     bne    unlocki
  267. endeI:    move.l    outhandle,d1
  268.     move.l    #break,d2
  269.     move.l    #breakend-break,d3
  270.     move.l    dosbase,a6
  271.     jsr    write(a6)
  272. ende:    clr.l    d0
  273.     clr.l    d1
  274.     move.l    dosbase,a6
  275.     jmp    exit(a6)
  276. getend:    lea    pfad,a0
  277. ge_1:    tst.b    (a0)+
  278.     bne    ge_1
  279.     sub.l    #1,a0
  280.     rts
  281. appendname:
  282.     jsr    getend
  283.     cmp.b    #":",-1(a0)
  284.     beq    an_1
  285.     move.b    #"/",(a0)+
  286. an_1:    move.l    actpuff,a1
  287.     lea    8(a1),a1
  288.     lea    name,a2
  289. an_2:    move.b    (a1)+,(a0)+
  290.     move.b    -1(a1),(a2)+
  291.     bne    an_2
  292.     rts
  293. removename:
  294.     jsr    getend
  295. rem_2:    cmp.b    #"/",-1(a0)
  296.     beq    rem_3
  297.     cmp.b    #":",-1(a0)
  298.     beq    rem_1
  299.     clr.b    -(a0)
  300.     bra    rem_2
  301. rem_3:    clr.b    -(a0)
  302. rem_1:    rts
  303. spaces:    move.b    #" ",(a0)+
  304.     bra    Zeil_ll
  305. zeilaus:lea    zeile,a0
  306.     lea    name,a1
  307.     move.b    #" ",(a0)+
  308.     move.w    lockcount,d0
  309.     sub.w    #1,d0
  310.     beq    zeil_end
  311.     sub.w    #1,d0
  312.     beq    keinspc
  313.     clr.l    d2
  314. zeil_loop:
  315.     add.l    #1,d2
  316.     clr.l    d3
  317.     bset    d2,d3
  318.     move.l    bitter,d4
  319.     and.l    d3,d4
  320.     bne    spaces
  321.     move.b    #"|",(a0)+
  322. zeil_ll:move.b    #" ",(a0)+
  323.     move.b    #" ",(a0)+
  324.     sub.w    #1,d0
  325.     bne    zeil_loop
  326. keinspc:move.b    #"+",(a0)+
  327.     move.b    #"-",(a0)+
  328. z_loop2:move.b    (a1)+,(a0)+
  329.     bne    z_loop2
  330.     jsr    gebaus
  331. zeil_end:
  332.     rts
  333. Fehler1:move.l    #Fehlerm1,d2
  334.     move.l    #Fehlerm1end-Fehlerm1,d3
  335.     bra    fehlerallg
  336. Fehler2:move.l    #Fehlerm2,d2
  337.     move.l    #F2ende-Fehlerm2,d3
  338.     bra    fehlerallg
  339. Fehler3:move.l    #Fehlerm3,d2
  340.     move.l    #Fehlerm3end-Fehlerm3,d3
  341.     bra    fehlerallg
  342. fehlerallg:
  343.     move.l    outhandle,d1
  344.     move.l    dosbase,a6
  345.     jsr    write(a6)
  346.     bra    ende
  347.  
  348. ; ---------------------------------------------------------------------
  349.  
  350. dosname:    dc.b 'dos.library',0
  351.         even
  352. Fehlerm1:    dc.b "**Kein Device angegeben. [device missing]",10,0
  353. Fehlerm1end:
  354.         even
  355. Fehlerm2:    dc.b 10,$9b,"7;31;40",$6d," Tree V1.3 ",$9b,"0;31;40"
  356.         dc.b $6d," © 1988 by "
  357.         dc.b $9b,"1;31;40",$6d,"M.Stoll & M.Zepf &"
  358.         dc.b " H.E.Stöffler  ",$9b,"0;31;40",$6d,10
  359.         dc.b "Dieses Programm darf frei kopiert werden. Es "
  360.         dc.b "handelt sich dabei um PUBLIC-",10
  361.         dc.b "DOMAIN-Software. [This program may be "
  362.         dc.b "freely distributed. It is placed in",10
  363.         dc.b "the PUBLIC DOMAIN.]",10,10
  364.         dc.b "Benutzung: Tree <Device>",10,10,0
  365. F2ende:
  366.         even
  367. break:        dc.b "**Abbruch! [Break!]",10,0
  368. breakend:
  369.         even
  370. Fehlerm3:    dc.b "**Ungültiges Device angegeben. [device invalid]",10,0
  371. Fehlerm3end:
  372.         even
  373. dosbase:    dc.l 0
  374. adresse:    dc.l 0
  375. inhandle:    dc.l 0
  376. outhandle:    dc.l 0
  377. tre_getr:    dc.l 0
  378. comlang:    dc.l 0
  379. userlock:    dc.l 0
  380. actlock:    dc.l 0
  381. actpuff:    dc.l 0
  382. lockcount:    dc.l 0
  383. success:    dc.l 0
  384. unlockflag:    dc.w 0
  385. Bitter:        dc.l 0
  386. dummy:        dc.w 0
  387.         even
  388. name:        blk.b 120
  389.         even
  390. zeile:        blk.b 256
  391.         even
  392. Pfad:        blk.b 1024
  393.         even
  394. dospuff:    blk.b 20
  395.         even
  396.  
  397.