Quick documentation for the NinjaForce Assembler v1.4 This Assembler is a 'no tools' assembler. You can't program GS/OS applications with it. We're using it for a half year now, and there have never been any bugs. You should be familiar with assembly language to use this program. To launch it, you have to type -NF.AS from Basic. Enter the filename of the source- file and the filename of the output file. If you press 'return' only when asked for the name of the output file, your assembly will be moved to the memory location specified by the ORG command. Your code has to follow certain standards: A label, the command, the operand and the comment must be seperated by spaces. The command may not begin in the first column. If you don't have a label in a line, insert one or more spaces (not tabs!). It is also possible to type in blank lines (with no spaces inside). This allows you to better structure your source code. Example: (label) (command) (operand) (comment) org $300 ;begin of program is $00 0300 sht ;use short registers begin ldx #0 ;load the x - register with 0 ]loop lda text+1,x ;load the accu with a text char jsr $fded ;print it inx ;increment x - register cpx text ;compare x with length byte before ascii text blt ]loop ;loop until done rts ;finished text str "Hi there!" ;length byte, then Ascii text. The special NF Assembler Commands: ORG The operand is the begin of the program (memory location). = or EQU Defines a label. DW Define Word(s). Must be seperated by commas. DFB Define Byte(s). Must be seperated by commas. HEX Define Hex-Byte(s). Must be sperated by commas. DS Define Storage. Operand-number of zeroes (byte values) are written. MSB Operand is either ON or OFF - takes effect on ASC and STR commands. COD Operand (byte value) is used to EOR Ascii Texts so that one can not read these from the monitor. This is a good method to protect secret texts from the eyes of others. - Takes effect on ASC and STR commands. ASC Operand holds text in " " STR Operand holds text in " ". A length byte is put before the text. TYP Operand (byte value) specifies the filetype of the outputfile. Look up the filetypes in a ProDOS reference. ($ff is a P8 - System file). If you do not use this command, the filetype of the outputfile will be BIN. IMP Operand "/disk/file" Loads in a non-forkfile at program counter location and includes it within the output file. SHT Use short (8 Bits) m and x,y registers. LNG Use long (16 Bits) m and x,y registers. M08 8-Bit m register. M16 16-Bit m register. X08 8-Bit x,y registers. X16 16-Bit x,y registers. MAC Begin macro definition. This command must have headed by the macro name. (Look at the example later in this text.) ^^^ End macro definition. Important: This is the only command wich may not have a label in front of it. LST If this command appears in the source file, you get a list output of all labels, sorted as they were defined. ; or * comment lines must begin with one of these characters. You can of course put comments behind any command line. Operand formats: Decimal 15 Hexadecimal $15 Binary %10010010 Ascii "a" or "ab" Program Counter * Label name Pseudo Commands: You may use these: Instead of these: BLT Branch less than. BCC BGT Branch greater than. BCS BGE Branch greater or equal than. BCS Macros: NF Assembler has very basic macro-functions. It is not possible to pass any information to the macro other than in the registers of the 65c816. A macro must be defined before it can be used. To call it, type in the name of the macro instead of a command. You should use local labels only in macros, because the assembler makes no difference between labels being defined within a macro or outside. You may not give a name already used as a label name, or some strange things will happen... Example of a macro: slowprt mac ;begin macro definition; macro name is: slowprint ldy #0 ;example code ]lp dey ;always use local labels within macros bne ]lp jsr $fded ^^^ ;end of macro definition Example of a macro call: lda #"A"+128 ;load akku with letter "A" slowprt ;print it (slow mode) Errors: Besides of the standard P8 errors that may occur during loading/saving source/out- put file, there are these assembler Errors: Unknown directive or command. Mostly typing errors (e.g.: LD in case of LDA etc.) Incorrect Hexadecimal value. Formal error. Incorrect Decimal value. Formal error. Incorrect Binary value. Formal error. Illegal Operand structure. Formal error. Undefined Label. Undefined Label was used. Branch too long. The destination from the Program Counter to the address specified by a branch-command is too long. NF AS entirely stops assembling. Import file not found. The file specified by the IMP command not is present. Illegal macro call. There was no macro with the given name found. Macro header is missing. A macro end command (^^^) was found without a macro begin command (MAC) before it. Special notes: - The assembler is case-sensitive in terms of labels and macro names, but not with commands (LDA,STA etc...) - simple math operations may be used (only + and -): $15-%1100 or "a"+15-label+$40 - Labels may not be used twice or the second is ignored (no error reported). - Local Labels: A local label begins with a ] character (e.g.: ]loop ) and may be defined more than one time. If used as an operand (e.g.: bra ]loop ) the last defined is used here. - Zero page and LongWord Labels must be defined before they can be used !!! - You may force the Long addressing mode by typing an "L" after the command. Example: LDAL $1000 will result in LDA $001000 - Always tell the assembler what type (16 or 8) of registers you use. When you begin the assembly, NF.AS is set to LNG, that is 16 Bits all registers. (So it is not necessary to write a LNG at the beginning of the Source). - Max. Source Length is 64k and so is the Output length. - The file format for the input file has to be standard Ascii Text (hi bit cleared, no Merlin 16+ texts can be used), but the file type can be Text or any type of Source. - Look at the Source code in this directory for an example of coding with NF AS. (You should print this reference if you want to program with NF AS.)