[Coco] 6809 example

Robert Gault robert.gault at worldnet.att.net
Sun Jan 18 23:39:59 EST 2004


Theodore (Alex) Evans wrote:
> On Jan 18, 2004, at 4:16 PM, Robert Gault wrote:
> 
>> If you run your program from within EDTASM+, it will crash because you 
>> ended it with an RTS. Programs running under EDTASM+ DEBUG must end 
>> with SWI.
> 
> 
> Point taken.  I haven't been using ESTASM+ a whole lot lately.  Looking 
> back, Barden generally had his samples go into an infinite loop so 
> instead of "rts" or "swi" he had "done jmp done".  It was mainly 
> presented as a counter argument to the claim that you would need to have 
> a complex output routine to do Hello, World without an OS call would be 
> complex.  Of course unless the routine was truly stand alone the proper 
> way would simply be to set things up for and perform an OS call hardly a 
> good example, though I have seen assembly language instruction which 
> starts with just such an example.
> 
> 

Actually things are not quite so simple if you want a generic printing 
routine. See below.

One of the significant differences between a high and low level language 
is the interaction with hardware. With a high level language like Basic, 
all you need to do is say PRINT and the OS will take your message and
convert it as needed so that it matches the requirements of your screen
hardware. With assembly language, you need to know the specification of
your hardware and make all adjustments yourself.

Regards printing, you need to know that there is something called the
ASCII Character Set. This set runs from $00 to $7F. The letters A-Z have
values $41-$5A and the letters a-z have values $61-7A. The next thing
you need to know is that on the Color computer low res screen, POKEing 
lower case ASCII values will not print anything useful.

When I copied Theodore's program, I accidentally made the FCC statement
HELLO, WORLD. The program cleared the screen to black and then printed
black letters on a green background. When I corrected the FCC statement
to "Hello, world" as written, only the H and W printed correctly.

To find out what is going on here, just write a Basic program to POKE 
all values from $00-$FF to the low res screen to find out what the 
values do. This will give you, not the ASCII set, but the Coco low res 
screen set.

So to get a green screen you need to store $60 as Paul mentioned. What 
do you find is needed for green letters on black background and what for 
black letters on a green background?

You could modify Theodore's program to change the contents of the fcc
statement to get the color combinations you want or you could change the 
loop. How would you change the loop so that lower case letters print 
correctly? How should you change the loop to get numbers printed 
correctly? By the way, since you really don't want the $00 to print, the 
exit test should be before the store instead of after.

   Original                 Suggested
wrtlp:
     lda ,y+
     sta ,x+                beq   quit
     bne wrtlp              sta   ,x+
     rts                    bra   wrtlp
                    quit    rts          if run from Basic
                    quit    swi          if run from EDTASM+ DEBUG
hello:
     fcc 'Hello, World'
     fcb 0

How might you modify the program if you did not want to use the fcb $00 
as an exit test?





More information about the Coco mailing list