home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 206.lha / RemLib / remlib.asm < prev    next >
Assembly Source File  |  1988-12-28  |  19KB  |  670 lines

  1. *****************************************************************************
  2. *
  3. * RemLib.asm    by    HEIKO RATH 
  4. *
  5. *            Copyrigth 1988 by the Software Brewery
  6. *
  7. * This program may be non-commercially distributed.
  8. *
  9. * The purpose of this program is to remove a library from the librarylist.
  10. * To be save, it only removes librarys with an OpenCnt of 0.
  11. * To get a list of all librarys use RemLib without an argument.
  12. *                                Heiko Rath
  13. *
  14. *****************************************************************************
  15. *                          
  16. *______  /          
  17. *______\O                    - The Software Brewery - 
  18. *      \\                          
  19. *       o            Sparkling, fresh software from W.-Germany
  20. *                 
  21. *     @@@@@          Straight from the bar to your system
  22. *     |~~~|\        
  23. *     | | |/        
  24. *     |___|        With our regards to the Software Distillery
  25. *
  26. *Members are (listed alphabetically):
  27. *Christian Balzer alias <CB>, Lattice C, user interfaces, beer addict. 
  28. *Christof Bonnkirch, Aztec C, telecommunications, beer adict.
  29. *Heiko Rath alias <HR>, Assembler, ROM-Kernal stuff, Marabou chocolate addict. 
  30. *Peter Stark alias PS, Lattice C, IO & utilities, WordStar addict.
  31. *Ralf Woitinas alias RAF, Assembler, anything, Ray-Tracing addict.
  32. *
  33. *Beverages: Altenmuenster Brauer Bier, Urfraenkisches Landbier, Grohe Bock.
  34. *
  35. *Send exotic drinks, beautyfull girls, $$$$, comments, critizism, flames, mail to:
  36. *
  37. *The Software Brewery
  38. *Christian Balzer
  39. *Im Wingertsberg 45
  40. *D-6108 Weiterstadt
  41. *West-Germany
  42. *
  43. *Send the above stuff and of course MARABOU-CHOCOLATE to:
  44. *
  45. *Heiko Rath (AAAARRRRGGGHHH, where is my Marabou chocolate??)
  46. *Raiffeisenstr.10a
  47. *D-6108 Weiterstadt
  48. *Tel.06150-2658
  49. *West-Germany
  50. *
  51. *
  52. *Our BBS "AmigaNode" isn't online yet. As soon as it becomes available, 
  53. *you'll be the first to know :-).
  54. *
  55.  
  56. ExecBase    Equ    4
  57.  
  58. ***
  59. *** Exec Offsets:
  60. ***
  61. OpenLibrary    Equ    -552        ;OpenLibrary (LibName,version)(a1,d0)
  62. CloseLibrary    Equ    -414        ;CloseLibrary (Library)(a1)
  63. Forbid        Equ    -132        ;Forbid ()()
  64. Permit        Equ    -138        ;Permit ()()
  65. AllocMem    Equ    -198        ;AllocMem (bytesize,requirement)(d0,d1)
  66. FreeMem        Equ    -210        ;FreeMem (memoryblock,bytesize)(a1,d0)
  67. FindName    Equ    -276        ;FindName (list,name) (a0,a1)
  68. RemLibrary    Equ    -402        ;RemLibrary (library)(a1)
  69.  
  70.  
  71. ***
  72. *** DOS Offsets:
  73. ***
  74. OutPut        Equ    -60        ;OutPut ()
  75. Write        Equ    -48        ;Write (file,buffer,length)(d1,d2,d3)
  76.  
  77. ***
  78. *** I use these Macros to make things easier for me
  79. ***
  80.  
  81. doit:    MACRO
  82.     move.l    #HeadLine,d2        ;address of HeadLine to d2
  83.     bsr    TextOutPut        ;output HeadLine
  84.     move.l    \1,d0            ;offset of listhead to d0
  85.     bsr    Showlib            ;output library-list
  86.     ENDM
  87.  
  88. ***
  89. *** Here we go:
  90. ***
  91.     move.l    sp,d6            ;store stack pointer on stack
  92.     move.l    a0,a2            ;save cmdline address
  93.     sub.w    #1,d0
  94.     clr.b    0(a2,d0.w)        ;make the cmdline null terminated
  95.  
  96.     move.l    ExecBase,a6        ;Execaddress to a6 (only to be sure)
  97.     move.l    #DOSNAME,a1        ;Librarynamepointer to a1
  98.     moveq    #0,d0            ;any version
  99.     jsr    OpenLibrary(a6)        ;try to open DOS-Libary
  100.     tst.l    d0            ;is d0 = NULL?
  101.     beq    ErrorExit        ;exit if call wasn't successfull
  102.     move.l    d0,DOSBase        ;save DOSBasepointer
  103.     move.l    d0,a6            ;move DOSBasepointer to a6
  104.     jsr    OutPut(a6)        ;identify the initial output handle
  105.     move.l    d0,stdout        ;save stdout
  106.  
  107.     move.l    #Text,d2
  108.     bsr    TextOutPut
  109.  
  110. SkipSP:    
  111.     move.b    (a2)+,d1        ;skip spaces
  112.     beq.b    ShowTheLibs        ;if NULL-String then /* show librarys */
  113.     cmp.b    #' ',d1            ;is it a Space ?
  114.     beq.b    SkipSP            ;yes -> SkipSP
  115.  
  116.     cmp.b    #'?',d1            ;is it '?' ?
  117.     beq    ShowHow            ;yes -> ShowHow
  118.  
  119.     cmp.b    #'"',d1            ;is it '"' ?
  120.     bne.b    001$            ;yes -> 001$
  121.     add.l    #1,a2
  122.     move.l    a2,a1
  123. 002$:
  124.     move.b    (a1)+,d1
  125.     beq    NoSuchLibrary
  126.     cmp.b    #'"',d1
  127.     beq.b    003$
  128.     bra.b    002$
  129. 003$:
  130.     sub.l    #1,a1
  131.     move.b    #0,(a1)
  132. 001$:
  133.     sub.l    #1,a2            ;decrement address by one
  134.     move.l    ExecBase,a6        ;ExecBase to a6
  135.     move.l    a6,a0            ;ExecBase to a0
  136.     add.l    liblist,a0        ;address of librarylist to a0
  137.     move.l    a2,a1            ;address of string to a1
  138.     jsr    FindName(a6)        ;search for the given name
  139.     tst.l    d0            ;is there a library with the given name
  140.  
  141.     beq.b    NoSuchLibrary        ;no -> NoSuchLibrary
  142.  
  143.     move.l    d0,a1            ;copy address of library to a1
  144.     move.w    32(a1),d0        ;get OpenCnt
  145.     tst.w    d0            ;is the OpenCnt = 0?
  146.     bne.b    NotZero            ;no -> say that the library is still open
  147.     jsr    RemLibrary(a6)        ;try to close the library
  148.     tst.l    d0
  149.     bne.b    ShowTheLibs        ;->ShowTheLibs
  150.  
  151.     move.l    #FailedToRemove,d2
  152.     bsr    TextOutPut
  153.     bra.b    ShowTheLibs
  154.  
  155. NoSuchLibrary:
  156.     move.l    #NotFound,d2
  157.     bsr    TextOutPut
  158.     bra.b    ShowTheLibs
  159.  
  160. NotZero:
  161.     move.l    #NotAbleToClose,d2
  162.     bsr    TextOutPut
  163.  
  164. ShowTheLibs:
  165.     doit    liblist            ;output Librarylist
  166.  
  167. CloseDOS:
  168.     move.l    ExecBase,a6        ;ExecBase to a6
  169.     move.l    DOSBase,a1        ;DOS-pointer to a1
  170.     move.l    ExecBase,a6        ;Exec-pointer to a6
  171.     jsr    CloseLibrary(a6)    ;close DOS
  172. ErrorExit:
  173.     move.l    d6,sp            ;restore stack pointer
  174.     rts                ;CLI here we go again!!!!
  175.  
  176. ShowHow:
  177.     move.l    #HelpText,d2
  178.     bsr    TextOutPut
  179.     bra    ShowTheLibs
  180.  
  181. *****************************************************************************
  182. *
  183. *    Showlib II                    11.1.87
  184. *            by    Heiko Rath
  185. *                Raiffeisenstr.10a
  186. *                D-6108 Weiterstadt
  187. *                West-Germany
  188. *                Tel.06150-2658
  189. *______  /          
  190. *______\O                    - The Software Brewery - 
  191. *      \\                          
  192. *       o            Sparkling, fresh software from W.-Germany
  193. *                 
  194. *     @@@@@          Straight from the bar to your system
  195. *     |~~~|\        
  196. *     | | |/        
  197. *     |___|        With our regards to the Software Distillery
  198. *
  199. * Members are (listed alphabetically):
  200. * Christian Balzer alias <CB>, Lattice C, user interfaces, beer addict. 
  201. * Christof Bonnkirch, Aztec C, telecommunications, money adict.
  202. * Heiko Rath alias <HR>, Assembler, ROM-Kernal stuff, Marabou chocolate addict. 
  203. * Peter Stark alias PS, Lattice C, IO & utilities, WordStar addict.
  204. * Ralf Woitinas alias RAF, Assembler, anything, Ray-Tracing addict.
  205. *
  206. * Beverages: Altenmuenster Brauer Bier, Urfraenkisches Landbier, Grohe Bock.
  207. *
  208. *
  209. * PURPOSE:            print out Librarylist (address of Node,
  210. *                type, priority, name of Node, version, revision,
  211. *                opencount)
  212. *
  213. * ROUTINETYPE:            subroutine
  214. *
  215. * SYNTAX:            bsr Showlib    (Exec-offset to librarylist)(d0)
  216. *
  217. * ENTRY CONDITIONS:        needs DOSlibrary opened and stdout defined
  218. *                also needs DOS-'Write' offset -48 defined.
  219. *                It also needs binhex subroutine.
  220. *
  221. * RETURNS:            none
  222. *
  223. * BUGS:            none
  224. *
  225. * NOTE:            none
  226. *
  227. * CHANGED:            nothing
  228. *
  229. * USAGE:            move.l    LibraryListOffset,d0
  230. *                bsr    Showlib
  231. *
  232. *****************************************************************************
  233. Showlib:
  234.     movem.l    d0-d7/a0-a6,-(sp)    ;save registers
  235.  
  236.     move.l    ExecBase,a6        ;ExecBase to a6
  237.     jsr    Forbid(a6)        ;forbid taskswitching (very important,
  238.                     ; 'cause we are accessing Systemdata)
  239.  
  240.     move.l    a6,a0            ;Execpointer to a0
  241.     add.l    d0,a0            ; + librarylistoffset=address of listhead
  242.     move.l    a0,ListHead        ;save address of listheader -=> ListHead
  243.     move.l    (a0),a1            ;get address of 1.Node to a1
  244.     move.l    a1,Node            ;save address of 1.Node -=> Node
  245.     addq.l    #4,a0
  246.     cmp.l    a1,a0            ;list empty?
  247.                     ;(test if listhead points to listhead+4)
  248.     beq    PrintLF            ;yes -=> send LF and exit
  249.  
  250.     moveq.l    #1,d1            ;set counter to 1 'cause there is at least
  251.                     ; one node in the list
  252. MyCountLoop:
  253.     move.l    (a1),a1            ;get address of next node to a1
  254.     tst.l    (a1)            ;see if contents of (a1) is NULL
  255.     beq.b    EndCount        ;leave counting loop
  256.     addq.l    #1,d1            ;increment counter by one
  257.     bra.b    MyCountLoop        ;do this once more
  258.  
  259. EndCount:
  260.     move.l    d1,NodeCount        ;save number of Nodes
  261.  
  262.     move.l    #58,d0            ;number of bytes per node
  263.     mulu    d1,d0            ;bytes per node * NodeCount
  264.     addq.l    #1,d0            ;add one for the bufferterminating Null
  265.     move.l    d0,MyMemoryLength    ;save lenght of Memoryblock
  266.     move.l    #$10001,d1        ;requirements:MEMF_Public & Clear
  267.     jsr    AllocMem(a6)        ;get memory from system
  268.     move.l    d0,MyMemoryBlock    ;save address of Memoryblock
  269.     move.l    d0,MyMemoryOffset    ;save address of Memoryblock 2.time
  270.     tst.l    d0            ;see if call was successfull
  271.     bne    MoveNodeToBuffer    ;yes -=> MoveNodeToBuffer
  272.  
  273.     move.l    #Err,d2            ;this code is only here, to inform the
  274.     bsr    TextOutPut        ; user that the AllocMem call wasn't
  275.     bra    PrintLF            ; successfull
  276.  
  277. MoveNodeToBuffer:
  278.     move.l    d0,a0            ;get address of MemoryBlock to a0
  279.     move.l    MyMemoryLength,d1    ;get length to d1
  280.  
  281. fill:
  282.     move.b    #' ',(a0)+        ;fill MyMemoryBlock with spaces
  283.     dbeq.b    d1,fill            ;is d1=NULL? (no-=>d1=d1-1-=>fill)
  284.  
  285. TheLoop:
  286.     move.l    MyMemoryOffset,a0    ;get address of MyMemoryOffset to a0
  287.     move.l    Node,a1            ;get address of current node to a1
  288.  
  289.     add.l    #10,a1            ;address of namepointer to a1
  290.     move.l    (a1),a1            ;get address of nodename to a1
  291.     moveq.l    #0,d1            ;this is faster than clr.l d1
  292.     moveq.l    #0,d2            ;set this to NULL for strlen
  293.  
  294. strlen:
  295.     cmp.b    (a1)+,d2        ;NULL?
  296.     beq.b    strlentest        ;yes -=>strlentest
  297.     addq.l    #1,d1            ;increment d1 by one (stringlength)
  298.     bra.b    strlen            ;do the loop once more
  299.  
  300. strlentest:
  301.     cmp.b    #20,d1            ;see if string is greater #20
  302.     ble.b    DoCopy            ;no (less or equal)-=>DoCopy
  303.     move.l    #20,d1            ;set max.length to 20
  304.  
  305. DoCopy:
  306.     move.l    Node,a1            ;get address of node to a1
  307.     add.l    #10,a1            ;address of namepointer to a1
  308.     move.l    (a1),a1            ;get address of nodename to a1
  309.     tst.l    d1            ;see if d1=0
  310.     bne    DoTheCopy        ;jump only if d1<>0
  311.     move.l    #NoName,a1        ;get address of NoName to a1
  312.     moveq.l    #7,d1            ;set length to 7 (length of 'No Name')
  313.  
  314. DoTheCopy:
  315.     subq.l    #1,d1            ;decrement d1 by 1
  316.  
  317. CopyLoop:
  318.     move.b    0(a1,d1),0(a0,d1)    ;copy source to destination
  319.     dbf    d1,CopyLoop        ;decrement d1, if d1<0 then out of loop
  320.  
  321.     move.l    MyMemoryOffset,a0    ;get address of MyMemoryOffset to a0
  322.     move.b    #'$',21(a0)        ;store '$'
  323.     move.b    #'$',35(a0)        ;store '$'
  324.     move.b    #10,57(a0)        ;store LF
  325.  
  326.     move.l    Node,a1            ;get Nodeaddress to a1
  327.     addq.l    #8,a1            ;add 8 to get address of Type
  328.     moveq.l    #0,d0            ;clear d0
  329.     move.b    (a1),d0            ;get Type to d0
  330.     move.l    MyMemoryOffset,a0
  331.     add.l    #31,a0
  332.     bsr    bindecb            ;convert to ASCII
  333.  
  334.     move.l    Node,a1            ;get Nodeaddress to a1
  335.     add.l    #9,a1            ;add 1 to get address of Priority
  336.     moveq.l    #0,d0
  337.     move.b    (a1),d0
  338.     move.l    MyMemoryOffset,a0
  339.     add.l    #35,a0
  340.     bsr    bindecb
  341.  
  342.     move.l    Node,a1            ;get Nodeaddress to a1
  343.     add.l    #32,a1            ;add 32 to get address of OpenCnt
  344.     moveq.l    #0,d0            ;clear d0
  345.     move.w    (a1),d0            ;get OpenCnt to d0
  346.     move.l    MyMemoryOffset,a0
  347.     add.l    #39,a0
  348.     bsr    bindecw            ;convert OpenCnt to ASCII
  349.  
  350.     move.l    Node,a1            ;get Nodeaddress to a1
  351.     add.l    #20,a1
  352.     moveq.l    #0,d0
  353.     move.w    (a1),d0            ;Version
  354.     move.l    MyMemoryOffset,a0
  355.     add.l    #45,a0
  356.     bsr    bindecw
  357.  
  358.     move.l    Node,a1
  359.     add.l    #22,a1
  360.     moveq.l    #0,d0
  361.     move.w    (a1),d0            ;Revision
  362.     move.l    MyMemoryOffset,a0
  363.     add.l    #51,a0
  364.     bsr    bindecw
  365.  
  366.     move.l    Node,d0            ;get Nodeaddress to d2
  367.     move.l    MyMemoryOffset,a0    ;get address of MyMemoryOffset to a0
  368.     add.l    #22,a0            ;add 22 to get storeaddress
  369.     bsr    binhex            ;convert address to ASCII
  370.  
  371.     add.l    #58,MyMemoryOffset    ;do this for the next loop
  372.     move.l    Node,a1            ;get nodeaddress to a1
  373.     move.l    (a1),Node        ;save address of next node
  374.     move.l    MyMemoryOffset,d0    ;get MyMemoryOffset to d0
  375.     addq.l    #1,d0
  376.     move.l    MyMemoryBlock,d1    ;get MyMemoryBlock to d1
  377.     add.l    MyMemoryLength,d1    ;add MyMemoryLength to d1
  378.     cmp.l    d0,d1            ;see if we have to loop once more
  379.     bne    TheLoop            ;if <> -=> TheLoop
  380.     move.l    MyMemoryBlock,a0    ;get address of MyMemoryBlock to a0
  381.     add.l    MyMemoryLength,a0    ;add length to MyMemoryBlock
  382.     subq.l    #1,a0            ;decrement address by one
  383.     move.b    #0,(a0)            ;set last byte of MyMemoryBlock to NULL
  384.  
  385.     move.l    MyMemoryBlock,d2    ;get address of MyMemoryBlock to d2
  386.     bsr    TextOutPut        ;print out the complete buffered list
  387.     move.l    MyMemoryBlock,a1    ;get address of MyMemoryBlock to a1
  388.     move.l    MyMemoryLength,d0    ;get length of MyMemoryBlock to d0
  389.     jsr    FreeMem(a6)        ;free the allocated RAM
  390.  
  391. PrintLF:
  392.     move.l    #LF,d2            ;get address of LF-string to d2
  393.     bsr.b    TextOutPut        ;and get it out via DOS-Write & stdout
  394.     jsr    Permit(a6)        ;permit taskswitching (I think Dos enables
  395.                     ; this for you, but I do this to be sure
  396.                     ; that taskswitching is now allowed.)
  397.     movem.l    (sp)+,d0-d7/a0-a6    ;restore Registers
  398.     rts
  399.  
  400. *****************************************************************************
  401. *
  402. *    TextOutPut
  403. *            by    Heiko Rath
  404. *                Raiffeisenstr.10a
  405. *                D-6108 Weiterstadt
  406. *                West Germany
  407. *                Tel.06150-2658
  408. *______  /          
  409. *______\O                    - The Software Brewery - 
  410. *      \\                          
  411. *       o            Sparkling, fresh software from W.-Germany
  412. *                 
  413. *     @@@@@          Straight from the bar to your system
  414. *     |~~~|\        
  415. *     | | |/        
  416. *     |___|        With our regards to the Software Distillery
  417. *
  418. * Members are (listed alphabetically):
  419. * Christian Balzer alias <CB>, Lattice C, user interfaces, beer addict. 
  420. * Christof Bonnkirch, Aztec C, telecommunications, beer adict.
  421. * Heiko Rath alias <HR>, Assembler, ROM-Kernal stuff, Marabou chocolate addict. 
  422. * Peter Stark alias PS, Lattice C, IO & utilities, WordStar addict.
  423. * Ralf Woitinas alias RAF, Assembler, anything, Ray-Tracing addict.
  424. *
  425. * Beverages: Altenmuenster Brauer Bier, Urfraenkisches Landbier, Grohe Bock.
  426. *
  427. * PURPOSE:         output a NULL-terminated string via stdout
  428. *
  429. * ROUTINE TYPE:     subroutine
  430. *
  431. * SYNTAX:        bsr    TextOutPut    (stringaddress)(d0)
  432. *
  433. * ENTRY CONDITIONS:    needs DOSlibrary opened and stdout defined
  434. *            also needs DOS-'Write' offset -48 defined.
  435. *
  436. * RETURNS:        none
  437. *
  438. * NOTE:        its better if the string is really NULL-terminated
  439. *
  440. * CHANGED:        nothing
  441. *
  442. * USAGE:        move.l    #Textaddress,d2
  443. *            bsr    TextOutPut
  444. *
  445. *****************************************************************************
  446.  
  447. TextOutPut:
  448.     movem.l    d0-d7/a0-a6,-(sp)    ;save registers
  449.     move.l    d2,a0            ;address to a0
  450.     clr.l    d3            ;count = 0
  451.  
  452. CountLoop:
  453.     tst.b    (a0)+            ;is it NULL ?
  454.     beq.b    PMsg            ;yes: -=> determine length
  455.     addq.l    #1,d3            ;count = count+1
  456.     bra.b    CountLoop        ;test next byte
  457.  
  458. PMsg:
  459.     move.l    stdout,d1        ;get stdout to d1
  460.     move.l    DOSBase,a6        ;move DOSBase to a6
  461.     jsr    Write(a6)        ;write the Text
  462.     movem.l    (sp)+,d0-d7/a0-a6    ;reserve registers
  463.     rts
  464.  
  465. ***********************************************************************
  466. *
  467. *     binhex
  468. *             by Heiko Rath
  469. *
  470. * PURPOSE: Convert a binary value in a register to
  471. *        a hex ASCII string at the destination address
  472. *          
  473. * ROUTINE TYPE: SUBROUTINE
  474. *
  475. * SYNTAX: bsr    binhex    (source(long),destination) (d0.l,a0)
  476. *       bsr    binhexw    (source(word),destination) (d0.w,a0)
  477. *       bsr    binhexb    (source(byte),destination) (d0.b,a0)
  478. *
  479. * ENTRY CONDITIONS: None
  480. *
  481. * RETURNS: ASCII string in destination address
  482. * NOTE:     the destination place must contain 8 bytes for any
  483. *            length (byte, word, longword)
  484. *
  485. * CHANGED: Nothing
  486. *
  487. * USAGE:
  488. *
  489. *     move    #label,d0
  490. *     move.l    address,a0    ;converts the address at label to
  491. *     bsr    binhex        ;string at address
  492. *                
  493. *     move    label,d0
  494. *     move.l    address,a0
  495. *     bsr    binhex        ;conv contents at label
  496. *
  497. *     move    #value,d0
  498. *     move.l    address,a0
  499. *     bsr    binhex        ;convert immediate value
  500. *
  501. ****************************************************************
  502.  
  503. binhex:    movem.l    d0-d2/a0,-(sp)        ;save registers
  504.  
  505.     move.l    #7,d2            ;get number of counts to d2
  506.     clr.l    d1            ;clear work register
  507.  
  508. 001$:    rol.l    #4,d0            ;move high nibble to low order
  509.     move.b    d0,d1            ;get low order byte to d1
  510.     andi.b    #$f,d1            ;isolate low order nibble
  511.     cmp.b    #$0a,d1            ;is it a letter or a digit?
  512.     blt.b    002$            ;if digit -=> 002$
  513.     add.b    #'A'-'0'-$0A,d1        ;offset for letters
  514.  
  515. 002$:    add.b    #'0',d1            ;convert to ASCII
  516.     move.b    d1,(a0)+        ;store it and increment storeaddress
  517.     dbf.b    d2,001$            ;do the converting 8 times
  518.  
  519.     movem.l    (sp)+,d0-d2/a0        ;restore registers
  520.     rts
  521.  
  522. ***********************************************************************
  523. *
  524. *     bindec
  525. *             by Heiko Rath
  526. *
  527. * PURPOSE: Convert a binary value in a register to
  528. *        a dec ASCII string at the destination address
  529. *          
  530. * ROUTINE TYPE: SUBROUTINE
  531. *
  532. * SYNTAX:
  533. *       bsr    bindecw    (source(word),destination) (d0.w,a0)
  534. *       bsr    bindecb    (source(byte),destination) (d0.b,a0)
  535. *
  536. * ENTRY CONDITIONS: None
  537. *
  538. * RETURNS: ASCII string in destination address
  539. * NOTE:     the destination place must contain 5 bytes for any
  540. *            length (byte, word). Don't use longwords!
  541. *
  542. * CHANGED: Nothing
  543. *
  544. * USAGE:
  545. *
  546. *     move    #label,d0
  547. *     move.l    address,a0    ;converts the address at label to
  548. *     bsr    bindec        ;string at address
  549. *                
  550. *     move    label,d0
  551. *     move.l    address,a0
  552. *     bsr    bindec        ;conv contents at label
  553. *
  554. *     move    #value,d0
  555. *     move.l    address,a0
  556. *     bsr    bindec        ;convert immediate value
  557. *
  558. ****************************************************************
  559.  
  560. bindecb:
  561.     movem.l    d0-d2/a0,-(sp)        ;store registers
  562.     move.l    d0,d1
  563.     move.l    a0,a1
  564.     bra.b    ByteToDec
  565.  
  566. bindecw:
  567.     movem.l    d0-d2/a0,-(sp)        ;save registers
  568.     move.l    d0,d1
  569.     move.l    a0,a1
  570.  
  571.     divu    #10000,d1
  572.     bsr.b    StoreOneByte
  573.     divu    #1000,d1
  574.     bsr.b    StoreOneByte
  575. ByteToDec:
  576.     divu    #100,d1
  577.     bsr.b    StoreOneByte
  578.     divu    #10,d1
  579.     bsr.b    StoreOneByte
  580.     bsr.b    StoreOneByte
  581.  
  582. 003$:                    ;003$ is used to clear the
  583.     move.b    (a1)+,d0        ; leading zeros
  584.     cmp.b    #'0',d0
  585.     bne.b    002$
  586.     cmp.b    #' ',(a1)
  587.     beq.b    002$
  588.     move.b    #' ',-(a1)
  589.     add.l    #1,a1
  590.     bra.b    003$
  591. 002$:
  592.     movem.l    (sp)+,d0-d2/a0        ;restore registers
  593.     rts
  594.  
  595. StoreOneByte:
  596.     add.b    #$30,d1
  597.     move.b    d1,(a0)+
  598.     clr.w    d1
  599.     swap    d1
  600.     rts
  601.  
  602. ***
  603. *** Variables:
  604. ***
  605.  
  606. DOSBase:    dc.l    0        ;this contains the DOSlibraryaddress
  607. stdout:        dc.l    0        ;this contains stdout
  608.                     ; address of the cmdline
  609. ListHead:
  610.     dc.l    0            ;At runtime this contains the
  611.                     ; address of the listheader
  612. Node:
  613.     dc.l    0            ;At runtime this contains the
  614.                     ; address of the current node
  615. NodeCount:
  616.     dc.l    0            ;At runtime this contains the
  617.                     ; number of nodes in the list
  618. MyMemoryLength:
  619.     dc.l    0            ;At runtime this contains the
  620.                     ; length of the memoryblock
  621. MyMemoryBlock:
  622.     dc.l    0            ;At runtime this contains the
  623.                     ; address of the memoryblock
  624. MyMemoryOffset:
  625.     dc.l    0            ;At runtime this contains the
  626.                     ; address of the memoryblock
  627.                     ; + 48 Bytes per finished node
  628.  
  629. ***
  630. ***Constants:
  631. ***
  632. liblist:    dc.l    $17a
  633.  
  634. DOSNAME:    cstring    'dos.library'
  635.         cnop    0,2
  636. Err:        dc.b    '*** Out of Memory Error ***',0
  637.         cnop    0,2
  638. NoName:        dc.b    'No Name',0
  639.         cnop    0,2
  640. LF:        dc.b    10,0        ;LF
  641.         cnop    0,2
  642. HeadLine:    dc.b    $9b,'4;32;40m'
  643.         dc.b    'Name                  Address  Typ Pri OpenC Vers. Revis.'
  644.         dc.b    $9b,'0;31;40m',10,0
  645.         cnop    0,2
  646. Text:
  647.     dc.b    $9b,'0;33;40m','Lib-Remover',$9b,'0;31;40m'
  648.     dc.b    '  by ',$9b,'0;32;40m','Heiko Rath',$9b,'0;31;40m',' - '
  649.     dc.b    $9b,'4;31;40m',169,' by ',$9b,'1;31;40m'
  650.     dc.b    'The Software Brewery',$9b,'0;31;40m',10
  651.     dc.b    'Raiffeisenstr.10a, D-6108 Weiterstadt, Tel. 06150-2658',10
  652.     dc.b    0
  653.  
  654.     cnop    0,2
  655. NotAbleToClose:
  656.     dc.b    $9b,'0;33;40m','Attention:',$9b,'0;31;40m'
  657.     dc.b    ' This library can not be closed, cause OpenCnt > 0',10,0
  658.     cnop    0,2
  659. FailedToRemove:
  660.     dc.b    $9b,'0;33;40m','Attention:',$9b,'0;31;40m'
  661.     dc.b    ' Failed to remove the library',10,0
  662.     cnop    0,2
  663. NotFound:
  664.     dc.b    $9b,'0;33;40m','Attention:',$9b,'0;31;40m'
  665.     dc.b    ' Library not found',10,0
  666.     cnop    0,2
  667. HelpText:
  668.     dc.b    'Use ',$9b,'0;33;40m','Remlib',$9b,'0;31;40m'
  669.     dc.b    ' ',34,'name.library',34,' to remove a library',10,0
  670.