home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / newc_dev / rmlib111.lha / remlib.asm < prev    next >
Assembly Source File  |  1991-01-13  |  27KB  |  712 lines

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