[Coco] 6809 example

Roger Taylor rtaylor at bayou.com
Mon Jan 19 23:36:30 EST 2004


At 09:45 AM 1/18/2004 -0800, you wrote:
>This looks a little above the skill set for a newbie like me.  I've sort 
>of lost track of this thread, but it looks like the code below is Basic, 
>not Assembly.  Right - wrong?
>
>Does anyone have some sample assmbly that they can post privately.  Also, 
>can someone please remind me again what is the difference between running 
>EDASM+ on a CoCo 2 and a CoCo 3

There are a handful of EDTASM versions out there that may look a little 
different than the others or act different, but they all accept 6809 
instructions and output 6809 code.

Maybe you can start with some example code that moves data around.  This is 
something you'll be doing a LOT.  You can't change an actual memory address 
or a CPU register, because they are only holders for data, but you can 
always change the data that's stored in either place, and always move data 
around.

You can move data:
1) from one register into another register
2) from a memory location into a register
3) from a register into a memory location

This is not saying that you'll be moving "the memory location" into a 
register, or "the register" into a memory location, but rather the data 
stored in those holders will be COPIED into another location.  An address 
always stays where it's at.  A CPU register stays where it's at, too.  Data 
can be cloned and stored in other places.  In other words, it doesn't leave 
a void behind when you move the data, but shares the data with some other 
holder.  You can also modify data without moving it from it's holder.  It's 
all in how you build your instructions.  You can "LOAD, STORE, TRANSFER, 
INCREMENT, DECREMENT, ADD, SUBTRACT, MULTIPLY" data... among many other 
things, but without altering data in some fashion, you're not going to have 
a very useful program.  :)

Here's a little snip that lets you see a piece of data being altered, and 
very fast.  It changes the upper-left character of the 32-column green 
screen so you can see the program running.

         org     8192    ; <-- specify where the program will reside in 
memory at run-time
start   lda     #65     ; starting out, we load the A register a value (65 
for no logical reason)
loop    tfr     a,b     ; this transfers the data that's in register A into 
register B
         stb     1024    ; store the data that's in register B into the 
memory location 1024
         inca            ; increment the value in A (add 1)
         bra     loop    ; branch back to the label "loop" forever

Since the B register was just used to show how to move data inter-register, 
we can remove the tfr instruction and achieve the same visual result:

         org     8192    ; <-- specify where the program will reside in 
memory at run-time
start   lda     #65     ; starting out, we load the A register a value (65 
for no logical reason)
loop    sta     1024    ; store the data that's in register A into the 
memory location 1024
         inca            ; increment the value in A (add 1)
         bra     loop    ; branch back to the label "loop" forever

Oh, and because it runs so fast, and the initial value of 65 will never be 
seen or noticed, the same visual result can be achieved using:

         org     8192    ; <-- specify where the program will reside in 
memory at run-time
loop    sta     1024    ; store the data that's in register A into the 
memory location 1024
         inca            ; increment the value in A (add 1)
         bra     loop    ; branch back to the label "loop" forever

And lastly.... this program will do the same thing as all of the above, 
only faster.

         org     8192    ; <-- specify where the program will reside in 
memory at run-time
loop    inc     1024    ; increment (add 1) to the data that's stored in 
address 1024
         bra     loop    ; branch back to the label "loop" forever

I always thought that "seeing" a program run was the best part of learning 
the 6809, so I hope the above examples help a little in understanding how 
fast data can be moved around and altered.


----------
Roger Taylor






More information about the Coco mailing list