[Coco] CCASM enhancements (includes long asm listing)

Roger Taylor operator at coco3.com
Wed Apr 25 23:52:12 EDT 2007


At 10:28 PM 4/24/2007, you wrote:
>Roger,
>
>This produces a listing with only two incompatibilities with CCASM...
>
>* It can generate labels on empty lines (no instructions)
>eg.     label_1
>                 lda     #$42
>
>* It uses spaces after each comma on "fcb" lines.
>eg.             fcb     0, 1, 2, 3

CCASM 4.0 already supports lines with labels only.   You can get 
CCASM 4.0 and some recent PDF docs at www.coco3.com in the Downloads 
section: Programming and Development.

The whitespace issue will take some work to fix.  Spaces and tabs are 
definately used to separate labels, opcodes, and comments, but I've 
got some tricky code in there to deal with other similar issues, so 
I'll look for a cure soon.

The following listing shows a typical Rainbow IDE build readout 
window, and also shows the power of the CCASM assembler.  Notice the 
math expressions that are possible, structures, and unions, 
etc.  Take special notice to the advanced 6309 instructions!  Some of 
these are not supported by any other 6309-capable assembler that I've 
seen.  I'm not sure if the CCASM docs fully demonstrate all of this, 
or if anybody really reads the docs enough to realize what all is possible.

For Portal-9, store cm.exe in c:\Windows or is it c:\Windows\System 
(can't recall right now), but in Rainbow 1.x it's in the installation 
directory as far as I know, and possibly could be used from the same 
Windows system folders since they're probably in the system PATH 
variable.  Anyway, replace cm.exe in the IDE you're using and let us 
know the results.


------

Rainbow IDE
(C) 2007 by Taylor Software, All Rights Reserved

PROJECT TITLE: test

decb dskini "Disks\disk1.dsk" -3
decb dskini "Disks\disk2.dsk" -3

cm CCASM_Test.asm -l -sa -loadm -o=Files\test.bin -de=Errors\error.log

CCASM - 6809/6309 Cross Assembler (4.0)
Copyright (C) 2003-2006 by Roger Taylor Software
All Rights Reserved

CCASM 4.0: assembling CCASM_Test.asm to test.bin

                       *------------------------------------------------------------------------------
                       * CCASM 4.0 6809/6309 cross assembler test source
                       * -Includes most of the assembler's functions
                       * -Any resulting binary is not intended to be executed
                       *------------------------------------------------------------------------------
                                          ttl    CCASM_Test

                                          org    8192    defaults to 
org 0 if not specified

                        alabel
                        anotherlabel
                        yetanotherlabel
                        aprettylonglabel_with_underscores

               {$0001}  true              =      1
               {$0000}  false             =      0

               {$FFFF}  orange            =      fruit
               {$FFFF}  fruit             =      -1

               {$0002}  label2            equ    2       set "label2" 
to the value of 2
               {$0003}  label3            =      3       set "label3" 
to the value of 3
               {$0004}  label4            set    4       set "label4" 
to the value of 4
               {$0064}  apple             equ    100
               {$0032}  apple             set    50      reassign the 
value 50 to the label/symbol "apple"
               {$000A}  apple3            set    10      same as "equ 10"
               {$0013}  color3            =      19
               {$0005}  row               =      5
               {$0008}  col               =      8
               {$167E}  ilong             =      71294
               {$FFFF}  nlong             =      -1
               {$0012}  IMM               equ    $12
               {$0034}  DIR               equ    $34
               {$5678}  EXT               equ    $5678

               {$2000}  start             equ    *       set "start" 
label to the current Program Counter (PC) address

                       *------------------------------------------------------------------------------
                       * automatic Direct Page addressing
                       *------------------------------------------------------------------------------

               {$1100}                    setdp  $11
  2000 86   39                            lda    #57
  2002 97   DF                            sta    $11DF
               {$0000}                    setdp  $00

                       *------------------------------------------------------------------------------
                       * 6809 instruction tests
                       *------------------------------------------------------------------------------

  2004 3A                                 ABX
                       *
  2005 89   12                            ADCA   #IMM
  2007 99   34                            ADCA   DIR
  2009 B9   5678                          ADCA   EXT
  200C A9   9F 5678                       ADCA   [EXT]
  2010 A9   84                            ADCA   ,X
  2012 A9   A1                            ADCA   ,Y++
  2014 A9   D3                            ADCA   [,--U]
  2016 C9   12                            ADCB   #IMM
  2018 D9   34                            ADCB   DIR
  201A F9   5678                          ADCB   EXT
  201D E9   9F 5678                       ADCB   [EXT]
  2021 E9   84                            ADCB   ,X
  2023 E9   A1                            ADCB   ,Y++
  2025 E9   D3                            ADCB   [,--U]
                       *
  2027 8B   12                            ADDA   #IMM
  2029 9B   34                            ADDA   DIR
  202B BB   5678                          ADDA   EXT
  202E AB   9F 5678                       ADDA   [EXT]
  2032 AB   84                            ADDA   ,X
  2034 AB   A1                            ADDA   ,Y++
  2036 AB   D3                            ADDA   [,--U]
  2038 CB   12                            ADDB   #IMM
  203A DB   34                            ADDB   DIR
  203C FB   5678                          ADDB   EXT
  203F EB   9F 5678                       ADDB   [EXT]
  2043 EB   84                            ADDB   ,X
  2045 EB   A1                            ADDB   ,Y++
  2047 EB   D3                            ADDB   [,--U]
  2049 C3   0012                          ADDD   #IMM
  204C D3   34                            ADDD   DIR
  204E F3   5678                          ADDD   EXT
  2051 E3   9F 5678                       ADDD   [EXT]
  2055 E3   84                            ADDD   ,X
  2057 E3   A1                            ADDD   ,Y++
  2059 E3   D3                            ADDD   [,--U]
                       *
  205B 84   12                            ANDA   #IMM
  205D 94   34                            ANDA   DIR
  205F B4   5678                          ANDA   EXT
  2062 A4   9F 5678                       ANDA   [EXT]
  2066 A4   84                            ANDA   ,X
  2068 A4   A1                            ANDA   ,Y++
  206A A4   D3                            ANDA   [,--U]
  206C C4   12                            ANDB   #IMM
  206E D4   34                            ANDB   DIR
  2070 F4   5678                          ANDB   EXT
  2073 E4   9F 5678                       ANDB   [EXT]
  2077 E4   84                            ANDB   ,X
  2079 E4   A1                            ANDB   ,Y++
  207B E4   D3                            ANDB   [,--U]
  207D 1C   12                            ANDCC  #IMM
                       *
  207F 48                                 ASLA
  2080 58                                 ASLB
  2081 08   34                            ASL    DIR
  2083 78   5678                          ASL    EXT
  2086 68   9F 5678                       ASL    [EXT]
  208A 68   84                            ASL    ,X
  208C 68   A1                            ASL    ,Y++
  208E 68   D3                            ASL    [,--U]
                       *
  2090 47                                 ASRA
  2091 57                                 ASRB
  2092 07   34                            ASR    DIR
  2094 77   5678                          ASR    EXT
  2097 67   9F 5678                       ASR    [EXT]
  209B 67   84                            ASR    ,X
  209D 67   A1                            ASR    ,Y++
  209F 67   D3                            ASR    [,--U]
                       *
  20A1 24   FE                            BCC    *
  20A3 25   FE                            BCS    *
  20A5 27   FE                            BEQ    *
  20A7 2C   FE                            BGE    *
  20A9 2E   FE                            BGT    *
  20AB 22   FE                            BHI    *
  20AD 24   FE                            BHS    *
  20AF 2F   FE                            BLE    *
  20B1 25   FE                            BLO    *
  20B3 23   FE                            BLS    *
  20B5 2D   FE                            BLT    *
  20B7 2B   FE                            BMI    *
  20B9 26   FE                            BNE    *
  20BB 2A   FE                            BPL    *
  20BD 20   FE                            BRA    *
  20BF 21   FE                            BRN    *
  20C1 28   FE                            BVC    *
  20C3 29   FE                            BVS    *
  20C5 8D   FE                            BSR    *
                       *
  20C7 85   12                            BITA   #IMM
  20C9 95   34                            BITA   DIR
  20CB B5   5678                          BITA   EXT
  20CE A5   9F 5678                       BITA   [EXT]
  20D2 A5   84                            BITA   ,X
  20D4 A5   A1                            BITA   ,Y++
  20D6 A5   D3                            BITA   [,--U]
  20D8 C5   12                            BITB   #IMM
  20DA D5   34                            BITB   DIR
  20DC F5   5678                          BITB   EXT
  20DF E5   9F 5678                       BITB   [EXT]
  20E3 E5   84                            BITB   ,X
  20E5 E5   A1                            BITB   ,Y++
  20E7 E5   D3                            BITB   [,--U]
                       *
  20E9 4F                                 CLRA
  20EA 5F                                 CLRB
  20EB 0F   34                            CLR    DIR
  20ED 7F   5678                          CLR    EXT
  20F0 6F   9F 5678                       CLR    [EXT]
  20F4 6F   84                            CLR    ,X
  20F6 6F   A1                            CLR    ,Y++
  20F8 6F   D3                            CLR    [,--U]
                       *
  20FA 81   12                            CMPA   #IMM
  20FC 91   34                            CMPA   DIR
  20FE B1   5678                          CMPA   EXT
  2101 A1   9F 5678                       CMPA   [EXT]
  2105 A1   84                            CMPA   ,X
  2107 A1   A1                            CMPA   ,Y++
  2109 A1   D3                            CMPA   [,--U]
  210B C1   12                            CMPB   #IMM
  210D D1   34                            CMPB   DIR
  210F F1   5678                          CMPB   EXT
  2112 E1   9F 5678                       CMPB   [EXT]
  2116 E1   84                            CMPB   ,X
  2118 E1   A1                            CMPB   ,Y++
  211A E1   D3                            CMPB   [,--U]
  211C 1083 0012                          CMPD   #IMM
  2120 1093 34                            CMPD   DIR
  2123 10B3 5678                          CMPD   EXT
  2127 10A3 9F 5678                       CMPD   [EXT]
  212C 10A3 84                            CMPD   ,X
  212F 10A3 A1                            CMPD   ,Y++
  2132 10A3 D3                            CMPD   [,--U]
  2135 8C   0012                          CMPX   #IMM
  2138 9C   34                            CMPX   DIR
  213A BC   5678                          CMPX   EXT
  213D AC   9F 5678                       CMPX   [EXT]
  2141 AC   84                            CMPX   ,X
  2143 AC   A1                            CMPX   ,Y++
  2145 AC   D3                            CMPX   [,--U]
  2147 108C 0012                          CMPY   #IMM
  214B 109C 34                            CMPY   DIR
  214E 10BC 5678                          CMPY   EXT
  2152 10AC 9F 5678                       CMPY   [EXT]
  2157 10AC 84                            CMPY   ,X
  215A 10AC A1                            CMPY   ,Y++
  215D 10AC D3                            CMPY   [,--U]
  2160 1183 0012                          CMPU   #IMM
  2164 1193 34                            CMPU   DIR
  2167 11B3 5678                          CMPU   EXT
  216B 11A3 9F 5678                       CMPU   [EXT]
  2170 11A3 84                            CMPU   ,X
  2173 11A3 A1                            CMPU   ,Y++
  2176 11A3 D3                            CMPU   [,--U]
                       *
  2179 43                                 COMA
  217A 53                                 COMB
  217B 03   34                            COM    DIR
  217D 73   5678                          COM    EXT
  2180 63   9F 5678                       COM    [EXT]
  2184 63   84                            COM    ,X
  2186 63   A1                            COM    ,Y++
  2188 63   D3                            COM    [,--U]
                       *
  218A 3C   12                            CWAI   #IMM
  218C 19                                 DAA
                       *
  218D 4A                                 DECA
  218E 5A                                 DECB
  218F 0A   34                            DEC    DIR
  2191 7A   5678                          DEC    EXT
  2194 6A   9F 5678                       DEC    [EXT]
  2198 6A   84                            DEC    ,X
  219A 6A   A1                            DEC    ,Y++
  219C 6A   D3                            DEC    [,--U]
                       *
  219E 88   12                            EORA   #IMM
  21A0 98   34                            EORA   DIR
  21A2 B8   5678                          EORA   EXT
  21A5 A8   9F 5678                       EORA   [EXT]
  21A9 A8   84                            EORA   ,X
  21AB A8   A1                            EORA   ,Y++
  21AD A8   D3                            EORA   [,--U]
  21AF C8   12                            EORB   #IMM
  21B1 D8   34                            EORB   DIR
  21B3 F8   5678                          EORB   EXT
  21B6 E8   9F 5678                       EORB   [EXT]
  21BA E8   84                            EORB   ,X
  21BC E8   A1                            EORB   ,Y++
  21BE E8   D3                            EORB   [,--U]
                       *
  21C0 1E   89                            EXG    A,B
  21C2 1E   12                            EXG    X,Y
                       *
  21C4 4C                                 INCA
  21C5 5C                                 INCB
  21C6 0C   34                            INC    DIR
  21C8 7C   5678                          INC    EXT
  21CB 6C   9F 5678                       INC    [EXT]
  21CF 6C   84                            INC    ,X
  21D1 6C   A1                            INC    ,Y++
  21D3 6C   D3                            INC    [,--U]
                       *
  21D5 0E   34                            JMP    DIR
  21D7 7E   5678                          JMP    EXT
  21DA 6E   9F 5678                       JMP    [EXT]
  21DE 6E   84                            JMP    ,X
  21E0 6E   81                            JMP    ,X++
  21E2 6E   B3                            JMP    [,--Y]
  21E4 9D   34                            JSR    DIR
  21E6 BD   5678                          JSR    EXT
  21E9 AD   9F 5678                       JSR    [EXT]
  21ED AD   84                            JSR    ,X
  21EF AD   81                            JSR    ,X++
  21F1 AD   B3                            JSR    [,--Y]
                       *
  21F3 1024 FFFC                          LBCC   *
  21F7 1025 FFFC                          LBCS   *
  21FB 1027 FFFC                          LBEQ   *
  21FF 102C FFFC                          LBGE   *
  2203 102E FFFC                          LBGT   *
  2207 1022 FFFC                          LBHI   *
  220B 1024 FFFC                          LBHS   *
  220F 102F FFFC                          LBLE   *
  2213 1025 FFFC                          LBLO   *
  2217 1023 FFFC                          LBLS   *
  221B 102D FFFC                          LBLT   *
  221F 102B FFFC                          LBMI   *
  2223 1026 FFFC                          LBNE   *
  2227 102A FFFC                          LBPL   *
  222B 16   FFFD                          LBRA   *
  222E 1021 FFFC                          LBRN   *
  2232 1028 FFFC                          LBVC   *
  2236 1029 FFFC                          LBVS   *
  223A 17   FFFD                          LBSR   *
                       *
  223D 86   12                            LDA    #IMM
  223F 96   34                            LDA    DIR
  2241 B6   5678                          LDA    EXT
  2244 A6   9F 5678                       LDA    [EXT]
  2248 A6   84                            LDA    ,X
  224A A6   A1                            LDA    ,Y++
  224C A6   D3                            LDA    [,--U]
  224E C6   12                            LDB    #IMM
  2250 D6   34                            LDB    DIR
  2252 F6   5678                          LDB    EXT
  2255 E6   9F 5678                       LDB    [EXT]
  2259 E6   84                            LDB    ,X
  225B E6   A1                            LDB    ,Y++
  225D E6   D3                            LDB    [,--U]
  225F CC   0012                          LDD    #IMM
  2262 DC   34                            LDD    DIR
  2264 FC   5678                          LDD    EXT
  2267 EC   9F 5678                       LDD    [EXT]
  226B EC   84                            LDD    ,X
  226D EC   A1                            LDD    ,Y++
  226F EC   D3                            LDD    [,--U]
                       *
  2271 30   05                            LEAX   5,X
  2273 30   A1                            LEAX   ,Y++
  2275 30   C3                            LEAX   ,--U
  2277 30   F1                            LEAX   [,S++]
  2279 31   05                            LEAY   5,X
  227B 31   A1                            LEAY   ,Y++
  227D 31   C3                            LEAY   ,--U
  227F 31   F1                            LEAY   [,S++]
  2281 33   05                            LEAU   5,X
  2283 33   A1                            LEAU   ,Y++
  2285 33   C3                            LEAU   ,--U
  2287 33   F1                            LEAU   [,S++]
  2289 32   05                            LEAS   5,X
  228B 32   A1                            LEAS   ,Y++
  228D 32   C3                            LEAS   ,--U
  228F 32   F1                            LEAS   [,S++]
                       *
  2291 48                                 LSLA
  2292 58                                 LSLB
  2293 08   34                            LSL    DIR
  2295 78   5678                          LSL    EXT
  2298 68   9F 5678                       LSL    [EXT]
  229C 68   84                            LSL    ,X
  229E 68   A1                            LSL    ,Y++
  22A0 68   D3                            LSL    [,--U]
                       *
  22A2 44                                 LSRA
  22A3 54                                 LSRB
  22A4 04   34                            LSR    DIR
  22A6 74   5678                          LSR    EXT
  22A9 64   9F 5678                       LSR    [EXT]
  22AD 64   84                            LSR    ,X
  22AF 64   A1                            LSR    ,Y++
  22B1 64   D3                            LSR    [,--U]
                       *
  22B3 3D                                 MUL
                       *
  22B4 40                                 NEGA
  22B5 50                                 NEGB
  22B6 00   34                            NEG    DIR
  22B8 70   5678                          NEG    EXT
  22BB 60   9F 5678                       NEG    [EXT]
  22BF 60   84                            NEG    ,X
  22C1 60   A1                            NEG    ,Y++
  22C3 60   D3                            NEG    [,--U]
                       *
  22C5 12                                 NOP
                       *
  22C6 8A   12                            ORA    #IMM
  22C8 9A   34                            ORA    DIR
  22CA BA   5678                          ORA    EXT
  22CD AA   9F 5678                       ORA    [EXT]
  22D1 AA   84                            ORA    ,X
  22D3 AA   A1                            ORA    ,Y++
  22D5 AA   D3                            ORA    [,--U]
  22D7 CA   12                            ORB    #IMM
  22D9 DA   34                            ORB    DIR
  22DB FA   5678                          ORB    EXT
  22DE EA   9F 5678                       ORB    [EXT]
  22E2 EA   84                            ORB    ,X
  22E4 EA   A1                            ORB    ,Y++
  22E6 EA   D3                            ORB    [,--U]
  22E8 1A   12                            ORCC   #IMM
                       *
  22EA 34   FF                            PSHS   A,B,CC,DP,X,Y,U,PC
  22EC 36   FF                            PSHU   A,B,CC,DP,X,Y,S,PC
  22EE 35   FF                            PULS   A,B,CC,DP,X,Y,U,PC
  22F0 37   FF                            PULU   A,B,CC,DP,X,Y,S,PC
                       *
  22F2 49                                 ROLA
  22F3 59                                 ROLB
  22F4 09   34                            ROL    DIR
  22F6 79   5678                          ROL    EXT
  22F9 69   9F 5678                       ROL    [EXT]
  22FD 69   84                            ROL    ,X
  22FF 69   A1                            ROL    ,Y++
  2301 69   D3                            ROL    [,--U]
                       *
  2303 46                                 RORA
  2304 56                                 RORB
  2305 06   34                            ROR    DIR
  2307 76   5678                          ROR    EXT
  230A 66   9F 5678                       ROR    [EXT]
  230E 66   84                            ROR    ,X
  2310 66   A1                            ROR    ,Y++
  2312 66   D3                            ROR    [,--U]
                       *
  2314 3B                                 RTI
  2315 39                                 RTS
                       *
  2316 82   12                            SBCA   #IMM
  2318 92   34                            SBCA   DIR
  231A B2   5678                          SBCA   EXT
  231D A2   9F 5678                       SBCA   [EXT]
  2321 A2   84                            SBCA   ,X
  2323 A2   A1                            SBCA   ,Y++
  2325 A2   D3                            SBCA   [,--U]
  2327 C2   12                            SBCB   #IMM
  2329 D2   34                            SBCB   DIR
  232B F2   5678                          SBCB   EXT
  232E E2   9F 5678                       SBCB   [EXT]
  2332 E2   84                            SBCB   ,X
  2334 E2   A1                            SBCB   ,Y++
  2336 E2   D3                            SBCB   [,--U]
                       *
  2338 1D                                 SEX
                       *
  2339 97   34                            STA    DIR
  233B B7   5678                          STA    EXT
  233E A7   9F 5678                       STA    [EXT]
  2342 A7   84                            STA    ,X
  2344 A7   A1                            STA    ,Y++
  2346 A7   D3                            STA    [,--U]
  2348 D7   34                            STB    DIR
  234A F7   5678                          STB    EXT
  234D E7   9F 5678                       STB    [EXT]
  2351 E7   84                            STB    ,X
  2353 E7   A1                            STB    ,Y++
  2355 E7   D3                            STB    [,--U]
  2357 DD   34                            STD    DIR
  2359 FD   5678                          STD    EXT
  235C ED   9F 5678                       STD    [EXT]
  2360 ED   84                            STD    ,X
  2362 ED   A1                            STD    ,Y++
  2364 ED   D3                            STD    [,--U]
                       *
  2366 80   12                            SUBA   #IMM
  2368 90   34                            SUBA   DIR
  236A B0   5678                          SUBA   EXT
  236D A0   9F 5678                       SUBA   [EXT]
  2371 A0   84                            SUBA   ,X
  2373 A0   A1                            SUBA   ,Y++
  2375 A0   D3                            SUBA   [,--U]
  2377 C0   12                            SUBB   #IMM
  2379 D0   34                            SUBB   DIR
  237B F0   5678                          SUBB   EXT
  237E E0   9F 5678                       SUBB   [EXT]
  2382 E0   84                            SUBB   ,X
  2384 E0   A1                            SUBB   ,Y++
  2386 E0   D3                            SUBB   [,--U]
  2388 83   0012                          SUBD   #IMM
  238B 93   34                            SUBD   DIR
  238D B3   5678                          SUBD   EXT
  2390 A3   9F 5678                       SUBD   [EXT]
  2394 A3   84                            SUBD   ,X
  2396 A3   A1                            SUBD   ,Y++
  2398 A3   D3                            SUBD   [,--U]
                       *
  239A 3F                                 SWI
  239B 103F                               SWI2
  239D 113F                               SWI3
  239F 13                                 SYNC
                       *
  23A0 1F   89                            TFR    A,B
  23A2 1F   12                            TFR    X,Y
                       *
  23A4 4D                                 TSTA
  23A5 5D                                 TSTB
  23A6 0D   34                            TST    DIR
  23A8 7D   5678                          TST    EXT
  23AB 6D   9F 5678                       TST    [EXT]
  23AF 6D   84                            TST    ,X
  23B1 6D   A1                            TST    ,Y++
  23B3 6D   D3                            TST    [,--U]

                       *------------------------------------------------------------------------------
                       * constant value identifiers  ($=hex, 
%=binary, otherwise decimal)
                       *------------------------------------------------------------------------------

  23B5 86   F6                            lda    #-10    decimal value
  23B7 86   F0                            lda    #-$10   hex value
  23B9 CC   FF94                          ldd    #-%1101100      binary value
  23BC 96   FF                            lda    $ff     hex address
  23BE FC   FF00                          ldd    $ff00   hex address
  23C1 96   03                            lda    %011    binary address

                       *------------------------------------------------------------------------------
                       * ASCII character translation to binary
                       *------------------------------------------------------------------------------

               {TRUE}                     cond   1
  23C3 86   61                            lda    #'a
  23C5 86   5A                            lda    #'Z
  23C7 86   39                            lda    #'9
  23C9 86   30                            lda    #'0
               {TRUE}                     endc


                       *------------------------------------------------------------------------------
                       * direct page and extended page addressing
                       * the "<" and ">" address mode modifiers are used
                       * to override the assembler's choice
                       *------------------------------------------------------------------------------

               {TRUE}                     if     true
  23CB 96   05                            lda    <5      accesses 
Direct Page address $05
  23CD B6   0005                          lda    >5      accesses 
"64k" address $0005 (regardless of Direct Page contents)
  23D0 96   05                            lda    5       let the 
assembler decide (produces the smallest possible code)
  23D2 A6   88 01                         lda    <1,x    force 8-bit offset
  23D5 A6   89 0001                       lda    >1,x    force 16-bit offset
  23D9 A6   01                            lda    1,x     assembler 
chooses the smallest possible offset starting from 5-bit up to 16-bit
  23DB A6   00                            lda    0,x     assembler 
chooses 5-bit offset of 0
  23DD A6   84                            lda    ,x      use NO 
offset (not exactly the same as 0,x)
  23DF A6   88 00                         lda    <0,x    use 8-bit offset of 0
  23E2 A6   89 0005                       lda    >5,x    use 16-bit offset of 5
               {TRUE}                     endc

                       *------------------------------------------------------------------------------
                       * loading data into registers
                       *------------------------------------------------------------------------------

  23E6 86   05                            lda    #5      load a constant
  23E8 CC   FFFB                          ldd    #-5     load a constant
  23EB BE   0400                          ldx    $0400   load 
directly from memory
  23EE 108E 0200                          ldy    #512
  23F2 CE   0064                          ldu    #100
  23F5 10CE 7F00                          lds    #32512
  23F9 86   03                            lda    #%011   load binary 
value of 3 into A
  23FB 86   03                            lda    #$03    load hex 
value of 3 into A
  23FD C6   03                            ldb    #$3     load hex 
value of 3 into B
  23FF CC   0006                          ldd    #%110   load binary 
value of 6 into D
  2402 9E   8A                            ldx    138     load 16-bit 
value at address 138 into register X
  2404 109E 9E                            ldy    158     load 16-bit 
value at address 158 into register Y
  2407 9E   32                            ldx    apple   load into 
register X the contents of the address "apple"

                       *------------------------------------------------------------------------------
                       * storing registers to memory
                       *------------------------------------------------------------------------------

  2409 B7   000A                          sta    >$0a    write to 
$000a regardless of DP mode
  240C ED   84                            std    ,x
  240E BF   7D64                          stx    32100
  2411 10BF 0100                          sty    $100
  2415 10DF 03                            sts    %011

                       *------------------------------------------------------------------------------
                       * using the 6309's powerful 32-bit register Q (A,B,E,F)
                       *------------------------------------------------------------------------------

  2418 CD   00010000                      ldq    #65536  load the value 65536
  241D CD   FFFFFFFF                      ldq    #-1     load the 
highest possible unsigned 32-bit value
  2422 
CD   FBAC3DE7                      ldq    #$FBAC3DE7      8-digit hexidecimal
  2427 CD   0000BEEF                      ldq    #$Beef

                       *------------------------------------------------------------------------------
                       * exchanging two registers (swapping their contents)
                       *------------------------------------------------------------------------------

  242C 1E   89                            exg    a,b
  242E 1E   98                            exg    b,a
  2430 1E   01                            exg    d,x
  2432 1E   13                            exg    x,u
  2434 1E   15                            exg    x,pc

                       *------------------------------------------------------------------------------
                       * transferring one register to another
                       *------------------------------------------------------------------------------

  2436 1F   89                            tfr    a,b
  2438 1F   12                            tfr    x,y
  243A 1F   01                            tfr    d,x

                       *------------------------------------------------------------------------------
                       * because the 6309 CPU has been found to allow 
exchanges between different
                       * register sizes, it is possible to assemble 
such instructions
                       *------------------------------------------------------------------------------

  243C 1F   81                            tfr    a,x
  243E 1F   18                            tfr    x,a
  2440 1F   29                            tfr    y,b

                       *------------------------------------------------------------------------------
                       * indexed memory access
                       *------------------------------------------------------------------------------

  2442 A6   82                            lda    ,-x     automatic 
decrement before read
  2444 A6   80                            lda    ,x+     automatic 
increment after read
  2446 A6   01                            lda    1,x     constant offset from x
  2448 A6   1F                            lda    -1,x    negative 
constant offset from x
  244A A6   88 10                         lda    16,x
  244D A6   10                            lda    -16,x
  244F A6   88 7F                         lda    127,x
  2452 A6   88 81                         lda    -127,x
  2455 A6   89 0080                       lda    128,x
  2459 A6   88 80                         lda    -128,x
  245C A6   89 0100                       lda    256,x
  2460 B6   2462                          lda    *+2
  2463 B6   2461                          lda    *-2
  2466 A6   89 FF00                       lda    -256,x
  246A A6   89 7FFF                       lda    32767,x
  246E 30   89 C000                       LEAX   -$4000,X
  2472 30   89 8000                       leax   $8000,x
  2476 31   A8 C0                         leay   -$40,y
  2479 30   89 FEA2                       LEAX   -350,X
  247D 30   01                            leax   1,x
  247F 33   C9 0200                       LEAU   512,U
  2483 33   C8 20                         LEAU   32,U
  2486 1C   CF                            ANDCC  #$CF
  2488 31   A8 20                         leay   32,Y
  248B 32   62                            LEAS   2,S
  248D 33   CB                            LEAU   D,U
  248F 30   1F                            leax   -1,X
  2491 31   A5                            leay   B,Y
  2493 30   89 FEA2                       leax   -350,X

                       *------------------------------------------------------------------------------
                       * automatic index offset ranges (5-bit)
                       *------------------------------------------------------------------------------

  2497 A6   10                            lda    -16,x
  2499 A6   11                            lda    -15,x
  249B A6   0F                            lda    15,x

                       *------------------------------------------------------------------------------
                       * automatic index offset ranges (8-bit)
                       *------------------------------------------------------------------------------

  249D A6   88 80                         lda    -128,x
  24A0 A6   88 81                         lda    -127,x
  24A3 A6   88 EF                         lda    -17,x
  24A6 A6   88 10                         lda    16,x
  24A9 A6   88 7F                         lda    127,x

                       *------------------------------------------------------------------------------
                       * automatic index offset ranges (16-bit)
                       *------------------------------------------------------------------------------

  24AC A6   89 8000                       lda    -32768,x
  24B0 A6   89 8001                       lda    -32767,x
  24B4 A6   89 FF7F                       lda    -129,x
  24B8 A6   89 0080                       lda    128,x
  24BC A6   89 7FFF                       lda    32767,x

                       *------------------------------------------------------------------------------
                       * automatic vs. forced index offset ranges
                       *------------------------------------------------------------------------------

  24C0 30   21                            leax   1,y     automatic 5-bit range
  24C2 30   A8 01                         leax   <1,y    force 8-bit 
range, but why?
  24C5 30   A9 0001                       leax   >1,y    force 16-bit 
range, but why?
  24C9 30   3F                            leax   -1,y    automatic 
5-bit range for negative offset
  24CB 30   A8 FF                         leax   <-1,y   force 8-bit 
range on negative offset, but why?
  24CE 30   A9 FFFF                       leax   >-1,y   force 16-bit 
range on negative offset, but why?
  24D2 30   A9 00FF                       leax   255,y   +255 can't 
fit into 5 bits, so becomes 16-bit range
  24D6 30   A8 FF                         leax   <255,y  means -1,y 
since you're confining 255 to an 8-bit int
  24D9 30   A9 00FF                       leax   >255,y  force 16-bit 
range, so it equals 255,y
  24DD 30   3F                            leax   65535,y automatic 
5-bit range for -1,y (65535 means -1)
  24DF 30   A8 
FF                         leax   <65535,y        8-bit range for -1,y
  24E2 30   A9 
FFFF                       leax   >65535,y        16-bit range for -1,y

                       *------------------------------------------------------------------------------
                       * indirect addressing, indexing, pointers
                       *------------------------------------------------------------------------------

  24E6 
A6   93                            lda    [,--x]  auto-decrement 
16-bit pointer before reading byte
  24E8 
A6   91                            lda    [,x++]  auto-increment 
16-bit pointer after reading byte
  24EA AD   9F A000                       jsr    [40960] call 16-bit 
address stored at 40960-40961
  24EE ED   9F 008A                       std    [138]   store 
register D in the address pointed to by address 138-139
  24F2 A7   9F 008A                       sta    [138]   store 
register A in the address pointed to by address 138-139
  24F6 A6   90                            lda    [,x+]   possible on 
6809, but probably useless [,r+]
  24F8 A6   92                            lda    [,-x]   possible on 
6809, but probably useless [,-r]

                       *------------------------------------------------------------------------------
                       * relative addressing, position-independent 
memory access
                       *------------------------------------------------------------------------------

  24FA 30   8D 
FB02                       leax   start,pcr       point X to the 
address of symbol "start"
  24FE 30   8D DB30                       leax   apple,pcr       load 
into register X the address of "apple"
  2502 AE   8D FAFA                       ldx    start,pcr       load 
X with the contents of the address of symbol "start"
  2506 AE   8D DB28                       ldx    apple,pcr       load 
into register X the contents of address "apple"
  250A 30   8D 
FAF3                       leax   start+1,pcr     point X to the 
address of symbol "start" + 1
  250E A6   8C FD                         lda    *,pcr   load the 
first opcode of the instruction "lda *,pcr"
  2511 A6   8C FF                         lda    *+2,pc  "pc" can be 
used for "pcr"

                       *------------------------------------------------------------------------------
                       * load effective address
                       *------------------------------------------------------------------------------

  2514 30   1F                            leax   65535,x same as leax -1,x
  2516 30   A9 00FF                       leax   255,y
  251A 30   01                            leax   1,x     add 1 to the 
register X (load 1+X back into X)
  251C 30   41                            leax   1,u     add 1 to the 
register U and store result into register X
  251E 30   A4                            leax   ,y      similar to 
tfr y,x (load the contents of register Y into register X)
  2520 31   62                            leay   2,s     load Y with 
the value of S + 2

                       *------------------------------------------------------------------------------
                       * reserving uninitialized memory
                       *------------------------------------------------------------------------------

  2522                                    rmb    1       reserve 1 
byte of memory
  2523                                    rmd    1       reserve 2 bytes
  2525                                    rmq    1       reserve 4 bytes
  2529                                    rmb    1024    reserve 1k 
of memory for a buffer, table, etc.

                       *------------------------------------------------------------------------------
                       * generating direct codes and constants
                       *------------------------------------------------------------------------------

                       * initialize data
  2929 02                                 fcb    2       form 
constant byte of the value 2 (2)
  292A 01                                 fcb    1       initialized byte
  292B      0002                          fdb    2       form 
double-byte of the value 2 (0,2)
  292D      00000002                      fqb    2       form 32-bit 
structure of the value 2 (0,0,0,2)
  2931      00000009                      fqb    9       form 4-byte 
structure of the value 9 (0,0,0,9)
  2935 07                                 byte   7       same as fcb
  2936      0001                          word   1       same as fdb
  2938      00000003                      dword  3       same as fqb
                       * zero-initialized data
  293C      00                            fzb    1       form 1 
zero-initialized byte (1 PC address)
  293D      0000                          fzd    1       form 1 
zero-initialized word (2 PC addresses)
  293F      00000000                      fzq    1       form 1 
zero-initialized double word (4 PC addresses)
  2943      00000000                      fzq    5       form a total 
of 5 32-bit integers holding the values (0,0,0,0)
  2947      00000000
  294B      00000000
  294F      00000000
  2953      00000000

                       *------------------------------------------------------------------------------
                       * forming lists/tables/arrays
                       *------------------------------------------------------------------------------

  2957 01 02 03 04                        fcb    1,2,3,4,5,6,7   form 
a simple list of bytes
  295B 05 06 07
  295E      0001                          fdb    1,2,4,7,3,5,6   form 
a table of (7) 16-bit entries
  2960      0002
  2962      0004
  2964      0007
  2966      0003
  2968      0005
  296A      0006
  296C      0064                          fdb    100,200,300,.,400 
    the "." returns the Program Counter within the constant list
  296E      00C8
  2970      012C
  2972      2972
  2974      0190
  2976      00000001                      fqb    1,2,3,4 form a table 
of (4) 32-bit entries
  297A      00000002
  297E      00000003
  2982      00000004
  2986 01 02 03 
04                        fcb    0+1,2,3,3+1,2+3,10-4,14/2,2*2*2
  298A 05 06 07 08

  298E      0001                          fdb    1,$5,%101,-1,5*5
  2990      0005
  2992      0005
  2994      FFFF
  2996      0019

                       *------------------------------------------------------------------------------
                       * constants with spaces between them?
                       *------------------------------------------------------------------------------

  2998 01               fctest            fcb    1,      2, 3, 4, 5

                       *------------------------------------------------------------------------------
                       * ASCII strings
                       *------------------------------------------------------------------------------

  2999 43 6F 43 6F                        fcc    "CoCo"  ;form string 
of characters
  299D 43 6F 43 6F                        fcn    "CoCo"  ;form 
null-terminated string (adds null to end)
  29A1 00
  29A2 43 6F 43 EF                        fcs    "CoCo"  ;form 
Sign-terminated string (sets bit 7 of last character)
  29A6 43 6F 43 6F                        fcr    "CoCo"  ;form 
Carriage-Return/Null-Terminated string (adds 13,0) to end
  29AA 0D 00

                       *------------------------------------------------------------------------------
                       * forming simple tables of data with automatic 
size calculation
                       *------------------------------------------------------------------------------

  29AC C6   03                            ldb    #tablsz ;returns 
size of the following "segment" of code
               {$29AE}  table             equ    *       ;set "table" 
to the current Program Counter value (*)
  29AE 01 02 03                           fcb    1,2,3   ;store bytes 
1,2,3 in the table
               {$0003}  tablsz            equ    *-table ;compute 
size in bytes from here back to the address of "table"


                       *------------------------------------------------------------------------------
                       * RUN-TIME MATH (performed while this 
assembled program is being executed)
                       *------------------------------------------------------------------------------

  29B1 47                                 asra   ;signed divide reg.a by 2
  29B2 
44                                 lsra   ;unsigned       divide reg.a by 2
  29B3 48                                 lsla   ;reg.a=(reg.a*2)
  29B4 1030 88                            addr   a,a     ;reg.a=(reg.a+reg.a)
  29B7 4C                                 inca   ;reg.a=reg.a+1
  29B8 4A                                 deca   ;reg.a=reg.a=1
  29B9 8B   10                            adda   #16     ;reg.a=reg.a+16
  29BB C3   0020                          addd   #32     ;reg.d=reg.d+32
  29BE 1030 10                            addr   x,d     ;reg.x=reg.x+reg.d

                       *------------------------------------------------------------------------------
                       * COMPILE-TIME MATH (mathematical expression evaluation)
                       * (performed while this program is being assembled)
                       *------------------------------------------------------------------------------

                       *------------------------------------------------------------------------------
                       * unary operations (single value operations)
                       *------------------------------------------------------------------------------

  29C1 86   FE                            lda    #-2
  29C3 8E   FF9C                          ldx    #-100
  29C6 86   CE                            lda    #-apple ;negate a 
symbol's value
  29C8 86   CD                            lda    #^apple ;compliment 
a symbol's value
  29CA 10CE FFCD                          lds    #~apple ;compliment 
a symbol's value

                       *------------------------------------------------------------------------------
                       * multiplication
                       *------------------------------------------------------------------------------

  29CE 96   1B                            lda    3*3*3
  29D0 8E   FF6A                          ldx    #-30*5  ; multiply 
30 x 5, negate the result, giving -150
  29D3 8E   FF06                          ldx    #50*(-5)        ; 
enclose negative multiplier
  29D6 8E   FF38                          ldx    #40*(-5)
  29D9 8E   FF6A                          ldx    #30*(-5)
  29DC 86   F1                            lda    #5*-3   ;same as 5*(0-3)
  29DE 10CE FFF1                          lds    #5*(0-3)
  29E2 86   F1                            lda    #-3*5   ;(0-3)*5
  29E4 B6   FFF1                          lda    -(5*3)
  29E7 B6   FFF1                          lda    -(5)*3
  29EA 8E   FF06                          ldx    #-50*5  ; no need to 
enclose beginning negative number to multiply
  29ED 8E   FF38                          ldx    #-40*5  ; multiply 
40 x 5, negate the result, giving -200

                       *------------------------------------------------------------------------------
                       * division
                       *------------------------------------------------------------------------------

  29F0 86   02                            lda    #4/2
  29F2 86   32                            lda    #100/2
  29F4 CC   00CE                          ldd    #(512-100)/2
  29F7 86   F6                            lda    #-(100/10)
  29F9 B6   FFCE                          lda    -(100/2)
  29FC 86   00                            lda    #-(1/2) -.5 (rounded off)
  29FE 
CC   0000                          ldd    #apple/100      divide 
value of apple by 100
  2A01 86   FF                            lda    #511/2
  2A03 86   3F                            lda    #255/4
  2A05 86   3F                            lda    #254/4
  2A07 86   3F                            lda    #253/4
  2A09 86   3F                            lda    #252/4
  2A0B 86   3E                            lda    #251/4

                       *------------------------------------------------------------------------------
                       * modulas division (computes the remainder)
                       *------------------------------------------------------------------------------

  2A0D 86   02                            lda    #254%4  compute 
remainder of 254/4
  2A0F 86   01                            lda    #253%4  compute 
remainder of 253/4
  2A11 86   00                            lda    #252%4
  2A13 86   0F                            lda    #255%16
  2A15 CC   0007                          ldd    #255%8
  2A18 CC   0003                          ldd    #255%4
  2A1B 8E   0003                          ldx    #251%4

                       *------------------------------------------------------------------------------
                       * addition/subtraction
                       *------------------------------------------------------------------------------

  2A1E 86   01                            lda    #2-1
  2A20 86   FF                            lda    #1-2
  2A22 8E   3000                          ldx    #start+$1000
  2A25 86   3C                            lda    #100-10-10-20
  2A27 8E   0064                          ldx    #apple+apple    same 
as (apple*2)

                       *------------------------------------------------------------------------------
                       * mixed arithmetic
                       *------------------------------------------------------------------------------

  2A2A 86   64                            lda    #50*4/2
  2A2C CC   3DFF                          ldd    #(1024+32)*15+31
  2A2F CC   0014                          ldd    #1+2*(3+4)+5    ; 
notice the order of operations ( 1 + 2*7 + 5 = 20)
  2A32 8E   FFF6                          ldx    #-(100/5*2)
  2A35 8E   FC7C                          ldx    #100+(-100*10)
  2A38 CC   0096                          ldd    #apple+200/2    ; 
return (value of apple) + (100)
  2A3B 9E   2C                            ldx    1*2+3*4+5*6
  2A3D 8E   050F                          ldx    #1024+8*32+15
  2A40 CD   70F2E800                      ldq    #0-100*200*300*400
  2A45 8E   09F6                          ldx    #apple+apple*apple
  2A48 9E   01                            ldx    apple-apple+1

                       *------------------------------------------------------------------------------
                       * comparison operations (return Boolean value, 
where true=1, false=0)
                       *------------------------------------------------------------------------------

  2A4A 86   00                            lda    #1=2    ; load A 
register with condition (0=False, 1=True) for "1 is equal to 2"
  2A4C 86   01                            lda    #100=100        ; 
load A register with condition for "100 is equal to 100"
  2A4E 86   01                            lda    #100=100
  2A50 86   01                            lda    #1<2    ; condition 
result for "1 is less than 2"
  2A52 86   00                            lda    #2<2    ; check to 
see if "2 is less than 2"
  2A54 86   00                            lda    #1>2    ; check if 
"1 is greater than 2"
  2A56 86   01                            lda    #2>1    ; check if 
"2 is greater than 1"
  2A58 86   00                            lda    #1>1    ; returns 
(1=True) if "1 is greater than 1", otherwise returns (0=False)
  2A5A 86   00                            lda    #100*4=5        ; 
check if "100*4 is equal to 5"
  2A5C 86   00                            lda    #100*4=4        ; 
check if "100*4 is equal to 4"
  2A5E 86   01                            lda    #1<2
  2A60 86   01                            lda    #2<3    ; is 2 less 
than 3?  yes, so load the value 1 (for true)
  2A62 86   01                            lda    #5>=5   ; is "5 
greater than or equal to 5" ? (yes)
  2A64 86   00                            lda    #3>4    ; 3 is not 
greater than 4, so this loads 0 into register A
  2A66 86   00                            lda    #6<=5   ; is "6 less 
than or equal to 5" ? (no)
  2A68 86   00                            lda    #6<=5
  2A6A 86   01                            lda    #3>2    ; load 
condition flag 0 or 1 into A
  2A6C 86   01                            lda    #4=4    ; load 
condition flag 1 into A
  2A6E 86   00                            lda    #4=5
  2A70 86   00                            lda    #apple<1        ; 
load condition (true or false) (0 or 1) if "apple" is less than 1
  2A72 86   01                            lda    #apple>1
  2A74 86   00                            lda    #apple=1
  2A76 86   01                            lda    #apple+5>apple
  2A78 
CC   0000                          ldd    #100*apple=apple        ; 
100*apple does not equal apple
  2A7B 
CC   0000                          ldd    #100*apple<apple        ; 
100*apple is not less than apple
  2A7E 8E   0000                          ldx    #apple+1/2<apple
  2A81 86   01                            lda    #-254<=255
  2A83 8E   0001                          ldx    #1000>-1000
  2A86 8E   0000                          ldx    #-2000>2000
  2A89 8E   0001                          ldx    #2000>-5000

                       * logical, bitwise and Boolean operations

  2A8C 86   01                            lda    #true&true      ; 
returns true if both cases are true
  2A8E 86   00                            lda    #true&false
  2A90 86   00                            lda    #false&true
  2A92 86   00                            lda    #false&false

  2A94 86   01                            lda    #true!true      ; 
returns true if either case is true
  2A96 86   01                            lda    #true!false
  2A98 86   01                            lda    #false!true
  2A9A 86   00                            lda    #false!false

  2A9C 
86   01                            lda    #true^false     Exclusive 
OR on two Boolean values
  2A9E 86   01                            lda    #true^false
  2AA0 86   01                            lda    #true!false!true
  2AA2 86   00                            lda    #true&false!false
  2AA4 86   01                            lda    #true&true&true
  2AA6 86   00                            lda    #true!true&false

  2AA8 86   FE                            lda    #~(true&true)
  2AAA 86   FE                            lda    #^(true!true)
  2AAC 86   FF                            lda    #^(true&false)
  2AAE 86   FF                            lda    #^(false&true)
  2AB0 86   FE                            lda    #^(true!false)
  2AB2 86   FE                            lda    #^(1<255)

  2AB4 
86   01                            lda    #(color3=19)&(row=5)&(col=8)
  2AB6 
86   01                            lda    #(color3=19)!(row=4)!(col=1)

                       * should return True case
               {TRUE}                     if 
(color3<20)&(row<(7-1))&(col>=3+4)
               {TRUE}                     endif

                       * should return False case
               {FALSE}                    if 
(color3>=19)&(row>(7-1))&(col>=3+4)
               {TRUE}                     endif

  2AB8 86   FE                            lda    #^1
  2ABA 86   00                            lda    #~255
  2ABC 86   FF                            lda    #^0
  2ABE 86   3F                            lda    #^192
  2AC0 86   FF                            lda    #^-1

  2AC2 86   F0                            lda    #%11111111&%11110000
  2AC4 86   0A                            lda    #%10101010&%00001111
  2AC6 86   55                            lda    #%01010101&%11111111
  2AC8 86   18                            lda    #%111000&%11100
  2ACA 86   02                            lda    #apple&apple3
  2ACC 86   80                            lda    #255&128

  2ACE 86   FF                            lda    #%10101010!%01010101
  2AD0 86   FF                            lda    #%11110000!%00001111
  2AD2 86   3F                            lda    #%110011!%001100
  2AD4 86   FF                            lda    #$f0!$0f
  2AD6 86   8F                            lda    #$0f!$80
  2AD8 86   3A                            lda    #apple!apple3
  2ADA 86   C0                            lda    #128!64

  2ADC 86   06                            lda    #%1111^%1001
  2ADE 86   0F                            lda    #%1001^%0110
  2AE0 86   3F                            lda    #%101010^%010101

                       *------------------------------------------------------------------------------
                       * block memory transfers
                       *------------------------------------------------------------------------------

                       * copy an 8k block of RAM to another location 
in lightning speed
  2AE2 8E   C000                          ldx    #49152  start address
  2AE5 108E 4000                          ldy    #16384  destination address
  2AE9 1086 2000                          ldw    #8192   size of RAM 
block to copy
  2AED 1138 12                            copy   x,y     do the copy

                       * blast 64k of memory into the 6-bit sound 
port in lightning speed
  2AF0 8E   0000                          ldx    #0      top of CPU 
address space
  2AF3 1086 FF00                          ldw    #65280  size of 
block to blast into one address
  2AF7 108E FF20                          ldy    #65312  DAC port
  2AFB 113A 12                            imp    x,y     implode 
contents of ,x into ,y

                       * fill a 16k block of RAM with the live 
contents of a hardware port
  2AFE 8E   FF22                          ldx    #65314  address to read from
  2B01 108E 2000                          ldy    #8192   start of 
block to be filled
  2B05 1086 4000                          ldw    #16384  number of 
bytes to read from port
  2B09 113B 12                            exp    x,y     expand the 
live contents of address 65314 into addresses 8192-24576

                       * clear the 32-column "VDG" screen in Disk BASIC
  2B0C 8E   2B1B                          ldx    #filler
  2B0F 108E 0400                          ldy    #1024
  2B13 1086 0200                          ldw    #512
  2B17 113B 12                            exp    x,y
  2B1A 39                                 rts
  2B1B 60               filler            fcb    96

                       * black out the CoCo 3's 16-color palette registers
  2B1C 8E   FFB0                          ldx    #65456  palette 
slots start here
  2B1F 108E 
2B2B                          ldy    #blackcode      address holding 
filler byte
  2B23 1086 0010                          ldw    #16     slots
  2B27 113B 12                            exp    x,y     fill ,y+ with zeros
  2B2A 39                                 rts
  2B2B 00               blackcode         fcb    0

                       *------------------------------------------------------------------------------
                       * 6309 bit transfers between a register and a 
DP memory location
                       *------------------------------------------------------------------------------

  2B2C 1132 79 00                         bor    a,7,1,$00       or 
memory $00 (bit 1) into register A (bit 7)
  2B30 1134 47 00                         beor   a,0,7,65280     XOR 
port $FF00 (bit 7) into register A (bit 0)
  2B34 1136 B2 10                         ldbt   b,6,2,$10       load 
memory $10 (bit 2) into register B (bit 6)
  2B38 1137 2B 
0A                         stbt   cc,5,3,10       store reg. CC (bit 
5) into memory 10 (bit 3)
  2B3C 1137 2B 
14                         stbt   cc,5,3,<20      store reg. CC (bit 
5) into memory 20 (bit 3)
  2B40 1137 2B 
1E                         stbt   cc,5,3,>30      store reg. CC (bit 
5) into memory 30 (bit 3)

                       *------------------------------------------------------------------------------
                       * 6309 BOOMs (Bit Operation On Memory) INSTRUCTIONS
                       * bits; memory
                       *------------------------------------------------------------------------------

  2B44 72   04 0400                       aim    4;1024  AND 
%00000100 with the memory in address 1024
  2B48 72   FC FF20                       aim    252;65312       AND 
%11111100 with the contents of the DAC
  2B4C 71   08 FF6A                       oim    %00001000;65386 OR 
the value 8 with a port
  2B50 7B   04 FF69                       tim    %100;65385      TEST 
bit 2 of the RS-232 pak status register
  2B54 6B   08 9F 03E8                    tim    8;[1000]        what 
does this do?
  2B59 61   80 9F A000                    oim    128;[40960]     OR 
bit #7 into the address pointed to by addresses 40960-40961
  2B5E 65   40 84                         eim    64;,x   do XOR of 64 
with memory pointed to by register X
  2B61 61   80 C4                         oim    128;,u  same as LDA 
,U ; ORA #128 ; STA ,U
  2B64 61   10 41                         oim    16;1,u  same as LDA 
1,U ; ORA #16 ; STA 1,U
  2B67 61   04 42                         oim    4;2,u   same as LDA 
2,U ; ORA #4 ; STA 2,U
  2B6A 62   80 94                         aim    %10000000;[,x]  same 
as LDA [,X] ; ANDA #128 ; STA [,X]
  2B6D 62   40 B8 02                      aim    %01000000;[2,y] same 
as LDA [2,Y] ; ANDA #64 ; STA [2,Y]
  2B71 62   20 80                         aim    %00100000;,x+   same 
as LDA ,X ; ANDA #32 ; STA ,X+
  2B74 61   10 A1                         oim    %00010000;,y++  same 
as LDA ,Y ; ORA #%00010000 ; STA ,Y++


                       *------------------------------------------------------------------------------
                       * CONDITIONAL ASSEMBLY
                       * Any symbols used in conditional expressions 
MUST be pre-resolved!
                       *------------------------------------------------------------------------------

               {TRUE}                     cond   label2=2
  2B77 1038             lab_A             pshsw  push    E/F (W) onto 
the S stack
  2B79 1039                               pulsw  pull    E/F (W) from 
the S stack
  2B7B 113D 01                            ldmd   #1      load Mode 
register with value of 1 (enable full 6309 mode)
  2B7E 34   01                            pshs   cc      push 
condition code register onto the S stack
  2B80 34   02                            pshs   a       push A 
register onto the S stack
  2B82 34   04                            pshs   b       push B
  2B84 34   06                            pshs   d       push A/B (D)
  2B86 34   10                            pshs   x       push X 
register onto the S stack
  2B88 34   20                            pshs   y       push Y 
register onto the S stack
  2B8A 34   40                            pshs   u       push U 
register onto the S stack
  2B8C 34   80                            pshs   pc      push PC 
(Program Counter) register onto the S stack
               {TRUE}                     endc   end conditional 
assembly case

               {TRUE}                     if     label2=2
  2B8E 34   02                            pshs   a       push A 
register onto the S stack
  2B90 34   04                            pshs   b       push B
               {TRUE}                     endif

               {FALSE}                    if     label2=3
                        lab_A             pshs   a  push A register 
onto the S stack
                                          pshs   b  push B
               {TRUE}                     endif

                       *------------------------------------------------------------------------------
                       * assembly-time instruction and operand pointers
                       *------------------------------------------------------------------------------

  2B92 8E   2B92                          ldx    #*      get address 
of instruction opcode
  2B95 30   8C FD                         leax   *,pcr   get address 
of instruction opcode
  2B98 BE   2B98                          ldx    *       load first 2 
bytes of instruction/operand
  2B9B 8E   2B9C                          ldx    #.      get address 
of instruction operand
  2B9E 30   8C FE                         leax   .,pcr   get address 
of instruction operand
  2BA1 B6   2BA2                          lda    .       load 1st 
byte of operand code

                       *------------------------------------------------------------------------------
                       * setting labels to the current Program 
Counter without using "label equ * "
                       *------------------------------------------------------------------------------

                        Somewhere
                        SomewhereElse
                        AnotherSomewhere
  2BA4                                    rmb    126
  2C22 20   80                            bra    SomewhereElse
  2C24 7E   2BA4                          jmp    Somewhere
  2C27 7E   2BA4                          jmp    AnotherSomewhere

                       *------------------------------------------------------------------------------
                       * ALIGNING THE PROGRAM COUNTER, INSERTING 
OPTIONAL NULL BYTES
                       *------------------------------------------------------------------------------

  2C2A                                    even   align   Program 
Counter on an even boundary
  2C2A      00                            odd    align   Program 
Counter on an odd boundary
  2C2B      00                            align  8       align PC on 
an 8-byte boundary
  2C2C      00
  2C2D      00
  2C2E      00
  2C2F      00

                       *------------------------------------------------------------------------------
                       * RECORDS/STRUCTURES
                       *------------------------------------------------------------------------------

  2C30                  person            struct
  2C30                  name              rmb    2       2 bytes for 
person's name (pointer to string)
  2C30                  weight            word   1       2 bytes for 
person's weight
                                          endstruct

  2C30                  student           struct         person
                                          endstruct
  2C30                  teacher           struct         person
                                          endstruct

  2C30 8E   0004                          ldx    #sizeof{person} get 
size of structure

  2C33 CE   2C43                          ldu    #students
  2C36 
30   40                            leax   student.name,u  point U to 
beginning of "name" field (chars)
  2C38 10AE 
42                            ldy    student.weight,u        load Y 
from "weight" field (integer)

  2C3B CE   3043                          ldu    #teachers
  2C3E 30   40                            leax   teacher.name,u
  2C40 10AE 42                            ldy    teacher.weight,u

  2C43                  students          rmb    1024    where 
records/objects are stored
  3043                  teachers          rmb    1024

                       * Forward reference to structures and unions?
                       * Not a problem.

  3443 BE   0003                          ldx    s2.ccc
  3446 BE   0003                          ldx    s1.value.ccc

                       *------------------------------------------------------------------------------
                       * NAMED UNIONS & ANONYMOUS UNIONS
                       *------------------------------------------------------------------------------

                       * named union
  3449                  s1                struct
  3449                  ddd               byte   1
  3449                  eee               word   1
  3449                  value             union
  3449                  aaa               byte   1       all union 
fields start at the same address
  3449                  bbb               word   1       regardless 
of their size
  3449                  ccc               dword  1       fields can 
be different data types, too
  3449                                    endu
                                          ends

  3449 96   03                            lda    s1.value.aaa
  344B D6   03                            ldb    s1.value.bbb
  344D DC   03                            ldd    s1.value.ccc

                       * anonymous union
  344F                  s2                struct
  344F                  ddd               byte   1
  344F                  eee               word   1
  344F                                    union
  344F                  aaa               byte   1
  344F                  bbb               word   1
  344F                  ccc               dword  1
  344F                                    endu
                                          ends

  344F 96   03                            lda    s2.aaa
  3451 D6   03                            ldb    s2.bbb
  3453 DC   03                            ldd    s2.ccc
                       *------------------------------------------------------------------------------
                       * LOCAL LABELS AND BRANCH POINTS
                       * Any label containing at least one '@' 
character is a local label.
                       * local labels can be reused if separated by a 
blank line of sourc code.
                       * Branch Points are named '!' and allow you to 
use the '<' or '>'
                       * characters to branch upwards or downwards in 
the source code to the nearest
                       * Branch Point.
                       *------------------------------------------------------------------------------

  3455 86   64          !                 lda    #50*4/2 Branch Point '!'
  3457 CC   3DFF                          ldd    #(1024+32)*15+31
  345A CC   0014                          ldd    #1+2*(3+4)+5
  345D 8E   006D        a@                ldx    #100+101/11
  3460 CC   0096                          ldd    #apple+200/2
  3463 9E   2C                            ldx    1*2+3*4+5*6
  3465 8E   050F                          ldx    #1024+8*32+15
  3468 20   1A          @d@               bra    >       branch 
downward to nearest Branch Point
  346A CD   70F2E800                      ldq    #0-100*200*300*400
  346F 8E   09F6                          ldx    #apple+apple*apple
  3472 9E   01                            ldx    apple-apple+1
  3474 86   64          @a                lda    #50*4/2
  3476 CC   3DFF                          ldd    #(1024+32)*15+31
  3479 20   E2                            bra    a@      branch to 
the "a@" above, not directly below

  347B 
CC   0014        a@                ldd    #1+2*(3+4)+5    reused 
local, possible since blank line separates other "a@"
  347E 8E   FFF6        a@@               ldx    #-(100/5*2)
  3481 8E   0064                          ldx    #99+10/10
  3484 
CC   0096        !                 ldd    #apple+200/2    another 
Branch Point '!'
  3487 9E   2C                            ldx    1*2+3*4+5*6
  3489 8E   050F                          ldx    #1024+8*32+15
  348C CD   70F2E800    @c@               ldq    #0-100*200*300*400
  3491 8E   09F6                          ldx    #apple+apple*apple
  3494 9E   01                            ldx    apple-apple+1
  3496 86   64          @b                lda    #50*4/2
  3498 20   E1                            bra    a@      branch to 
the "a@" above
  349A CC   3DFF                          ldd    #(1024+32)*15+31
  349D CC   0014                          ldd    #1+2*(3+4)+5
  34A0 8E   006E        b@                ldx    #100+100/10
  34A3 CC   0096                          ldd    #apple+200/2
  34A6 9E   2C                            ldx    1*2+3*4+5*6
  34A8 8E   050F        @@b               ldx    #1024+8*32+15
  34AB CD   70F2E800                      ldq    #0-100*200*300*400
  34B0 8E   09F6        b at b               ldx    #apple+apple*apple
  34B3 9E   01                            ldx    apple-apple+1
  34B5 20   CD                            bra    <       branch 
back/upwards to nearest '!' label

                       ; ';'semicolon commenting is now allowed as 
well as '*' commenting
                       ; the '?' character is now allowed for 
identifying local labels as well as '@'
                        ; comment
                         ;comment

  34B7 20   02          a?                bra    a?a     ;local label
  34B9 20   FE          ?a                bra    ?a      ;local label
  34BB 20   FA          a?a               bra    a?      ;local label
  34BD 30   8C FE       ?b                leax   .,pcr
  34C0      0001        ?0                fdb    1,.,3
  34C2      34C2
  34C4      0003

  34C6 A6   AF FFFF                       lda    -1,w    register W 
used as a 16-bit index register
  34CA A6   1F                            lda    -1,x
  34CC A6   3F                            lda    -1,y
  34CE A6   5F                            lda    -1,u
  34D0 A6   7F                            lda    -1,s
  34D2 A6   8D CB49                       lda    -1,pcr

                       * EDTASM-compatible operators

  34D6 86   01                            lda    #3.and.1
  34D8 C6   FF                            ldb    #.not.0
  34DA 86   00                            lda    #1.xor.1
  34DC 86   05                            lda    #10.div.2
  34DE 86   03                            lda    #255.mod.4
  34E0 86   03                            lda    #1.or.2
  34E2 86   00                            lda    #4.equ.5
  34E4 86   01                            lda    #6.equ.6
  34E6 86   01                            lda    #5.neq.6
  34E8 86   00                            lda    #5.neq.5
  34EA 8E   0000                          ldx    #(true).equ.false
  34ED 8E   0000                          ldx    #1.and.false

                       * Important note to EDTASM users: in order to 
use the .OP.
                       * operators correctly, use the CCASM -e option.  This
                       * prevents the expression evaluator from 
seeing structures
                       * and namespaces and uses the dot-named 
operators such as
                       * .not. .or. .and. .xor. correctly,
                       * or you can stay in full CCASM mode and still use these
                       * named operators by enclosing all symbol 
names in parenthesis
                       * like so:

                       * EDTASM expression mode off but still useable

               {FALSE}                    if     (false).equ.(true)
               {TRUE}                     endif
               {TRUE}                     if 
(false).or.(true).and.(true)
               {TRUE}                     endif

               {$0000}                    end

_GENERAL SYMBOLS_____________ADDRESS_______BYTES_
?00086                          34C0        0000
?a0086                          34B9        0000
?b0086                          34BD        0000
@@b0084                         34A8        0000
@a0083                          3474        0000
@b0084                          3496        0000
@c at 0084                         348C        0000
@d at 0083                         3468        0000
a?0086                          34B7        0000
a?a0086                         34BB        0000
a at 0083                          345D        0000
a at 0084                          347B        0000
a@@0084                         347E        0000
alabel                          2000        0000
anotherlabel                    2000        0000
AnotherSomewhere                2BA4        0000
apple                           0032        0000
apple3                          000A        0000
aprettylonglabel_with_underscores       2000        0000
b at 0084                          34A0        0000
b at b0084                         34B0        0000
blackcode                       2B2B        0000
col                             0008        0000
color3                          0013        0000
DIR                             0034        0000
EXT                             5678        0000
false                           0000        0000
fctest                          2998        0000
filler                          2B1B        0000
fruit                      FFFF_FFFF        0000
ilong                      0001_167E        0000
IMM                             0012        0000
label2                          0002        0000
label3                          0003        0000
label4                          0004        0000
lab_A                           2B77        0000
nlong                      FFFF_FFFF        0000
orange                     FFFF_FFFF        0000
row                             0005        0000
Somewhere                       2BA4        0000
SomewhereElse                   2BA4        0000
start                           2000        0000
students                        2C43        0000
table                           29AE        0000
tablsz                          0003        0000
teachers                        3043        0000
true                            0001        0000
yetanotherlabel                 2000        0000
_bp_0000                        3455        0000
_bp_0001                        3484        0000

_FORMAL PARAMETERS___________ADDRESS_______BYTES_

_PROCEDURES__________________ADDRESS_______BYTES_

_STRUCTURES & UNIONS_________ADDRESS_______BYTES_
person                          0000        0004
person.name                     0000        0000
person.weight                   0002        0000
s1                              0000        0007
s1.ddd                          0000        0000
s1.eee                          0001        0000
s1.value                        0003        0004
s1.value.aaa                    0003        0000
s1.value.bbb                    0003        0000
s1.value.ccc                    0003        0000
s2                              0000        0007
s2.aaa                          0003        0000
s2.bbb                          0003        0000
s2.ccc                          0003        0000
s2.ddd                          0000        0000
s2.eee                          0001        0000
student                         0000        0004
student.name                    0000        0000
student.weight                  0002        0000
teacher                         0000        0004
teacher.name                    0000        0000
teacher.weight                  0002        0000

_LOCAL VARIABLES______________OFFSET_______BYTES_


[1253 lines] [No Errors] ['test.bin' is 2185 bytes long]

decb copy -2 "Files\test.bin" "Disks\disk1.dsk","TEST.BIN"

* BUILD COMPLETE *









-- 
Roger Taylor




More information about the Coco mailing list