====== Assembler syntax ====== ==== Overview ==== The assembler is designed to cope with many common formats, but in practice most programs from books will need modifying. By default the program is assembled to address $4000; change this with the ORG directive. This is a two-pass assembler, meaning the source code can reference labels that are not defined until later in the program. Once successfully assembled the program will be listed in the Disassembly panel. If a special label "start" was defined it will be listed from here and be ready to start. Otherwise $4000 is the default address. === Comments === Everything on a line from a **;** (semicolon) onward is treated as a comment and ignored by the assembler. For compatibility a ***** (star) symbol can also be used. === Numeric constants === Numbers are in decimal by default. Specify hexadecimal values by preceding the digits by the **$** symbol. Also the C standard **0x** format is recognised. For binary precede the digits by the **%** symbol. Positive and negative numbers are preceded by the **+** and **-** symbols respectively. Constants and labels can be chained together with simple arithmetic (just plus and minus). const asciiZero=48, asciiNine=+57, asciiEight=$38 const asciiSeven=0x37, asciiOne=%00110001, minusNineteen=-$13 const PIA=$FF20 start: lda #'9 lda #asciiZero lda #asciiNine lda #asciiEight lda #asciiSeven lda #asciiOne lda #minusNineteen ldb PIA+1 === Labels === Labels are used to refer to constants and memory addresses. A label starts with a letter and may continue with letters, digits, or the **_** (underscore) character. There is no limit to their length, though it's best to keep them fairly short. They are not case sensitive. When a label is defined at the start of a line, follow it with a **:** (colon). Otherwise, make sure the label is at the very start of the line with no whitespace. There are no reserved words, but avoid confusion by not using 6809 instructions or registers. There is a special label called 'START': define this and your program will execute and be listed from here. const txtRAM=$400 vidRAM EQU $600 start: jsr vidInit line_buffer: rmb $20 vidInit: ldx #txtRAM ldy #vidRam ldu #Line_Buffer rts === Directives === A directive does not assemble to a machine language instruction, but either defines data or specifies the way in which the assembler should process the instructions and data. They are not case sensitive. == ORG
== Sets the **origin** of the code. Instructions and data following this directive in the source file will be assembled at that address onward in memory. The default value is **$4000** . start: jsr libRoutine01 ; jsr $f000 ; ... org $F000 libRoutine01: pshs d,x == END == Signals the end of the source file. There may be text following but it will not be assembled. finish: clra rts ; Some reminders here ... end More reminders here ... == RMB == == DS == Reserve memory bytes (or define space). The assembler reserves space for **** bytes of memory without defining their values. lineInput: rmb 33 ; 33 bytes for a line input buffer textArea: ds $0200 ; 512 bytes for a text screen == CONST