[Coco] CCASM procedures working!
Roger Taylor
rtaylor at bayou.com
Tue Dec 7 22:43:16 EST 2004
Well, here is one of the first sample programs I assembled along with the
listing so you can see what code is generated automatically by the
assembler. The programs I have tested are working, so I'll do a little
more testing before I release CCASM 2.93.
In the following program, I define a procedure called "fillmem" which has 3
formal parameters: start, len, byte
When I "call" the procedure, I pass in 3 values which are transposed to
their formals so that the procedure can access them.
The parameters are accessed as offsets into the S stack. Currently, there
is no support for local variables inside of procedures except for the
formal parameters. I have not tested embedded procedures yet, where one
procedure calls another.
org 3584
screen equ 1024
scrsiz equ 512
color equ 128
fillmem proc start:word,len:word,filler:byte
ldx start,s
lda filler,s
ldy len,s
a@ sta ,x+
leay -1,y
bne a@
rts
endproc
start call fillmem,screen,scrsiz,color
call fillmem,1024,512,128
rts
end start
the listing:
CCASM 2.93: assembling cross6809.asm to pro.bin
org 3584
{$0400} screen equ 1024
{$0200} scrsiz equ 512
{$0080} color equ 128
fillmem proc
start:word,len:word,filler:byte
0E00 AE 62 ldx start,s
0E02 A6 66 lda filler,s
0E04 10AE 64 ldy len,s
0E07 A7 80 a@ sta ,x+
0E09 31 3F leay -1,y
0E0B 26 FA bne a@
0E0D 39 rts
endproc
0E0E 8680 start call fillmem,screen,scrsiz,color
0E10 3402
0E12 CC
0E13 0200
0E15 3406
0E17 CC
0E18 0400
0E1A 3406
0E1C BD
0E1D 0E00
0E1F 3265
0E21 8680 call fillmem,1024,512,128
0E23 3402
0E25 CC
0E26 0200
0E28 3406
0E2A CC
0E2B 0400
0E2D 3406
0E2F BD
0E30 0E00
0E32 3265
0E34 39 rts
{$0E0E} end start
color =[ 0080] _pr_fillmem_start =[0002_0002]
start =[ 0E0E] a at 0007 =[ 0E07]
_pr_fillmem_len =[0002_0004] screen =[ 0400]
_pr_fillmem_filler =[0001_0006] scrsiz =[ 0200]
_pr_fillmem =[ 0E00] _pr_fillmem_3 =[0001_0006]
_pr_fillmem_2 =[0002_0004] _pr_fillmem_1 =[0002_0002]
[22 lines] [No Errors] ['pro.bin' is 63 bytes long]
Note that the automatic code created by the CALL function is not formatted
in the listing, so it looks kinda rough right now for those who can read
raw ML. Still, this is major progress.
Anybody up for writing a stdlib or graphics lib? :)
--
Roger Taylor
More information about the Coco
mailing list