home *** CD-ROM | disk | FTP | other *** search
- !BasShrink - a BASIC program compactor
- ======================================
-
- The purpose of !BasShrink is to provide a simple method
- of squashing BASIC programs by the usual methods of
- shortening variable/procedure/function names, deleting
- blank lines, REMs and spaces and concatenating lines (ie
- joining them together!).
-
- The procedure to squash a BASIC program is then:
-
- 1) Load !BasShrink if it is not already loaded. It will
- appear on the icon bar.
- 2) The main input window may be opened by clicking on the
- icon on the icon-bar.
- 3) Drag the BASIC file either to the icon on the icon-bar
- or to the main input window. If the main data window
- is not open then it will opened automatically.
- 4) Amend the options if necessary.
- 5) Amend the filename to save the squashed as and/or drag
- the file to the destination directory, or just click
- OK to overwrite the original program.
- 6) Wait while the program is squashed.
-
- Notes for version 2
-
- i) The 'Multi-task' option is non-functional.
-
- ----------------------------------------------------------
- OPTIONS
- -------
- c : concatenate lines : implemented
- l : remove blank lines : implemented fully
- -p <str>: don't shorten if start <str> : implemented fully
- r : remove REM statements : implemented fully
- * : remove *| statements : implemented fully
- s : remove spaces : implemented fully
- -v : verbose : implemented
- A : ASC("<char>") -> <number> : implemented fully
- D : affect DATA statements : implemented fully
- F : shorten function names : implemented fully
- I : represent integers shortest : implemented fully
- M : multi-task : not implemented
- P : shorten procedure names : implemented fully
- S : SWI "<name>" -> SWI <number> : implemented fully
- V : shorten variable names : implemented fully
-
- Saving the options
- ------------------
- To save the current state of the options then click on
- the 'Save options' icon. This will then be start up state
- when !BasShrink is next run. It is possible to reset the
- options to the start up state by dragging the !Choices
- file onto the icon-bar icon or the main input window.
- If the !Choices file is deleted then the default state
- as set up in the template file is used.
-
- Concatenating lines
- -------------------
- By default lines within a program are joined together
- wherever possible. Exceptions include lines which are
- referenced by GOTO,GOSUB,etc. statements, DATA statements
- and comments.
- Use -c to prevent lines from being concatenated.
-
- Blank lines
- -----------
- By default blank lines within a program (whether blank
- to begin with or becoming blank during shrinking) are
- removed. The exception to this are those lines which are
- directly referenced in GOTO and RESTORE statements as a
- tokenised line number.
- Use -l to prevent blank lines from being deleted.
-
- Preserving names
- ----------------
- Use -p followed by a string of characters which
- represents the start sequence of characters of variable/
- procedure/function names which are not to be shortened.
- This is useful if you are using libraries and don't want
- names starting with '_Wimp', for example, being shortened
- as they reference variable names and procedure/function
- calls to those libraries.
- example: using -p _Wimp
- 10 PROC_Wimp_InitTask
- 20 PROC_MyInit
- becomes: 10 PROC_Wimp_InitTask
- 20 PROCA
-
- REM statements
- --------------
- By default a REM and all following text on that line is
- removed.
- Use -r to prevent REM statements from being deleted.
-
- *| statements
- -------------
- These are the equivalent of a REM but for a star command
- instead. By default a *| and all following text on that
- line is removed.
- Use -* to prevent *| statements from being deleted.
-
- Spaces
- ------
- By default all unnecessary spaces within a line are
- removed.
- Use -s to prevent spaces from being deleted.
-
- Progress display
- ----------------
- By default there is no output from !Shrink. Use -v to
- switch the 'verbose' option on. This displays the progess
- of the compaction on the BASIC file. There are three
- passes, and on each pass the line number currently being
- processed is displayed.
-
- Converting ASC("<char>") to a number
- ------------------------------------
- By default whenever the token ASC occurs on a line, an
- attempt will be made to evaluate it. !Shrink can handle
- both ASC"<char>" and ASC("<char>"), and if there is more
- than one character between the doubele quotes, then only
- the first character is used, the others being ignored.
- Use -A to prevent the token ASC being evaluated.
- example: 10 space = ASC" "
- becomes: 10 space = 32
-
- DATA statements
- ---------------
- By default the text following a DATA keyword is treated
- as though it were on a 'normal' line, and is shrunk as
- dictated by the other options. The exception to this is
- that on the first pass (when creating the name tables), no
- attempt will be made to parse the DATA line, so only names
- which occur on 'normal' lines and on the DATA line are
- shrunk (is requested), all other names are left as found.
- Use -D to prevent the DATA line being affected.
- example: 10 var_names = 2
- 20 DATA var_names,"Fred",Jim
- becomes: 10 A = 2
- 20 DATA A,"Fred",Jim
-
- Function names
- --------------
- By default function names are shortened.
- Use -F to prevent function names from being shortened.
-
- Integers
- --------
- By default any integer (binary, decimal or hex) numbers
- are converted to their shortest form. This is done by
- representing numbers from 0 to 99999999 in decimal and
- numbers geater than 99999999 in hex.
- Use -I to prevent integers from being converted.
- example: 10 big_number = 199999999
- 20 small_number = &10
- 30 binary_value = %1111
- becomes: 10 big_number = &BEBC1FF
- 20 small_number = 16
- 30 binary_value = 15
-
- Procedure names
- ---------------
- By default procedure names are shortened.
- Use -P to prevent procedure names from being shortened.
-
- Converting a swi "<name>" to a swi <number>
- -------------------------------------------
- By default whenever the token SYS or the mnemonic SWI
- occurs on a line, and it is followed by a string, then the
- string is passed to OS_SWINumberFromString. If valid, the
- string will be replaced by the relevant number.
- Note that you may have to load in a module that contains
- swi's before using !BasShrink, so that all swi names are
- recognised.
- Use -S to prevent the name being converted to a number.
- example: 10 SYS "OS_WriteN"
- 90 SWI "OS_WriteN"
- becomes: 10 SYS 70
- 90 SWI 70
-
- Variable and register names
- ---------------------------
- By default variable names are shortened. This includes
- the shortening of register names within assembly language.
- Use -V to prevent variable names from being shortened.
- example: 10 LogicState = TRUE
- 80 LDMFD R13!,{R0-R12,R14,PC}
- becomes: 10 A = TRUE
- 80 LDMFD 13!,{0-12,14,PC}
-
- ----------------------------------------------------------
- HISTORY
- -------
- Version 0.21 : 10-Jul-91
- What !BasShrink will do:
- * Variable/FN/PROC names are shortened
- * Blank lines are removed
- * Preserving names using the -p <str> option
- * REM and *| statements are removed
- * Unnecessary spaces are removed
- * Representing integers as their shortest form
-
- Version 0.22 : 11-Jul-91
- Bug fix: A blank line in a program (that's one with
- just a space on it) used to be interpreted incorrectly and
- a line of garbage put in its place.
- Bug fix: Colons at the end of a line weren't removed.
- Bug fix: Comments within assembly language were not
- recognised. They are now also removed if required.
- Rewrite: The integer conversion routine now uses SWIs.
-
- Mike Harrison's basic cruncher seems to break the rules
- for the assignment of variable names. He uses '`' as one
- of the characters, which is not documented in the User
- Guide on page 21. This states that the rules for variable
- names are:
- - There must be no space within the name
- - They can contain digits and unaccented upper- and
- lower-case letters
- - An additional 'letter' is '_'
- - They must not start with a digit
- - They must not start with a BASIC keyword
- I will allow my code to recognise '`' as a legal character
- within a variable name, but I won't as yet use it as a
- character in my variable name assignments. I may keep it
- as a special start or end character for use with variables
- used in assembly language.
-
- Version 0.23 : 12-Jul-91
- ARMcode: The function getName, giving a saving of
- approximately 5 seconds per pass.
- Bug fix: The BASIC keyword ASC is now allowable inside
- assembly language.
- Bug fix: in procedure addStringToLine which did not
- remove all unnecessary spaces.
- Bug fix: Some comments were left in assembly language.
-
- Version 0.24 : 12-Jul-91
- Rewrite: Tidying up the code which shrinks the lines.
- Bug fix: Spaces between two integer variable names are
- now properly.
-
- One thing which needs to be seen to is that inside
- assembly language there does not need to be a space
- between mnemonics and variable/register names or numbers.
-
- Version 0.25 : 13-Jul-91
- SWI name to number now works (are you happy now Mark!).
- Bug fix: A bug was introduced earlier when decoding the
- 'ASC' keyword.
-
- Version 0.26 : 15-Jul-91
- ARMcode: The routine which builds up the short name from
- its index position. This saves a few seconds, but nothing
- major (oh well, such is life!).
- Rewrite: Tidying up the code dealing with variable names
- saving a bit of time and making the code more readable.
- Problem: The routine which decodes ARM mnemonics needs
- to be totally rewritten as it can't cope with 'TEQ', as it
- reads the 'EQ' part as being the condition part of the
- instruction.
-
- Version 0.27 : 16-Jul-91
- As a fudge to the above problem, 'T' is considered as an
- instruction. A rewrite is needed in a later version.
- ARMcode: The routine which searches for a name in the
- linked list, giving a significant time saving, in the
- order of 25% (better than expected!).
- Bug fix: If there was no terminating double quote then
- the error 'line too long' would occur.
-
- Version 0.28 : 23-Jul-91
- Bug fix: CHR$... would cause an error to be generated if
- found in assembly language. Thanks to Mark for spotting
- that one. It can now cope with many other 'valid' tokens
- within assembly language, such as AND, TRUE, NOT, etc.
- Bug fix: Blank lines were be removed, even when the line
- number was referenced (ie by GOTO RESTORE GOSUB etc).
-
- Version 0.29 : 23-Jul-91
- ARMcode: More routines have been re-written in ARM code,
- namely adding a name and finding a line number.
- Rewrite: Tidying up of the CASE statement for checking
- assembly language code has saved a lot of time.
-
- Version 0.29a: 23-Jul-91
- Rewrite: The routines which create the name tables.
-
- Version 0.30 : 28-Jul-91
- Bug fix: Decimal numbers which begin with a decimal
- point are now recognised properly.
- Problem: Certain assembler mnemonics are not recognised,
- such as ORRS and EORS. I've no idea what the problem is.
- The routine which decodes mnemonics is going to be
- rewritten anyway in a later version.
- If the first line of the program being squished begins
- with a REM statement, then the string:
- ' ¤¤¤ Squished by Lofty's !Shrink vsn <vsn> on <date> ¤¤¤'
- is added to the end of that line.
- The conversion of ASC"<char>" to the relevant number now
- works, in both lines of BASIC and assembly language.
-
- Version 0.31 : 31-Jul-91
- The option 'affect DATA' has been implemented.
-
- Version 0.32 : 02-Aug-91
- Update : The first line is only amended now if the line
- is a REM and does not already contain '¤¤¤...'.
-
- Version 0.33 : 09-Aug-91
- Bug fix: Tokens are now fully recognised within assembly
- language.
- Rewrite: The routines which shorten lines, improving the
- overall performance of the program.
-
- Version 0.34 : 10-Aug-91
- Update : The first line is updated with '¤¤¤...', with
- the previous '¤¤¤...' being removed.
-
- Version 0.35 : 12-Aug-91 (2.00)
- Concatenation of lines now works.
-
- Version 0.36 : 16-Aug-91 (2.01)
- Bug fix: A DATA line could be added to the previous line
- during concatenation.
- Update : A query box now pops up if the source file will
- be overwritten, asking for confirmation.
- Rewrite: Most of the 'front-end' code.
-
- Version 0.37 : 20-Aug-91 (2.02)
- Rewrite: The routine which converts numbers to their
- shortest form. It calculates all possible representations
- and chooses the shortest.
- Update : The front-end now copes with most errors which
- are likely to occur.
- Update : The !BasShrink small and normal icons have been
- decreased in height to conform to the Acorn standard.
-
- 22-Aug-91
- Update : The front-end 'Other Options' toggle works.
-
- Version 0.38 : 24-Aug-91
- Bug fix: A space is required after the mnemonic 'SWI'
- and before a following double quote.
- Update : If there is not enough memory for the DIM then
- a more useful error message is generated.
-
- Version 0.39 : 27-Aug-91 (2.03)
- Bug fix: It's a forward slash '\' (not a backslash '/')
- which represents a comment in assembly language.
- Update : r0,...,r15 and pc are now valid register names.
- Feature: If 'shorten variables' is set then the register
- names r0,...,r15 and R0,...,R15 are shortened to 0,...,15.
-
- Version 0.40 : 28-Aug-91 (2.10)
- Feature: SWI "<name>" -> SWI <number> has been added.
- Update : The front-end 'Save options' button works.
-
- ----------------------------------------------------------
-
- COPYRIGHT
- ---------
- !BasShrink designed and written by John 'Lofty' Wallace,
- with help from Mark Bright and Stuart Hickinbottom.
-
- Version 1 of this program has been placed into the public
- domain. It may be freely copied and distributed for non-
- profit making purposes (a small charge to cover cost of
- distribution is allowed, however), so long as the code is
- not altered (apart from customising !Run/!Boot files) and
- this text file remains present and unaltered.
-
- The source code remains copyright © John Wallace and
- Architype Software, 1991.
-
- Version 2 of !BasShrink, which allows concatenation of
- lines, is available at £5.00 (this includes the full
- source code).
-
- Version 3 of !BasShrink will soon be available, which will
- multi-task under the desktop. This will be £5.00, with a
- discount of £2.50 for version 2 owners.
-
- Due to the continued development of !BasShrink, there will
- be new versions made available from time to time (for both
- version 2 and 3). Registered users will be notified of
- major new releases and can receive the latest version by
- sending a formatted disc and a cheque for £1.00 (to cover
- adminstration and P&P costs).
-
- End User Licence Conditions
- ---------------------------
- 'Software' refers to the source code for all versions of
- !BasShrink and related software.
- 'User' refers to the person who has purchased the
- software.
- The conditions of use are:
- 1. Only the User may use the Software, and must not make
- the Software available to any third party by way of gift
- or loan or hire.
- 2. Sections of the Software can only be included within
- PUBLIC DOMAIN programs written by the User, and they must
- include in a readme file these End User Licence Conditions
- stating clearly which sections of the User's program the
- conditions covers (ie those taken from the Software).
- 3. If the User wishes to include sections of the
- Software in programs they wish to sell, permission must
- be sort from Architype Software (by writing to the address
- below) for a distribution licence.
- 4. No liability will be accepted by John Wallace or
- Architype Software for the suitability of the Software for
- any purpose or for any loss due to the use or mis-use of
- the Software.
-
- If you have any queries/suggestions then write to:
-
- John Wallace
- Architype Software
- 54 Parkes Hall Road
- Woodsetton
- Dudley
- West Midlands
- DY1 3SR
-