
Naviagtion
Home
|
Source Files
The main source file is opened by the SB-Assembler when you start the program.
This main source file may open as many include source files as you need, one at a time.
The include files follow exactly the same rules as the main source file.
Source files may only contain plain ASCII characters. It is recommended to use normal standard ASCII characters only. Extended ASCII characters (Full IBM characters) are discouraged because they may lead to unexpected results. This restriction does not apply to the comment fields however. Formatted files produced by e.g. Word or Wordperfect can not be used by the SB-Assembler.
A wide variety of text editors (not word processors!) is available that can be used to edit your source files.
Starting at the lowest end in a Microsoft environment there is EDLIN (Created by the makers of Windows), then upwards to COPY CON, followed by EDIT, NE, QE, E, ME, ED, PE and many, many others.
Even Window's Notepad can be used to create your source files.
The SB-Assembler is case insensitive, which means that it doesn't matter whether you use upper or lower case characters in your source files for labels, mnemonics, directives and operands. Naming Your Source Files In Version 2The name of source files and all other files used or created by the SB-Assembler must obey to the DOS rules. Mainly this means that the filename may contain a maximum of 8 characters followed by a dot and a 3 character extension. Files may be preceded by a drive letter (e.g. C: or M: ) and a path name. The total length of drive letter, path name and file name may not exceed 127 characters, or less if the DOS you use is the limiting factor.
The default extension for source files is .asm .
This means that you do not have to specifically supply this extension if you save your source files with the .asm file extension.
Naming Your Source Files In Version 3On a Windows system you can use the standard file naming standards again.
The limitations of the 8.3 naming convention no longer exists.
You may use longer names if you like.
You may also include drive letter and path names to direct the assembler to the proper files.
Path names and file name are separated by a backward slash \ .
Different rules apply on Linux, Unix and MAC systems.
For starters, in these operating systems file names ARE case sensitive.
This means that soure.asm and Source.asm are two different files.
The default extension for source files is .asm .
This means that you do not have to specifically supply this extension if you save your source files with the .asm file extension.
Source File Contents
A source file consists of one or more program lines.
These lines are interpreted by the SB-Assembler one after the other.
Every program line contains up to 4 fields.
Some fields may be empty, others may only be empty if the rest of the line can be treated as a comment field.
.CR 6502 Use 6502 overlay
RESET LDA #$FF Initialize stack
TAX
JSR INIT Initialize machine
JMP START Get going
.CR 6502 Use 6502 overlay
RESET LDA #$FF Initialize stack
TAX
JSR INIT Initialize machine
JMP START Get going
Both of these imaginary programs do exactly the same. The SB-Assembler doesn't care less which one of these two program it has to translate. It's up to you to decide which one you think is the easiest to read by a human. Completely empty lines are only listed in the list file and are ignored by the assembler. Below is a typal source line containing all fields. All fields are separated from each other by at least one space or TAB character. LabelField InstructionField OperandField CommentField Label FieldThe first field is the label field. This field always starts at the first position on the program line. This means that no spaces or TABs may be in front of this field. The label field contains a label if the first character of the line is a letter A to Z, a dot or a colon. The label field will end at the first space, TAB or EOL character on the program line. The label field is empty if the first character on the program line is a space or a TAB character.
If the first character on the program line is a semicolon ( ; ) or an asterisk ( * ) the whole line is treated as a comment line.
Comment lines are only listed and are ignored by the assembler.
Clearly they are intended for human readability only.
Any other character found on the first position of a program line will result in a "Bad symbol error" message in Version 2, or a an "Illegal label name" in Version 3. LABEL GLOBAL_LABEL .LOCAL_LABEL :MACRO_LABEL ; Comment line * Also a comment line # A comment line, only in Version 3 ! This line is illegal because of its first character ! Instruction FieldThe second field on a program line is the instruction field, also known as the mnemonic field. This field starts at the next non-space character behind the label field. If the label field is empty the instruction field starts at the first non-space character of the program line. The instruction field is assumed to be empty if no non-space characters follow the label field. It is perfectly legal to have only a label field on a source line.
The instruction field must contain a legal directive if it starts with a dot.
Otherwise an "Unknown directive" error is reported.
An instruction field starting with the > symbol is a macro call. Please refer to the description of Macros for more details.
An instruction field starting with a semicolon ; or an asterisk * will cause the rest of the source line to be treated as comments.
The rest of the source line will be ignored by the SB-Assembler.
This effectively means that this line does not contain an operand field.
In all other cases the instruction field should hold a legal mnemonic. Mnemonics are exclusively interpreted by Cross-Overlays. This means that mnemonics can't be interpreted without a loaded Cross-Overlay (see .CR directive). In Version 2 of the SB-Assembler Mnemonics may not be more than 10 characters long. In Version 3 there is no maximum limit. The instruction field ends at the next space or TAB character or at the EOL. COUNTER .EQ 50
LABEL NOP
RET
.LOCAL NEG
EXAMPLE ; An comment example
Operand FieldThe third field is the operand field. The operand field starts at the next non-space character after the instruction field. The operand field should contain the operands that are expected by the mnemonic or directive in the instruction field. Some mnemonics or directives don't expect an operand, in which case the operand field is treated as a comment field. Other mnemonics or directives have optional operands. In those cases the operand should follow the instruction field within 10 space characters (9 for Version 2). Otherwise the operand field is treated as comment field, effectively omitting the optional operand. You can force a comment field sooner by using a semicolon as first character in the operand field. The other comment prefixes, # and * are not accepted here and may have different meanings. Still other mnemonics or directives require one or more operands. In which case the distance between the instruction field and operand field is not important. Now it is not allowed to start the operand field with a semicolon because an operand is expected!
Multiple operands in an operand field should be separated from each other by commas.
The operand field ends at the next space or TAB character or EOL.
Except when the operand is a delimited string of course.
All other rules for the operands are dictated by the mnemonic or directive in the instruction field. LABEL LD A,B
LD A, B Only allowed in Version 3
INC A
.LOCAL CALL DISPLAY
Comment FieldThe fourth and last field is the comment field. This field is only meant for us humans and will be ignored by the SB-Assembler. The comment field automatically starts when the SB-Assembler doesn't expect any more operands. This also means that it is not necessary to start a comment field with a semicolon, as with most other assemblers. It won't hurt if you do start the comment field with a semicolon though. Everything is allowed in the comment field, for the SB-Assembler has already stopped interpreting your source line here. LABEL LD A,B Auto comment field
INC A ; Forced comment field
.LOCAL NOP No operand required, auto comment
CAUTION ; Requires forced comment, otherwise expects operand here
; Line contains only comment, forced comment is required now
|