FULL SCREEN EDITOR/ASSEMBLER PLUS 80 ==================================== Oxford Computer Publishing, 1983 written by James Hutchby APPENDIX 1 ---------- COMMAND SUMMARY --------------- The keyboard - Unshifted keys give lower case letters and numbers; CAPS SHIFT'ed keys give upper case letters and cursor movement & control functions. Toggle caps lock status with CAPS LOCK key. SYMBOL SHIFT'ed keys give subsidiary red single-character legend. All keys auto-repeat if held down. NORMAL EDIT MODE (blinking cursor) Moving the cursor:- Left Arrow - left one column Down Arrow - down one line Up Arrow - up one line Right Arrow - right one column TRUE VIDEO - up one page (24 lines) INV. VIDEO - down one page (24 lines) ENTER - right to next tab stop (next field) CAPS SHIFT'ed ENTER - left margin of next line down Changing characters :- type new text over old text. Deleting characters :- use DELETE key. Inserting characters :- press GRAPHICS key and cursor stops blinking. Type in new text. Use Right Arrow key to insert spaces up to next tab stop and Left Arrow & DELETE keys to backspace. Press ENTER to exit insert mode. Cancel changes :- Press EDIT key and all changes made to a line are cancelled. Cursor placed on first character. LINE COMMANDS ------------- Press both shift keys on desired line. Line is highlighted. Next key pressed determines function to be performed:- CAPS SHIFT + SYMBOL SHIFT - Aborts line command. D - Deletes line or block of lines. I - Enters line insert mode and cursor stops blinking. Type in text. Use Right Arrow key to insert spaces up to next tab stop and Left Arrow & DELETE keys to backspace. Press ENTER to insert another new line. Press both shift keys to exit line insert mode. C - Marks line or block of lines for copying. M - Marks line or block of lines for moving. H - Moves or copies line or block of lines to here. B - Marks line as block terminator. ENTER - Cancels pending move/copy & deletes block markers. T - Displays from top of text buffer. E - Displays last line in text buffer. F - Repeats last entered (F)ind extended command. SPACE - Invokes extended command processor. EXTENDED COMMANDS ----------------- Press both shift keys and then the SPACE key to enter extended command mode. Type in command at base of screen and press ENTER to execute it. Press ENTER on an empty line to abort extended command. Nstart,inc - Renumbers every line in the text buffer. Gnumber - Searches for the specified line from the top of the display onwards. Fstring - Searches for the specified string from the top of the display onwards. Cstring - Changes all occurrences of the previously specified (F)ind string to this string. C - Deletes all occurrences of the previously specified (F)ind string. MEM - Displays free memory length and start address. BASIC - Returns to Spectrum's BASIC interpreter. CLEAR - Clears the text buffer and 'delete protects' symbols. MCTT - Calls Machine Code Test Tool. RUN - Branches to the first address in the object code buffer. Pnumber - Prints a number of lines starting with the line at the top of the display. P - Prints the rest of the text buffer. Sfilename - Saves the text buffer to tape. S - Saves the buffer with default filename 'SourceCode'. Lfilename - Loads a file from tape into the text buffer. L - Loads the next file on tape. Xfilename - Appends a file to the text buffer. X - Appends the next file on tape. Vfilename - Verifies a file with the text buffer. V - Verifies the next file on tape. Afilename/s1/s2/s3... - Invokes the assembler with switches s1,s2,s3... active. A/s1/s2/s3... - Invokes the assembler with default filename 'ObjectCode' and switches s1,s2,s3... active. Assembler switches ------------------ /NO - Suppress output of object code to tape. /NS - Suppress symbol table listing or printout. /NL - Suppress assembly listing or printout. /LP - Output symbol table and assembly listing to line printer. /WE - Wait on errors until key pressed (C cancels). /IM - Assemble object code directly into memory. /AO - Assemble with absolute origin. /OS - Assemble using old symbol table. PRINTING HARD COPY ------------------ To summarise, there are three ways in which you can produce hard copy printout: (a) With the /LP switch active during an assembly. (b) With the P extended command. (c) Pressing SYMBOL SHIFT and F or G from MCTT. Note that the BREAK key (CAPS SHIFT and SPACE) can be used at any time to cancel a printout, even if a print function is invoked and no printer is connected. ********** 4.10 VALUE OPERANDS ------------------- Operands with numeric values are coded as constants or expressions. The range of values for an operand is determined by the instruction it is associated with. For example, in the instruction LD HL,nn 'nn' can be any 16-bit value, whereas in the instruction LD A,n 'n' can only be an 8-bit value. Certain instructions are even more restrictive - for example, in the instruction IM i 'i' is only valid as 0, 1 or 2. Constants A constant can be expressed as a symbolic label, the location counter symbol $, a character string or a numeric value. a) Symbolic labels Every symbol in a program has a value set to it during the assembly (set to zero if there is an error in its definition line). The syntax of a symbol name has already been discussed. b) Location counter - $ The $ character may be used to represent the current value of the assembler location counter - that is the address at which the next byte of object code will be (logically) stored. e.g. JR $ will put the C.P.U. in an infinite loop. c) Character strings Character string constants may be used if enclosed by single quotes ('). The string is right justified (that is to say that all but the rightmost two characters are ignored) and is evaluated as a 16-bit constant based upon the ASCII codes of its characters. Embedded single quotes are represented by two in succession. Examples: LD A,'a' loads the accumulator with 61H. LD A,'''' loads the accumulator with 27H. LD HL,'ab' loads the HL register pair with 6162H. d) Numeric constants The assembler recognises four types of numeric constant, namely binary (base 2), octal (base 8), decimal (base 10) and hexadecimal (base 16). A numeric constant consists of a string of numbers (0 to 9) or hexadecimal digits (0 to 9, A to F) followed by a base determiner. This suffix specifies the type of the constant as follows:- B = binary OorQ = octal D = decimal (default base) H = hexadecimal If no base determiner is present the assembler assumes the constant to be decimal. The following numeric constants are all equivalent - 10010B, 22O, 22Q, 18,18D,12H. Note that hex numbers which start with a letter MUST be prefixed by a zero or the assembler will assume you are using a symbol e.g. FFH is invalid, write as 0FFH. All constants are stored internally using 16 bits. Numbers greater than 65535 are accepted but any overflow from them is lost. 4.11 EXPRESSION EVALUATION -------------------------- The assembler features a very powerful expression evaluator. Symbols, constants and operators can be combined in any order to produce complex expressions. These greatly simplify the programmer's task by automatically generating such things as table lengths, string lengths, constants, addresses and other data. As a general rule, an expression can be substituted in any instruction that would otherwise take just a simple numeric operand. The operators that may be used in expressions are shown below. Associated with each operator is a precedence level - this determines the order in which operands are combined within an expression to produce a result. Operators of high precedence evaluate before operators of lower precedence - operators of equal precedence evaluate from left to right. The order of evaluation can, however, be controlled by the inclusion of parentheses (brackets). OPERATOR FUNCTION PRECEDENCE = equals 1 lowest <> not equals 1 precedence > greater than 1 < less than 1 >= greater than or equal 1 <= less than or equal 1 + addition 2 - subtraction 2 OR logical or 3 ! logical or 3 XOR logical exclusive or 3 AND logical and 4 & logical and 4 * multiplication 5 / division 5 MOD modulo 5 NOT 1's complement 6 highest ( ) parentheses 7 precedence Notes: (i) Comparison operators (the first six of the above) compare two terms and give -1 if the result is true and 0 if it's false. e.g. 7 > 4 gives -1, 9 <= 1 gives 0, 7 <> 6 gives -1. (ii) Logical operators are bitwise in operation, that is they act upon each of the 16 bits in each of their two terms in succession to give a 16 bit result. e.g.1100110B AND 1001011B equals 1000010B, 1110110B OR 0110001B equals 1110111B, 1101101B XOR 1001100B equals 0100001B. (iii) Division is integral, the fractional part being lost. Multiplication is 16 bit, overflows are not detected. e.g. 7/2 equals 3, 0FFFFH * 2 equals 0FFFEH. (iv) The modulo operator gives the remainder result of a division. e.g. 23 MOD 7 equals 2. (v) The NOT operator is a unary operator, it gives the one's complement of a single number (1's = > 0's = > 1's). e.g. NOT 10011011B equals 1111111101100100B. (vi) Parentheses may be used to group parts of an expression together to force those parts to be evaluated first. In effect they override the fixed precedence levels. Operations of the same precedence are applied from left to right across an expression. . (vii) Parentheses may be nested to any depth. e.g. (1*(2+(3*(4+5)))) equals 29. (viii) The first operator in an expression cannot be a left parenthesis e.g. LD A,(4*8)+3 is invalid and will cause an error. Rewrite as LD A,3+(4*8). (ix) An expression such as 1010AND0111 will generate an error message because the assembler assumes the 'A' in 'AND' to be part of the first constant. To avoid this problem, rewrite the expression as 1010 AND 0111. 4.12 PSEUDO-OPCODES ------------------- Recall that the opcode field of a line of source code contains a mnemonic for one of the Z-80's instructions. In addition the assembler recognises certain other mnemonics in this field called pseudo-opcodes or pseudo-ops. These are not machine executable instructions but rather directives to the assembler to perform specific operations, set up data structures etc. Labels are compulsory on DEFL and EQU statements but optional on other pseudo-op statements. ORG - ORiGin. This pseudo-op takes a single number or expression as an argument and sets the assembler location counter to the value of this operand. If a label is present on an ORG statement, it takes on the value of the counter before its modification. Although ORG statements can appear anywhere in a program listing, it is considered good practice to define an origin in the first line. For example the statement ORG 1234H sets the assembler location counter to the value 1234 hexadecimal and subsequent instructions produce object code designed to run at this address. The statement ORG $+100 reserves a hundred bytes of storage (equivalent to DEFS 100 - see below). Note that if you assemble your program with the 'into memory' switch active no ORG statements are necessary. The assembler automatically produces object code at the first free address in the system. END - This pseudo-op simply marks the end of the assembly source code. It takes no arguments and its inclusion in a program is optional but if present then all lines following the END statement are ignored by the assembler. The next three pseudo-ops generate byte(s) of data at the current assembly location rather than machine code instructions. Data structures produced by these directives can be used as general constants, messages, look-up tables etc. DEFB or DB - DEFine Byte. This pseudo-op takes 8-bit numbers or expressions as arguments and stores the values of the operands at the current assembly location (and increments the location counter by one). Multiple arguments are accepted if separated by commas. For example the statement DEFB 10,0FFH,'a' generates three bytes of object code -10, 255 and 97 decimal. If the value of an operand is greater than 255 or less than -256, a "FIELD OVERFLOW" error is signalled and only the low order 8-bits are stored. DEFW or DW - DEFine Word. This pseudo-op takes 16-bit numbers or expressions as arguments and stores the values of the operands at the current assembly location (and increments the location counter by two). Standard Zilog format is employed with the low-order byte being stored before the high-order byte. Again multiple arguments are accepted if separated by commas. For example the statement DEFW -1,1000H,10 generates six bytes of object code -255, 255, 0, 16, 10 and 0 decimal. DEFM or DM - DEFine Message. This pseudo-op takes a string as an argument and generates object code bytes corresponding to the ASCII codes for the characters in the string. The string must be enclosed by single quotes (') and, as usual, embedded single quotes are represented by two in succession. For example the statement DEFM 'Hello' generates five bytes of object code - 72 101, 108, 108 and 111 decimal; the statement DEFM '"a"' generates three bytes of object code - 39, 97 and 39 decimal. DEFS or DS - DEFine Storage. This pseudo-op takes a single number or expression as an argument and reserves a number of bytes for data storage. In effect the location counter is incremented by the value of the operand. For example DEFS 5 sets aside five bytes. If a label is used on this statement it takes on the value of the location counter prior to the incrementing operation. No object code is generated by this pseudo-op. EQU and DEFL (or DL) - These next two pseudo-ops do not generate any object code but instead assign values to symbols. Both require labels in their statements and both take a single number or expression as an argument. The symbolic label specified is set to the value of the operand specified. The distinction between EQU and DEFL pseudo-ops is that the same label may be DEFL'ed many times to different values in the same program while an EQU'ated label may only be set once. Note that in the assembly listing the value assigned to the symbol appears in the first column rather than the current value of the location counter. For example COMMA EQU 44 defines a symbol with the name 'COMMA' and gives it the value 44 (the ASCII code for a comma). When referring to this value in a program use the symbolic form LD A,COMMA rather than the absolute form LD A,44 to aid clarity and understanding. LABEL EQU $ assigns to LABEL the current value of the assembler location counter. A symbol defined initially by a DEFL directive can be subsequently re-defined by either a DEFL or an EQU directive but cannot be re-defined as an ordinary label. Only the last value of a DEFL symbol will appear in the symbol table listing. PAGE - This pseudo-op causes the line printer to print blank lines to the top of the next page. It takes no argument. HEAD - This pseudo-op takes a string surrounded by single quotes (') as an argument, i.e. similar to the DEFM pseudo-op. The string operand is printed at the top of each page, and thus can be used to title a program. Note that HEAD statements can appear anywhere in the source code. Statements containing the above two pseudo-ops do not appear in the line printer listing but do appear in the screen listing. LIST OFF and LIST ON - This pseudo-op toggles the output of hardcopy to the line printer when the /LP switch is active. A LIST OFF statement causes subsequent assembly lines to appear only on the screen. A LIST ON statement causes subsequent assembly lines to appear on the line printer (if /LP set) as well as the screen. - Most assembler programs contain a number of EQU statements to define the values of any constants used. These are usually grouped together, either at the start of a program, or at the end. A typical use for the LIST pseudo-op would be to suppress the printout of these EQU'ates when a hardcopy of an assembly is taken. WAIT - This pseudo-op pauses an assembly, prints the message "PRESS ANY KEY TO CONTINUE THE ASSEMBLY" on the bottom line of the screen, and then waits for a key to be pressed. It takes no argument. Note that a WAIT statement takes effect on both passes of the assembler. INCL - This powerful pseudo-op instructs +80 Editor/Assembler to begin assembling from a named microdrive file. In effect, the specified file is INCL'uded in the text buffer at the specified point. The real advantage of this is that much larger programs can now be assembled than could ever be contained at any one time in the text buffer. For example the source code of a large program could be split up into a number of individual modules with, say, filenames "module 1 ", "module 2" and "module 3". An 'executive' program such as the one below could then be used to assemble the entire program in one operation with all cross-references between the modules fully resolved (unlike the /OS switch which can only be used for 'backward' references). 00010 ORG 8000H 00020 INCL module 1 00030 INCL 1module 2 00040 INCL 2module 3 00050 END Note that each file is loaded on each pass of the assembler, and that any microdrive error will abort the assembly. Remember that END pseudo-ops are used to mark the end of assembly source code. If the individual modules of programs contain END statements, be warned that these may lead to the premature termination of an assembly. As a general rule, therefore, END statements should be confined to the executive level. If the modules of a program are spread across several microdrive cartridges, WAIT pseudo-ops can be used to facilitate the assembly of the whole program in one operation. For example: 00010 ORG 8000H 00020 WAIT ; first cartridge 00030 INCL Source1 00040 WAIT ; second cartridge 00050 INCL Source2 00060 END The user must insert the correct cartridges into the microdrive in the correct sequence in response to the "PRESS ANY KEY . . ." prompts. In the above example, this will involve four cartridge 'swaps' in all (two on each pass). Default drive number for INCL statements is drive 1, but note that there is no default filename. Also note that comments should not be used on INCL lines as they are treated as part of the filename. Finally note that INCL files cannot be nested. Users of 80 column printers and interfaces should note that the assembler automatically paginates its hardcopy output, and prints a page number at the top right hand corner of every sheet. The following two pseudo-ops are available to these users (NB. they have no effect if a 32 column ZX printer is connected). PAGE - This pseudo-op causes the line printer to print blank lines to the top of the next page. It takes no argument. HEAD - This pseudo-op takes a string surrounded by single quotes (') as an argument, i.e. similar to the DEFM pseudo-op. The string operand is printed at the top of each page, and thus can be used to title a program. Note that HEAD statements can appear anywhere in the source code. In addition, +80 Editor/Assembler patches MCTT to enable it to support an 80 column printer. Pressing the SYMBOL SHIFT and the F or G keys at any time will copy the screen to the line printer. The F key prints on the left hand side of the paper while the G key prints on the right hand side. Note that the BREAK key (CAPS SHIFT and SPACE) can be used at any time to cancel a printout, even if a print function is invoked and no printer is connected. Statements containing any of the above new pseudo-ops do not appear in the line printer listing but only in the screen listing. -- End of File