[Coco] Need help with Assembler Program
Robert Gault
robert.gault at worldnet.att.net
Sat Feb 2 14:08:51 EST 2008
Charles Shrader wrote:
> Greetings!
>
> I'm playing with EDTASM++ in an emulator (I've just ordered a real
> cartridge from Cloud-9) and am having
> Some problems with an "example" program I found on the internet.
>
> When I assemble, I get no errors. But when I try to execute the
> program, I get unusual results.
>
> I'm wondering if the subroutines I'm referencing aren't located where
> this listing shows them.
>
> I'm running on Dave Kiel's Coco 2 emulator. Here are some of the
> subroutines that this program calls:
>
> JSR 43304 - this is supposed to do a CLS routine.
> JSR [40962] - this should be a CHROUT subroutine.
>
> I take it that an address in brackets [] is a relative address - the
> data at memory location 40962 is
> a pointer to the actual location of the CHROUT subroutine?
>
> I'm wondering if these subroutine locations are actually for a Coco3
> perhaps??
>
> The entire test program I'm trying to get running is:
>
>
> 00100 START JSR 43304 CLS SUBROUTINE
> 00110 LDA #65 ASCII A
> 00120 AGAIN JSR [40962] CHROUT SUBROUTINE
> 00130 INCA NEXT IN ALPHABET
> 00140 CMPA #91 ONE PAST ASCII Z?
> 00150 BNE AGAIN
> 00160 LDA #32 ALPHABET DONE
> 00170 LDB #6 PRINT 6 SPACES
> 00180 REPEAT JSR [40962]
> 00190 DECB
> 00200 BNE REPEAT
> 00210 LOOP BRA LOOP
> 00210 END
>
>
> Chuck
First, that is not relative addressing but extended indirect. You are
correct about what [address] does.
The program looks good and would work except for some very important
caveats. Where will the program be located in memory? How do you know
were to go to get the program to start? Is the program going to be run
from EDTASM's ZBUG or from Basic?
As listed the program does not have an ORG (origin) statement. That
means you have no way to predict where it will reside in memory. It
won't matter much if run from ZBUG but there could be other problems. If
run from ZBUG, you may overwrite part of the EDTASM program code.
I suggest you make the following changes.
ORG $7000
00100 START JSR 43304 CLS SUBROUTINE
...
00210 END START
These changes will tell EDTASM that the program should reside in memory
starting at $7000. It also tells EDTASM that an info block at the end of
the program should contain the execution address START. Run the program
from Basic as follows:
10 CLEAR 200,&H7000
20 LOADM"TEST":EXEC
Just use whatever name the program is saved as. The clear statement will
reserve space in memory above $7000 for the program. Since the program
now contains the execution address, EXEC will start it.
More information about the Coco
mailing list