home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / comm / atob-4.0.lha / ATOB / AVAIL.DOC < prev    next >
Text File  |  1994-10-13  |  4KB  |  189 lines

  1.  
  2. AVAIL.DOC
  3.  
  4. A HACK AND A CHALLENGE!
  5. AVAIL is one of the most used utilities on my system.  So I decided to
  6. rewite (or HACK, if you prefer) it in ASMB Language as a learning experience.
  7. This version runs the same as the original, except uses much less stack, and
  8. gives the correct total largest hunk.  Values differ due to less RAM usage.
  9. It is 372 bytes.  Anyone want to try a smaller version?  Well, anyway, it
  10. lives again as a test file for BTOA/ATOB encode/decode.
  11.  
  12.  
  13. AVAIL.AB is the above program encoded by BTOA (Binary to ASCII).
  14.  
  15.  
  16. ATOB decoding
  17. -------------
  18.  
  19. >ATOB
  20.  
  21.  READ file: AVAIL.AB
  22. WRITE file: AVAIL (Y/N) Y
  23.  
  24. Thats it!  AVAIL is decoded and placed in your current directory.
  25. Alternately, for a different WRITE file:
  26.  
  27. >ATOB
  28.  
  29.  READ file: AVAIL.AB          - Encoded files with file.AB
  30. WRITE file: AVAIL (Y/N) N     - No, don't use that name
  31. WRITE file: RAM:A             - Put it in RAM: named "A"
  32. >
  33.  
  34. and AVAIL is decoded to RAM: with the filename "A".
  35.  
  36.  
  37. BTOA encoding
  38. -------------
  39.  
  40. >BTOA
  41.  
  42.  READ file: RAM:A             - "A" is the binary file
  43.  ATOB name: A (Y/N) N         - Name ATOB uses when decoded
  44.  ATOB name: AVAIL             - Tell the receiver the real name
  45. WRITE file: RAM:A.AB (Y/N) N  - No, not the default path:filename
  46. WRITE file: RAM:AVAIL.AB      - Save the ASCII file
  47. >
  48.  
  49. and RAM:A has been encoded in file RAM:AVAIL.AB.  When it is decoded,
  50. ATOB will default to the ATOB name "AVAIL".
  51.  
  52.  
  53.  Randy Lilly           N3ET @ N3ET.PA.USA.NA (send me a note)
  54.  752 S Carldon St
  55.  Allentown, PA 18103
  56.  
  57.  
  58. ---
  59. *Avail.ASM  Randy Lilly 871220
  60.  
  61. _LVOAvailMem EQU -$D8
  62. _LVOCloseLibrary EQU -$19E
  63. _LVOOutPut EQU $FFFFFFC4
  64. _LVOForbid EQU $FFFFFF7C
  65. _LVOWrite  EQU -$30
  66. _LVOPermit EQU -$8A
  67.  NOPAGE
  68.  
  69. LF1:
  70.  LEA    DB(PC),A4
  71.  MOVE.L A4,A1           ;DosNam
  72.  MOVEQ  #0,D0
  73.  MOVE.L 4,A6
  74.  JSR    -$228(A6)       ;-552 _LVOOpenLibrary
  75.  MOVE.L D0,(A4)+
  76.  MOVE.L D0,A6
  77.  JSR    _LVOOutPut(A6)
  78.  MOVE.L D0,(A4)
  79.  MOVE.L 4,A6
  80.  JSR    _LVOForbid(A6)
  81.  MOVEQ  #0,D6
  82.  MOVE.L D6,D7
  83.  MOVE.L 322(A6),A0      ;$14C
  84.  
  85. LF2:                    ;Get maximum totals
  86.  TST.L  (A0)
  87.  BEQ.S  LF5
  88.  MOVE.L 24(A0),D0       ;Upper
  89.  SUB.L  20(A0),D0       ;-Lower
  90.  BTST.B #1,15(A0)       ;MEMF_CHIP
  91.  BEQ.S  LF3
  92.  ADD.L  D0,D7
  93. LF3:
  94.  BTST.B #2,15(A0)       ;MEMF_FAST
  95.  BEQ.S  LF4
  96.  ADD.L  D0,D6
  97. LF4:
  98.  MOVE.L (A0),A0
  99.  BRA    LF2
  100.  
  101. DOA1
  102.  BSET.L #17,D3   20000
  103. DOA
  104.  MOVE.L D3,D1
  105.  JMP    _LVOAvailMem(A6)
  106.  
  107. LF5:
  108.  MOVEQ  #2,D3           ;MEMF_CHIP
  109.  BSR    DOA
  110.  MOVE.L D0,D5
  111. * MOVEQ  #2,D1          ;$20002 MEMF_CHIP|MEMF_LARGEST
  112.  BSR    DOA1
  113.  MOVE.L D0,A5
  114.  MOVEQ  #4,D3           ;MEMF_FAST
  115.  BSR    DOA
  116.  MOVE.L D0,D4
  117. * MOVEQ  #4,D1          ;$20004 MEMF_FAST|MEMF_LARGEST
  118.  BSR    DOA1
  119.  MOVE.L D0,A1
  120.  JSR    _LVOPermit(A6)
  121.  
  122.  LEA    HEADER(PC),A0
  123.  BSR.S  LF8
  124.  
  125.  MOVE.L A5,-(SP)
  126.  MOVE.L D7,-(SP)
  127.  MOVE.L D7,-(SP)
  128.  SUB.L  D5,(SP)
  129.  MOVE.L D5,-(SP)
  130.  PEA    MCHIP(PC)
  131.  BSR.S  LF7
  132.  
  133.  MOVE.L A1,-(SP)
  134.  MOVE.L D6,-(SP)
  135.  MOVE.L D6,-(SP)
  136.  SUB.L  D4,(SP)
  137.  MOVE.L D4,-(SP)
  138.  PEA    MFAST(PC)
  139.  BSR.S  LF7
  140.  
  141.  MOVE.L A1,-(SP)
  142.  CMPA.L (SP),A5
  143.  BLS.S  LF6
  144.  MOVE.L A5,(SP)
  145. LF6:
  146.  ADD.L  D4,D5
  147.  ADD.L  D6,D7
  148.  MOVE.L D7,-(SP)
  149.  MOVE.L D7,-(SP)
  150.  SUB.L  D5,(SP)
  151.  MOVE.L D5,-(SP)
  152.  PEA    MTOTAL(PC)
  153.  BSR.S  LF7
  154.  LEA    60(SP),SP
  155.  
  156.  MOVE.L -(A4),A1
  157.  MOVE.L 4,A6
  158.  JMP    _LVOCloseLibrary(A6)
  159.  
  160. LF7
  161.  LEA    FMT(PC),A0     ;Format
  162. LF8
  163.  MOVE.L A1,-(SP)
  164.  LEA    8(SP),A1       ;Buff
  165.  LEA    L8(PC),A2      :Operation
  166.  LEA    LF1(PC),A3     ;NewBuff
  167.  MOVE.L A3,D2          ;Buff
  168.  MOVE.L 4,A6
  169.  JSR    -522(A6)       ;RawDoFormat
  170.  MOVE.L (A4),D1        ;FH
  171.  MOVEQ  #47,D3         ;Size
  172.  MOVE.L DB(PC),A6
  173.  JSR    _LVOWrite(A6)
  174.  MOVE.L (SP)+,A1
  175.  
  176. L8:
  177.  MOVE.B D0,(A3)+
  178.  RTS
  179.  
  180. DB     DC.B 'dos.'
  181. MYOUT  DC.B 'library',0
  182. FMT    DC.B '%.5s %9ld %9ld %9ld %9ld',$A,0
  183. MCHIP  DC.B 'chip '
  184. MFAST  DC.B 'fast '
  185. MTOTAL DC.B 'total'
  186. HEADER DC.B 'Type  Available    In-Use   Maximum   Largest',$A,0
  187.  END
  188.  
  189.