Source Files
Labels
Symbols
Opcodes
Operands
Constants
Expressions
Location Counter
Comments
The Crossbow assembler operates on source files made up of a mix of statement lines and comment lines. Statement lines use a combination of instruction mnemonics and assembler directives to generate program code and data or to control some aspect of the assembler's operation. Comment lines are either blank lines containing only tabs, spaces, and carriage returns, or lines beginning with a semi-colon, followed by programmer's comments and ending with a carriage return.
Statement lines have four fields: the label field which associates a symbol with a memory location, the opcode or directive field which generates code or instructs the assembler, the operand field which contains the operands to be acted on, and the comment field for explaining the intent of the line. The label, opcode, and operand fields are delimited with one or more space or tab characters, while the comment field delimiter requires both space characters and a semi-colon. As shown in the examples below, not all fields in a statement line need to be filled.
LABEL: OPCODE: OPERAND: COMMENTS: =============================================================== lonelab nop mylabel nop jmp mylabel ; opcode, operand, and comment ALABEL: BTST 3,$62,X ; ALL FIELDS USED
Some assemblers (most notably Motorola's) have a slightly different format for source lines which will confuse Crossbow. Provided with the Crossbow package is a utility program called Moto­p;>Crossbow which will convert source files in Motorola format to Crossbow format. See the documentation in the Moto­p;>Crossbow folder for more information.
Statement lines begin with a label field which the programmer may use to symbolically refer to the memory location of the instruction being assembled. If present, labels must begin in the first column of the line and must conform to the rules for assembly language symbols described below. Labels may optionally end with a colon character (the colon does not become part of the label) and colon terminated labels do not require space or tab characters before the next field.
Labels may stand alone on a line, followed by a carriage return or semi-colon comment, or they may lead into the opcode field, separated by one or more tab or space characters. Labels which begin with the underscore character may be applied to relatively unimportant local jumps and excluded from the symbol table listing to reduce clutter. Statement lines which do not have labels must use one or more space or tab characters to delimit the next field.
Crossbow also supports automatic labels as a convenient alternate to named labels for simple loops and jumps. Automatic label definitions consist of a single colon at the start of a line which Crossbow expands into a unique label during assembly. Forward label references consist of a colon followed by a plus sign, followed by a single digit (1..9), specifying the relative location of the automatic label. Backward label references consist of a colon followed by a minus sign, followed by a single digit (1..9).
;================================================= ; Auto Lab Test.Asm ;================================================= proc "6805" msdelay tsta ; A = Milliseconds <<<<<<<<<<< beq :+3 ; no delay, just | | >>>>>>> : ldx #FRQKHZ / 50 ; clock freq KHz | | | | >>> : decx ; 3 ; | | | nop ; 2 ; | | | nop ; 2 ; | | <<< bne :-1 ; 3 ; inner loop | | ; 10 ; | | deca ; | <<<<<<< bne :-2 ; outer loop | >>>>>>>>>>> : rts ;
Crossbow symbols may contain any combination of up to 32 characters from the following set of characters (A-Za-z0-9_), with the restriction that the first character must be alphabetic or the underscore character. Crossbow labels ARE case sensitive, i.e. "lab", "LAB", and "Lab" are three different labels.
The opcode field contains instruction mnemonics particular to the target microprocessor, assembler directives native to the Crossbow assemblers, and macro instructions created by the programmer. The opcode field must be separated from the label field by at least one tab or space character. The mnemonics, directives, and macros in the opcode field are not sensitive to case.
Crossbow searches for opcodes both in the macro table and the mnemonic table. If the opcode can't be found in either table, Crossbow positions the insertion point to the end of the errant opcode and displays the message: "Bad mnemonic or directive".
Some mnemonics and directives specify the size of the operation by suffixing the opcode with a period followed by a size character. Crossbow recognizes the following size specifiers and defaults to single byte for directives, and the chip makers recommended defaults for mnemonics.
Size Specifiers .b .B Byte .s .S Short (2 Bytes) .w .W Word (2 Bytes) .l .L Long (4 Bytes)
The optional operand field specifies the constants, registers, or expressions acted upon by the instruction or directive. Operands must be separated from the label field by at least one tab or space character. The operand field extends from the first non-space character following the opcode up to the end of the line or up to the semi-colon beginning a comment field. Space characters between multiple operands or expression operators are ignored by the assembler.
Crossbow recognizes three type of constants: numeric constants in several number bases, character constants, and string constants. Numeric constants default to decimal, but may be expressed as binary, octal or hexadecimal using the Intel, Motorola, or IEEE suffixes and prefaces shown at below.
Radix IEEE Moto Intel prefix prefix suffix Decimal D' d' none D d1 Hex H' h' $ H h2 Binary B' b' % B b Octal Q' q' @ Q q or O o notes: 1 decimal default, 2 requires leading digit
String constants are 1 to 255 characters enclosed in double-quotes usually used with data declaration directives to reserve initialized data in memory for use by the assembled program. Two consecutive double-quotes generates one occurrence of the double-quote character in the string, e.g. """" (four double quotes) generates a single byte containing one double-quote.
Character constants are one or two characters enclosed in single-quotes usually used as immediate operand data. Two consecutive single-quotes generates one occurrence of the single-quote character in a fashion similar to double quotes in string constants.
Expression operands contain combinations of constants and arithmetic, relational, and bitwise operators which evaluate to a number. Crossbow expressions use IEEE operators , and the operators associate from left to right. Operator precedence is shown in the table below with the highest precedence operators on the top. The parentheses serve to alter the default precedence and associativity.
Operator Description ( ) parenthesis * / % multiply, divide, modulo - ~ unary minus, unary complement + - add, subtract << >> shift left, shift right = <> equals, not equal < <= less than, less than or equal > >= greater than, greater than or equal & | ~ and, or, exclusive or
The following are some examples of how Crossbow would evaluate certain expressions.
data.b 1 - 1 - 1 ; will be -1
data.b 1 - (1 - 1) ; will be 1
data.b 1 = 1 ; will be 1
data.b 1 > 1 ; will be 0
data.b 1 < 1 ; will be 0
data.w start + h'100
data.w (tabend - tabstart) / elmsiz
data.w ((tabend - tabstart) / elmsiz) * 'D'
data.b "string with embedded quote ("")"
Crossbow accepts both the asterisk and dollar sign (*, $) to indicate the value of the current memory address at the start of the current instruction line.
Comments follow the last used field on the line and are recognized by the assembler by their leading semi-colon. Everything from the semi-colon to the end of the line is ignored.
Crossbow family assemblers feature a rich set of directives or pseudo-ops supporting Intel, Motorola, and IEEE-694 naming conventions. The directives group into six categories: source control, data declarations, symbol declarations, location control, conditional assembly, and macro assembly.
Prefacing an opcode with a period forces Crossbow to examine the directives and alias tables before looking in the instruction mnemonic table.
Source Control INCLUDE Include another file into the current assembly END End assembly on the current source file ALERT Display a message and continue assembly ERROR Display a message and halt assembly PROC Choose the default instruction set by processor Data Declarations DATA Declare initialized data (IEEE) DB "Define Byte" (Intel) FCB "Form Constant Byte" (Motorola) DW "Define Word" (Intel) FDB "Form Double Byte" (Motorola) FCC "Form Constant Characters" (Motorola) BLOCK Initialize a block of memory Symbol Declarations EQU Assign value to symbol ASSIGN Temporary symbol assignment (IEEE) SET Temporary symbol assignment (Intel) ASK Input value at assembly time Location Control ORG Set location counter ALIGN Force location counter alignment SECTION Multiple section assembly RES Reserve uninitialized data DS "Define Storage" (Intel) RMB "Reserve Memory Block" (Motorola) Conditional Assembly IF Begin conditional assembly ELSE Alternate assembly path ENDIF End conditional assembly Macro Assembly MACRO Begin macro definition EXITM Exit macro early ENDM End macro definition ALIAS Assign a new name to an instruction
Previous Next Contents