** THE OSI ASSEMBLER EDITOR ** The ASSEMBLER EDITOR allows you to enter machine-language programs using the OPCODES instead of the actual machine numbers. The use of this program is straightforward but there are several special features, which allow this program to be versatile. The top-level commands are: I = INITIALIZE program (Y/N) - erases any previous program and starts out at the beginning of the workspace. A0 (or A) = Assemble program, displaying the listing and any errors detected on the screen. A1 = Assemble program and display only the errors. A2 = Assemble program and make a CHECKSUM listing. (This can be re-loaded (using a checksum loader) and executed.) A3 = Assemble to memory directly at location specified in program. ** WARNING THIS DOESN'T HAVE ANY PROTECTION FROM WRITING OVER THE ASSEMBLER OR SOURCE CODE! ** R = Renumber program. Renumbers starting from the first line stepping by 10s. D = Delete (line or lines). After the D type in the lines to be zapped. Like this "D100-150" or "D10,20,130-200" etc. P = List program. This lists the source file. You can list individual lines, several individual lines (like Delete), or the whole thing (just P). Once started you must wait until it is done listing to do anything. S = Set SAVE mode. Turns on save mode-- all subsequent printing is done to the Cassette as well as the screen. Use it to save your (A2) CHECKSUM program, or your (P) source code.(for future use) L = Load mode. When in load mode, input is from cassette. To exit, hit spacebar. The editor commands are: [Shift] O = delete character, [Shift] N (^) = delete line, [CTRL] I = TAB. This concludes the top-level commands, the rest are the Assembler functions There are four ways of entering constants for use in the assembler editor. They are BINARY, OCTAL, DECIMAL, & HEX, and each have a special way of telling the assembler what type they are: All binary numbers are preceded with a "%". A typical number may look something like - %01001111 All octal numbers are preceded by a "@". Such a number may look like - @237 All decimal numbers are entered by themselves with no special 'flags'. Finally all HEX numbers are preceded with a "$". For example - $4F. The last type of constant is a character string constant these use a " ' " to denote them. For example 'this is a character string constant' In 6502 machine code there are 13 addressing modes (refer to a 6502 machine lang. handbook) these are examples of each: Accumulator - LSR A IMMEDIATE - LDA #$00 ZERO PAGE - LDA $03 ZERO PAGE,X - LDA $03,X ZERO PAGE,Y - LDX $20,Y ABSOLUTE - LDA $FFEE ABSOLUTE,X - LDA $FFEE,X ABSOLUTE,Y - LDA $FFEE,Y IMPLIED - CLC RELATIVE - BCC *-10 (INDIRECT,X)- LDA (FE,X) (INDIRECT),Y- LDA (FE),Y ABSOLUTE INDIRECT - JMP ($FFF7) Where ever you have a number or an address say like $FE00, you can replace the actual address with a LABEL. Labels can be an actual place in your program, or an assigned value. They can be composed of any character A-Z , 0-9, . and : but they must be less than seven characters long, and MUST begin with a A-Z! The only predefined label is the "*" which refers to the current value of the location counter through out an assembly. You use this to set the address of where you program will be located (like at the top- *=$2000, where $2000 is the starting address of your program). You also use it as the 'current' program counter. Suppose you want to jump to a place in your program 10 bytes away from where you are. You would simply say 'JMP *+10' - note it points to the beginning of the currently executing command. That means you include the length of the instruction (2 bytes,3 bytes, whatever) when you go down (like JMP *+10) and don't include the length of the instruction when you jump up (it would read 'JMP *-7' cause the JMP instruction is 3 bytes long! and the pointer points to the front of the command.) EXAMPLE PROGRAM ;This is a comment 10 *=$2000 ;set the prog to start at $2000 20 LDX #$00 ;puts a 0 in the 'X' register 30 CPX #$0F ;checks to see if X = 0F (15) 40 BEQ END ;notice END is a label ,the prog will goto end if X=0F 50 INX ;increment x 60 JMP *-5 ;jumps back to the CPX statement 60 END=* ;setting the address of the label 70 RTS ;return from subroutine. EXPRESSIONS are evaluated strictly from left to right and include +,-,*,/ . Do not confuse this "*" with the label "*". As seen above, instruction statements are of the following form- (lable) (opcode) (operand) (comment) At least one space must exist between fields. Directive statements (not 6500 instructions) are used to define numeric and character string constants, to set the program origin (see above), reserve space, and equate labels to values. All directives begin with a period and appear in the opcode field of a directive statement. The directive may be preceeded by a lable, and must be followed by an appropriate operand. The operand may be followed by any comment desired. The fields are (label) (directive) (operand) (comment) where label and comment fields are optional. .BYTE - used to generate single byte numerical constants and character string constants of any length. EXAMPLE .BYTE 0 .BYTE %10,#C6410,10,$10,'10',TEN MESG .BYTE 'MESSAGE',255,'.',$D .BYTE SIZE+1 .WORD - used to generate two byte numerical constants in low, high order by byte (used for machine addresses) EXAMPLE .WORD $ABCD .WORD START,START+2 .WORD 10,100,1000,10000 .DBYTE - used to generate two byte numerical constants in HIGH,LOW order by byte. EXAMPLE .DBYTE $ABCD .DBYTE START,START+2 .DBYTE 10,100,1000,10000 = Directive - used to set program origin, reserve space and equate labels to values. Each uses a distinct statement form and are shown below. SETTING THE PROGRAM ORIGIN LOCATION Statement form *= expression EXAMPLE * = $0300 * = START * = LAST+15 RESERVING SPACE Statement form *=*+expression (Label is optional) or *=expression+* EXAMPLE * = *+1 TABLE *=*+125 EQUATING LABELS TO VALUES Statement form label = expression EXAMPLE TEN=10 START=$8C00 SIZE=XDIM*YDIM In all forms of the equals directive, all labels used in an expression must be previously defined in the assembler source file or the assembler cannot determine the location of subsequent labels during pass one of the assembly. This can result in "lable previously defined" errors (error 12) for the subsequent labels during pass two. ---ERROR CODES--- 1 - A,X,Y,P,S are reserved names 3 - ADDRESS NOT VALID an address greater than (FFFF) hex or 65535 decimal was found. 4 - FORWARD REFERENCE IN EQUATE, ORIGIN, OR RESERVE DIRECTIVE an expression used in one of these directives includes a label that hasn't been previously defined in the assembly source file. 5 - ILLEGAL OPERAND TYPE FOR THIS INSTRUCTION an operand was found which is not defined for the specified instruction opcode. Refer to manual for the defined instructions and addressing modes. 6 - ILLEGAL OR MISSING OPCODE a defined opcode was not found. See manual 7 - INVALID EXPRESSION an expression was found that is not a valid sequence of numerical constants and/or labels separated by valid operator or is not a valid instruction operand form. 8 - INVALID INDEX- MUST BE X OR Y 9 - LABEL DOESN'T BEGIN WITH ALPHABETIC CHARACTER a non alphabetic character was encountered where a label was expected. 10- LABEL GREATER THAN 6 CHARACTERS a string of more than 6 valid label characters (A-Z,0-9,$,.,:) was found before a non valid label character. This is a warning message, assembly will continue using the first 6 characters. 12- LABEL PREVIOUSLY DEFINED 13- OUT OF BOUNDS ON INDIRECT ADDRESSING an indirect-indexed or indexed-indirect address does not fall into page zero as required. 14- 15- RAN OFF END OF LINE an operand is required and wasn't found before end of line. 16- RELATIVE BRANCH OUT OF RANGE target address of a branch instruction is farther away than minus 128 to plus 127 byte range as the instruction permits. 18- UNDEFINED LABEL the identified label is not defined anywhere with in the assembler source file. 19- FORWARD REFERENCE TO PAGE ZERO MEMORY this warning message is generated when an instruction that has both zero and absolute addressing modes has an operand that is defined later in the assembler source file to be a page zero address. During pass one the assembler set aside two bytes for the operand since its value is not yet known. Then during pass two the operand is found to require only a single byte, so one byte is wasted. This is not a serious error because the generated code will generally execute as expected. 20- IMEDIATE OPERAND GREATER THAN 255 an immediate operand expression was evaluated to be greater than 255, the maximum value that can be represented in a single byte immediate operand. 25- LABEL(SYMBOL) TABLE OVERFLOW size of workspace is insufficient to hold current source file and a table for all of the labels encountered in the program. To assemble will require a reduction in either the size of the program source file or the number of symbols or an in{rease in the size of the workspace. Memory locations of interest. $1300 G - To enter from the monitor Program uses $0240 to $1391, source file is contained $1391+ $12C9, 12CA Start of source file (lo,hi) $12CB, 12CC End of source file $12FC, 12FD Used to bias the placement of obj code during A3 assembly, 0 as supplied $12FE, 12FF End of source file automatically incremented as text is entered