@ass by A. Fachat (fachat@galileo.rhein-neckar.de) ---------------------------------------------------------------------- @ass is covered by the GNU public License, see file COPYING 0) Preface The Programm @ass is a 2-pass 6502 Assembler. I have written this programm some years ago and I do not support it any more. I do also not take any warranty for this programm or its use in any form. The only reason I publish it now is that someone asked me for another programm that I have written with this assembler. 1) How to use To use the assembler you have to load the programm into memory as a machine programm and save it from overwriting by poking something to the basic end pointer, except if you put it to $c000. The source Code for the Assembler has to be written in the BASIC editor, i.e. you have a line number and then several assembler commands in the line, separated by colons. Each assembler command can be either a normal assembler opcode or a pseudo assembler opcode. To assemble the programm, start the source code with "RUN". The first Command in the source code has to be a "SYS Assembler_Startaddress". Then the assembler takes over. 2) Assembler opcode Allowed syntax is MOS standard, e.g. 'LDA (expression),y' or 'ADC #$02'. 3) Mathematical expressions 'expression' is a mathematical term with algebraic logic without hierarchy, i.e. the expression is being done from left to right. Watch out, no multiply before add! Brackets are ok and work as expected. valid operands are: 123 -decimal $345 -hex %110 -binary * -Programm counter # -assembler pass "a" -ASCII (bytewide) LABELX -Label -(LAB+1) -expression valid operators are: + -addition - -substraction * -multiplication / -division ! -or & -and ^ -exclusive or > -shift left argument to the right, right argument says how many bits < -shift left argument to the left before each expression you can use the following unary operands > -take the high-byte of the result < -take the low-byte of the result ! -use 2 Byte addressing even if result is zeropage each operand can be preceded by a '-', to take the twos complement. All operations are done in 16 Bit integer. 4) Labels Labels can be defined in two ways: 'LABEL STA LABELA,X' or 'LABELB =expression' A Label can only be defined once. 5) Remarks Remarks are preceeded by a semicolon and last till the next colon or the end of the line. 6) Pseudo opcodes The following pseudo opcodes are allowed: .OPT opt1 [,opt2 [,opt3 [...]]] set some assembler options valid options are: OO Put the objectcode into memory O3 Put the object code in the file opened with Filenumber 3 (OPEN 3,8,1,"name" before the starting SYS command) P Listing to the screen P2 Listing to file number 2 .END End of assembler code, Basic takes over now. .BYT expression1 [,expression2 [...]] puts Databytes into objectcode .WORD expression1 [,expression2 [...]] puts Datawords (16 Bit) into objectcode .ASC "TEXT" puts text into objectcode .GOTO Linenumber continue assembling at line number .SYS expression same as BASIC Command SYS .FILE 8,"Filename" Load the next part of the source code from Device 8, File "Filename" into memory. At the end of the code there must be the following code: .END 8,"Part1" This reloads the first part of the code into memory to start pass 2. .ICL Device,"Filename" Load next part of the source code and, after assembling it, return to the old file directly after the .ICL pseudo opcode. In fact, the file is kept in memory and the other file is loaded at the end of this file and is removed afterwards. .LST device,"Filename" Load (extra) Label tab after Pass 1 .SST device,"Filename" Saves actual Label tab in Pass 1 .IF expression If the expression is not zero, then the assembling goes on in the same line behind the if command, otherwise in the next line. *= expression set Programm counter to expression. 7) Sample Programm 10 SYS7*4096 ;call @ASS 20 .OPT P,OO ;set output 30 *=$033C ;set PC 40 LDY #0 50 L1 TYA 60 STA $0400,Y 70 INY:BNE L1 80 RTS:.END ;ENDE 90 SYS828:REM Call the machine language programm 100 getA$:ifA$=""then1310