ASPECT Editor/Assembler Bug-Byte Software INSTRUCTIONS FOR ASPECT The program "ASPECT 4.2", its documentation and artwork are strictly the copyright of Bug-Byte. It is illegal to make a copy of ASPECT 4.2 without authorisation from Bug-Byte and legal action will he taken against anyone found doing so. Introduction Aspect 4.2 is a combined Editor Assembler designed to aid the production of machine code programs and subroutines on the Sinclair Spectrum Computer.. Aspect 4.2 does not affect the stack pointer and temporary storage used by the Spectrum Basic Language ROM. This is a deliberate part of the design of Aspect as it is assumed that many programmers would wish to use Aspect to design machine code subroutines as "add-ons" to the existing BASIC language commands. This also allows the use of the Spectrum tape system for loading and saving both source code and object code. Getting Started If you do not already possess one, it is advisable to obtain a copy of PROGRAMMING THE Z80 by Rodnay Zaks, or a similar Z80 tutor and reference book. To run Aspect 4.2, enter: LOAD "" The first program to load is the Aspect basic bootstrap loader "aspload" which will execute automatically, load Aspect 4.2, clear the screen and then jump to execute it. The Commands Upon execution of Aspect 4.2 the commands available are as follows:- A = Assemble program Ln = goto text line number n B = Backup through text one line N = clear text buffer for NEW program Dn = Delete next n lines of text R = Return to Spectrum BASIC E = Edit current line S = Show symbol table after assembly Fn = Forward through next n lines Vn = View next n lines of text H = Hunt for line or string Wn = Show WHERE text buffer starts and I = Insert text before current line ends To enter a command just type the command letter followed by the parameter 'n' if needed. Using the Editor The Keyboard The first difference that you will notice between Aspect 4.2 and Spectrum BASIC is that the keyboard loses all of its normal multi-shifted functions. It will now perform as as ordinary alphanumeric teletype-like keyboard - the only difference is the function of the DELETE key - this has now been changed so that you have to push SYMBOL SHIFT instead of CAPS SHIFT to obtain the delete function. This was done so that it is possible to delete characters with a one-handed action. The only characters that will now work under Aspect 4.2 are those that are necessary to the editing and assembly of programs. You cannot for instance use coloured text or user-defined graphics as entries to the editor, although these facilities of the Spectrum will still work if called from your own machine code programs. User Input Errors If you make on error in the entry of a command then Aspect 4.2 will reply with the question mark [?] symbol and prompt you to enter a further command character. Editor Commands Insert ... The Insert command has two functions: the first is to allow the entry of text into on empty buffer; the second is to allow text to be inserted into the buffer at any position in the source code listing. This command always inserts text before the current line. Delete ... The Delete command allows the user to delete either the current line or the next n consecutive lines of text. (NB. Use this command carefully.) List ... This command allows the current location of the editing pointer to be altered and thus determines from which line of text all other commands perform their action. To look at a particular line of text in the buffer, type the command [Ln] where n equals the number of the particular line within the buffer; to go to the top of the buffer type [L]. View ... To look at a number of consecutive lines in the buffer type [Vn] where n equals the number of lines to scroll through. (16 is a good choice - ie. [V16] - the editor will then display the next 16 lines of text in the buffer. Backup ... This command allows the user to move the current editing pointer back through the text file; ie. to back up 5 lines type [B5]. Forward ... The Forward command allows the user to move the current editing pointer forward through the text. Hunt ... The Hunt command tells the editor to search for the given text string and set the current line number to the location of the occurrence of that string; eg- HLABEL will hunt for the word LABEL. Edit ... If a line has to be edited, the user first of all sets the current editing pointer to the line with the L command and then types E. The editor then prints the line on the screen and places the cursor at the end of it. The user may then backspace along the line to change the text. Where ... This command shows the user where the start of text, and the end of text, and memory limit are. The output is in hexadecimal numbers. New ... This command enables the user to clear the text buffer and resets the editing pointer to the top of the buffer. Return ... The Return command enables the user to return intact to the Spectrum BASIC Interpreter. To get back to Aspect 4.2 from BASIC enter: PRINT USR 24576 This will warm start the editor and your text should still be intact. Assemble ... When the source program text has been entered correctly and checked for errors, the procedure to assemble is to type the letter [A] and hit Return. The user will see the source and object listing appear on the Spectrum screen. If the program is quite large the listing can be stopped for examination by depressing any key and continued by depressing any key. Once the listing reaches the end of the program it will type the letters EOF on the screen; the object code is then in memory starting at the LOAD address. Show ... This command enables the user to print on the screen a cross reference table for all the labels in the assembly. Aspect 4.2 Syntax The syntax of the source program should be as that of the Zilog Z80 Assembly Language Programming Manual; ie- Label: Operator Operand; Comment START: LD HL,MSG1; this is a comment MSG1: DB "this is a message"; this is another comment The label should always be separated from the operator by a colon, the operator from the operand by a space and the comment should always be separated from the code by a semi-colon. Hex digits are allowed and are specified by adding an H after the number. Enter it as 0FFFFH. The symbol $ can be used to represent the program counter for relative jumps, etc. For example the jumps in the following program are all allowed. All are assembled as jumps back to the program start. ORG 7800H JP $-3 LOAD 7800H JP START START: JP 7800H END Pseudo-ops. The following operators are not part of the Zilog Z80 instruction set but are understood by Aspect 4.2. They should be used in exactly the same way as normal operators. ORG. Program origination address; eg- [ORG 08000H]. This statement sets the origin point for the program counter to work from. It may be used any number of times in the code to organise the program for different addresses. LOAD. Object code output start address; eg- [LOAD 07800H]. It is possible to set ORG and LOAD for different addresses in cases where the memory the program will finally run in is not available during assembly. You MUST include both an ORG and a LOAD pseudo-op at the start of every program; eg ORG 7800H LOAD 7800H This will assemble the code at address 7800 hex. EQU. Used to assign a symbol to a variable; eg- [SCREEN: EQU 4000H] DS. This tells the assembler that the next X locations must be allocated as defined storage space. The define space command needs to be put on a line on its own; eg- to define an area 100 bytes long, labelled DATA, use: DATA: DS 100 - do not enter it as: DATA: DS 100 DW. This generates a word or two bytes in the object file in reversed order as required by the 16-bit instructions of the Z80. DB. This operator causes all the bytes on the same line to be inserted in the output code in order; eg- [MSG1: DB 20H,24H,23H] or [MSG1: DB "this is Aspect 4.2"]. END. It is essential to terminate the assembly source code with an END statement otherwise the assembler will give an EOF error. Aspect 4.2 Memory Allocation Aspect 4.2 automatically sets itself up for the correct memory size and resides at location 24576 (decimal) or 6000 (hex). It is approximately 4K long and the text buffer start and end location can be obtained by using the W command, which will give the start of buffer, end of buffer and top of memory. There is a space of approximately 450 bytes between the end of the assembler and the text buffer for the symbol table. All of Aspect's storage and stacks are kept inside the 4K allocated to it. It is not wise to load code below about 7800H as this will affect the operation of the Sinclair BASIC. Cassette Operations Both source code and object code can be saved and loaded by using the Sinclair Basic Tape Operating System with the commands as follows:- [LOAD "filename" CODE (start address),(length)] [SAVE "filename" CODE (start address),(length)] The correct syntax and use of these commands can be found in chapter 26 in the ZX Spectrum manual. When saving listings, use the W (Where) command to find the end of the text buffer and then SAVE the CODE from the start of Aspect (24576) to the end of the text buffer. To reload, simply use: LOAD "" CODE - and PRINT USR 24576 after loading for a normal re-entry from BASIC. There is no need to load in Aspect first. Look out for other Bug-Byte programs at your local computer shop, branches of BOOTS and W.H. SMITHS, or in our advertising in the computer press and elsewhere. Think you can write a better program than this? We'd love to see it. Send a copy on cassette to: THE PROGRAMMING DEPARTMENT, BUG-BYTE, 100 THE ALBANY, OLD HALL STREET, LIVERPOOL L3 9EP - for a free appraisal of its worth, without any obligation to donate the program to our range. Or simply send an S.A.E. for details of our terms for contributed programs.