home *** CD-ROM | disk | FTP | other *** search
- !Squish
- -------
- Release 2.38
-
-
- ARM-Code BASIC Squishing software : Kevin J Swinton
- C RISC OS WIMP Interface software : Stuart Swinton
-
- © Kevin J Swinton and Stuart Swinton 1990/1991/1992
- Published by : Unique Software 1993
-
-
- -----------------------------------------------------------------------------
- Disclaimer
- -----------------------------------------------------------------------------
-
- The software is provided "as is". Neither the authors or Unique Software
- make any warranty, express or implied, of the merchantability of this
- software or its fitness for any particular purpose. In no circumstances
- shall either be liable for any damage, loss of profits, or any indirect or
- consequential loss arising out of the use of this software or inability to
- use this software, even if advised of the possibility of such loss.
-
-
- -----------------------------------------------------------------------------
- Rules and regulations for !Squish
- -----------------------------------------------------------------------------
-
- * Squish is not perfect. After an extremely long development time, Squish
- has reached the stage whereby it can squash any program by someone with a
- respect for 'sensible' programming. One can lecture about the principles of
- good design in today's competing environment, but no. Though suffice to
- mention a statement made by Dijkstra in 1979, on the subject of software:
-
- "The advent of cheap and powerful devices will put Software Engineering
- back 25 years."
-
- This, of course, is absolutely true.
-
- The BBC BASIC interpreter is quite simple. It's syntax rules are good,
- but very flexible. This allows people to tackle the subject of programming
- in very different ways. Squish uses general algorithms to reduce the size
- of programs, but there are restrictions should you want the resulting file
- to work! These are listed below, along with hints on how to avoid these.
-
-
- ------------------------- Restrictions with Squish --------------------------
-
-
- * GOTO, GOSUB and RESTORE.
-
- Squish will simply ignore these commands by skipping past them. Nowadays it
- is absolutely unforgiveable to use GOTO/GOSUB so Squish will NEVER support
- these. RESTORE commands are generally OK, but
-
- a) don't use formula based RESTORE commands if you can avoid doing so, and
- b) don't RESTORE pointers to blank lines/REMs that will be deleted.
-
- Please note that, if a program has been written sensibly, it is perfectly
- possible for it's GOTO, GOSUB, and/or RESTORE commands to be squished and
- still work correctly. (Eg. RISC User's !Dustbin.)
-
-
- ----------------------------------------------------------
-
-
- * DATA statements
-
- If a variable is an element of a DATA statement, it will need to be
- renamed along with the other references to it throughout the program.
-
- In DATA statements, BASIC determines a string from a variable by the fact
- that the former is enclosed within quotation marks, although the syntax
- does allow certain strings to exclude quotation marks.
-
- Squish works on the principle that ALL strings are enclosed within
- quotation marks. If not, the DATA element is liable to be renamed.
- For example :
-
- 100 DATA window <- This will be renamed
- 100 DATA "window" <- This will NOT be renamed
-
-
- ----------------------------------------------------------
-
-
- * Pointless lines.
-
- Don't use pointless lines to separate PROCedures etc.. Use blank/commented
- lines instead, else Squish will attempt to rename the text inbetween
- (should you ask Squish to "Rename Variables", but not "Remove REMs etc."
- first.)
-
- Eg. :
-
- ENDPROC
- :
- : --- Routine to read TIME --- <- Squish will assume these are VARIABLEs
- :
- DEF PROCget_time
-
- The annotation of programs using REM statements is the correct method. So,
- to implement the above example :
-
- ENDPROC
- :
- : REM Routine to read TIME <- Correct style, acceptable by Squish
- :
- DEF PROCget_time
-
-
- ----------------------------------------------------------
-
-
- * The EVAL problem.
-
- This refers to FuNctions like :
-
- A% = EVAL( "FNdoodah(" + STR$ input + ")" )
-
- Squish sees "FNdoodah" as a constant (quite correctly) and does not rename
- it. There are other language constructs available that can be used in place
- of this method, and should be whenever possible (particularly if the
- program is to be Squished at a later date.) Note that EVAL statements which
- use FN/PROC identifiers can be used by renaming variables WITHOUT the
- "PROCs" and "FNs" options.
-
-
- ----------------------------------------------------------
-
-
- -----------------------------------------------------------------------------
- Special Notes on !Squish for programmers (and other interested parties)
- -----------------------------------------------------------------------------
-
-
- * When determining if a line is blank, the one thing that seperates a 'dummy'
- line from a real one is if it contains a KEYWORD. The routine that checks
- for this simply scans the tokenised line for a hex value of &7F or greater.
- If this is the case, a KEYWORD is present, and the line is taken to be
- 'real', regardless of whether or not it is ever executed.
- The exceptions are lines that consist of a '*' command, a line containing a
- return assignment (eg. =result$), or a line consisting solely of '[', or
- ']', as these are all valid lines containing no KEYWORDs.
-
- * When removing SPACEs from a line, there are many conditions whereupon a
- single SPACE must be left so that the BASIC interpreter can make sense of
- what is going on. For an example, Squishing 'X = Y NOT Z' can only be
- Squished to 'X=Y NOTZ', because taking the remaining SPACE out results in
- the BASIC interpreter recognising this as an assignment, as opposed to a
- logical operation. Although Squish doesn't take all of these conditions
- into account, it still provides a more than adequate reduction rate.
-
- * Note that recognising if you are in Assembler or not depends entirely
- upon how many '[' and ']' signs have been encountered, and when Squishing
- assembler commands, all statements are left with a single SPACE between
- each field of the statement. ';' comments are also deleted.
- (Although the idea of Squish is to Squish BASIC programs, the assembler
- Squisher has been included to improve those programs that use small amounts
- of ARM code, just to please those who like to do so.)
-
- * To remove REM statements, Squish scans the tokenised line for the Hex
- value for 'REM'. If this is found, the line is shortened appropriately.
- This works fine, but there is one occasion when this doesn't work, and that
- is when you put a REM statement after a DATA statement, as the interpreter
- stores this as a string, failing to tokenise it.
-
- * As mentioned above, everything following a DATA statement is stored as pure
- ASCII, and the same also applies to REM statements, so if you concatenate a
- program without removing REM statements, if 2 (or more) REMs are Squished
- together, the supplementary REMs are de-tokenised into ASCII form, which is
- why Squished REM statements look a little weird.
-
- KJS (08-08-90) - Release version 1.00
-
-
- -----------------------------------------------------------------------------
- History file
- -----------------------------------------------------------------------------
-
-
- * Amended the blank-line removal code to account for OTHERWISE statements
- being present [OTHERWISE->&7F]
- * Restructured logic format for IF... statements. Previously 'dead' logic has
- now been redesigned to cope with IF... statements without THENs.
- * Additional logic to ensure 'OTHERWISE' keywords start on a new line.
-
- KJS (10-08-90) - Release version 1.01
-
-
- * Inserted additional code to rename variables.
-
- KJS (21-09-90) - Release version 1.02
-
-
- * Variable renamer now copes with ARM code, and instructions are not
- treated as variables. (eg. LDMEQIA.)
- * RESTORE statements are left alone (BASIC encodes ensuing pointers), making
- renumbering possible after compaction.
- * Labels such as '.Address' are not treated as an ADD instruction (variable
- code used to check the ADD part and be fooled by this.)
- * Option of fast/slow compaction inserted. Slow allows Squish to compact as
- a background task, whilst fast allows Squish to control the system during
- compaction.
- * Renaming code altered to produce liberally-spread variable names, a feature
- from the old BBC days, as the interpreter takes less time to identify the
- variable it wants.
-
- KJS (25-09-90) - Release version 1.03
-
-
- * Additional code added so that semicolon-text in Assembly language is not
- treated as variables (if you Squish a program using the rename variable
- option WITHOUT removing REMs etc., REMarks in Assembly language were
- renamed)
- * Additional code also added to the renaming procedures, since, when using
- Assembly language, AND and EOR instructions are tokenised as if they were
- BASIC instructions.
-
- KJS (03-10-90) - Release version 1.04
-
-
- * Logic in the SPACE-Squishing procedures restructured for DIM statements.
- * Save-over-original option altered to a 'final-info' one, so that the old
- and new program-length, and the compression rate, may be seen.
- * Procedure that removes SPACEs rewritten to be a lot speedier.
-
- KJS (22-10-90) - Release version 1.05
-
-
- * Additional code added to cope with the BY keyword used in conjunction with
- certain graphic commands. BY itself is stored as ASCII text straight after
- the tokenised graphic keyword.
-
- KJS (25-10-90) - Release version 1.06
-
-
- * Algorithms completely rewritten in ARM Code.
- * Algorithms VASTLY improved.
- (Has competently Squished everything tried so far.)
- * Windows redrawn from scratch.
- * User interface completely rewritten in C.
-
- KJS (22-08-91) - Release version 2.00
-
-
- * User interface
- - bugs sorted out.
- - made completely !Help compatible.
- - pause facility / swap between fast & slow options implemented
- - etc. etc.
-
- Izzy (26-10-91) - Release version 2.10
-
-
- * ARM and C interface recoded to allow >8k programs to be loaded and have
- their variables compacted. Filename extraction for in-memory-data-transfers
- implemented (so why doesn't everyone else use it?)
-
- Izzy (23-11-91) - Release version 2.11
-
-
- * Problem with 'flex_midextend' cured by using 'flex_extend' instead.
-
- Izzy (24-12-91) - Release version 2.12
-
-
- * 'Rename under flex' bugs solved. Only ALI-vars still remain a problem.
-
- KJS (31-12-91) - Release version 2.14 (2.13 is unlucky, man!)
-
-
- * DIV and MOD spacing problems removed (why had I not noticed this before?)
- All variables now forced to lower-case to remove FN/PC/IF/ON problems
- (why had I not noticed this either?!)
-
- KJS (12-01-92) - Release version 2.15
-
-
- * Renaming of program variables vastly restructured. Now renames ARM Code
- variables properly, without renaming shift mnemonics. Help file redone
- to a more 'serious programmer attitude' style ... NOT!
-
- KJS (26-01-92) - Release version 2.16
-
-
- * Minor modifications to run under RISC OS 3.10
-
- Izzy (18-12-92) - Release version 2.17
-
-
- * Major modifications to run under RISC OS 3.10. Squish can now save without
- constantly falling over.
-
- Izzy (07-01-93) - Release version 2.18
-
-
- * Help system rewritten. Templates generally 'tidied' up. Modification to
- SPACE remover to correctly handle removal of multiple SPACEs within
- particular DIM statements.
-
- KJS (08-01-93) - Release version 2.19
-
-
- * ERROR EXT problem solved. OPT problem solved, specifically renaming of 1
- character pass variables. Register renaming solved. Can now rename ARM
- registers that have been assigned to 1 character variable names. Anomalies
- with C interface (WIMP drags, IMDTs etc.) solved. Validation of BASIC file
- included, as per !Edit. BackDrop icon created. Adjust click on main window
- forces filer window to appear.
-
- KJS (11-01-93) - Release version 2.20
-
-
- * REM removal code rewritten. Squish can now remove comments from ARM
- assembler correctly. (Assembler can have further statements after a
- comment, BASIC can't.)
- * Variable renamer changed to cope with the rewritten REM code. Can now
- rename variables AFTER concatenation, without renaming all the embedded
- ARM comments.
- * Save routines now made more robust.
-
- KJS / Izzy (13-01-93) - Release version 2.21
-
-
- * C interface updated. RAM transfers work correctly. Interface examined for
- consistency.
- * ARM routines compared to BASIC CRUNCH command - ARM routines found to be
- somewhat better.
- * Save routine now suffixes filename with S or Q as appropriate. Code fixed
- to prevent renaming ARM variables that begin with a register definition
- (eg. "r13pointer"). Problem with *commands solved.
-
- KJS / Izzy (19-01-93) - Release version 2.22
-
-
- * A 'bug' in the "Pause" feature removed. If squishing is paused, pressing
- either the Cancel or the Fast icon failed to reset the Pause status, and
- subsequent icons reflected erroneous states.
-
- KJS (24-02-93) - Release version 2.23
-
-
- * SERIOUS problem in the messaging system removed, which had only became
- apparent after release RISC OS 3.10 was fitted. Option added to the Rename
- algorithm to allow suppression of renaming PROCEDURE and/or FUNCTION
- identifiers.
-
- KJS/Izzy (25-02-93) - Release version 2.24
-
-
- * Dialogue box handler code completely re-written. Squish can now be quit
- from the menu without a problem. Modified RAM save routine slightly -
- now if you save using an in-memory data transfer the data is considered
- safe. It will be up to the other package to warn the user that the data
- is unsafe, since Squish will by now have effectively finished processing.
- * Bug in rename variables fixed. If a *command was part of an IF...THEN
- construct, it was renamed.
-
- Izzy (01-03-93) - Release version 2.25
-
-
- * Put in code to differentiate between a PREQUIT message being application
- specific / a general desktop shutdown routine.
-
- Izzy (02-03-93) - Release version 2.26
-
-
- * Completely re-wrote dialogue box code. All dboxes now self-centre across
- MODE changes.
- * Changed the code back so that in-memory data transfers are NOT considered
- safe.
- * Options for squishing are now automatically displayed if none are selected
- when attempting to squish a program.
- * Messages file and templates tidied up. Help messages for menus taken out
- as not supported by the current C compiler.
-
- Izzy (03-03-93) - Release version 2.27
-
-
- * Squish will now intelligently deal with an attempt to quit the program.
- * The RISC OS desktop boot file facility is also now supported.
- * Extra code inserted to allow identifiers to be 'locked' from renaming.
- Principally, this allows libraries to have global PROC/FN/vars exported
- to individual RunImages without the need to concatenate, also retaining
- their uncompressed format. The syntax for listing identifiers is held
- within REM statements in the source program, as per example :
-
- 100 REM LOCK <identifier 1> , <identifier 2> , ... , <identifier n>
-
- so a WIMP program which uses a global WIMP procedure library may
- have a LOCK statement something like this :
-
- 100 REM LOCK PROCopen_window , PROCclose_window , WINDOW% , ICON_TEXT$
-
- Of course, both the main RunImage AND the library itself will need to have
- a copy of the LOCK statements, else one will have it's identifiers renamed
- and the other won't. Also note that subscripts must be omitted, so a LOCK
- cannot have something like this :
-
- 100 REM LOCK PROCedure_OpenWindow( x% ) <- the "( x% )" should be
- omitted from this line
-
- KJS/Izzy (17-03-93) - Release version 2.28
-
-
- * C interface now allows multiple re-squish attempts without losing the list
- of LOCKed variables. Also advises when re-squishing may be advisable due to
- lack of memory when renaming variables.
- * All calculations on savings are now based on the original program size.
- * Help now given on SAVE dialogue box.
-
- Izzy (18-03-93) - Release version 2.29
-
-
- * Bug in variable renamer fixed. One character identifiers caused problems
- in some places, especially in the third opcode field, in use as an
- immediate (eg. #X).
-
- KJS (19-03-93) - Release version 2.30
-
-
- * Put in new save routines to use the drag-a-sprite facility.
-
- Izzy (21-03-93) - Release version 2.31
-
-
- * Iconise facility implemented fully. Now when iconised, Squish will
- continue to process the BASIC program. When finished the iconbar
- sprite will change to indicate that the process has been completed,
- but that the window is still iconised. Double click on the iconised
- window to continue. Also fixed minor bug when using ADJUST on the
- close window icon to open the programs directory.
-
- Izzy (01-04-93) - Release version 2.32
-
-
- * Patch over initialisation routines to cope with new Wimp_Initialise
- specification, as C library doesn't allow for this.
-
- Izzy (03-04-93) - Release version 2.33
-
-
- * Patch over 'wimpt' routines. Had to insert our task handle into the
- 'wimpt' routines workspace directly, as Acorn have forgotten to tell
- us that 'xfer_send' uses, for in memory data transfers, the 'wimpt_task'
- function - which meant that Squish version 2.33 fell over when doing
- in-memory data transfers.
-
- Izzy (06-04-93) - Release version 2.34
-
-
- * Put in hourglass routines to include the LED indicator and changed
- message warning order when you attempt to Squish a program.
-
- No LED : Initialising general internal routines,
- Top LED : Extracting LOCK information,
- Bottom LED : Initialising variables.
-
-
- * SYS reduction code altered, so that renaming of OS_WriteC (SYS &0)
- does not have it's only zero stripped off by the leading_zero code.
-
- KJS/Izzy (07-04-93) - Release version 2.35
-
-
- * Fixed * command bug.
-
- KJS (15-04-93) - Release version 2.36
-
-
- * Adjusted !Run file so as not to re-instate a CLib that is already active.
-
- Izzy (10-05-93) - Release version 2.37
-
-
- * Removed bug in EOL removal code. Now removes EOL rubbish, without also
- removing out of bound characters at the end of a * command.
-
- KJS (29-07-93) - Release version 2.38
-
-
- -----------------------------------------------------------------------------
- Special note
- -----------------------------------------------------------------------------
-
- * After concatenation, although the tokenised line may be less than or equal
- to 255 bytes long, the UNtokenised may be a lot longer. BASIC editors do
- not like this (sad isn't it?) and kick up errors of the sort : 'Line xxxx
- is too long to be edited.'. Please note that this is not a 'bug' with
- Squish, but a limitation of the editors.
-
- ------------------------------ End Of Help File -----------------------------
-