[Coco] Color Forth Help Request

Darren A mechacoco at gmail.com
Fri Feb 20 20:16:58 EST 2015


On Fri, Feb 20, 2015 at 4:20 PM, Stephen Pereira <spereira1952 at comcast.net>
wrote:

> Here is my code:
>
> *
> * BRUTE FORCE ROUTINE TO LOAD SCREENS 1 THRU 8
> * USING THE DECB LOADM ROUTINE
> * JAN 2015, SMP
> * ERROR CHECK & ADVICE FROM BRETT GORDON
> *
>         FCB     $84,'L,'S,'C,'R+$80
>         FDB     SSCR-7
> LSCR    FDB     *+2
>         PSHS    CC,A,B,DP,X,Y,U SAVE ALL JUST IN CASE
>         LDX     #$094C  CLEAR FILE NAME LOCATION
>         LDA     #32
> L3      STA     ,X+
>         CMPX    #$0954
>         BNE     L3
>         LDX     #$094C  FILE NAME LOCATION
> L4      JSR     $A1B1   GET KEY IN A
>         TFR     A,B     SAVE KEY IN B
>         PSHS    B,X,Y
>         JSR     [$A002] ECHO KEY
>         PULS    Y,X,B
>         TFR     B,A     GET KEY IN A
>         CMPA    #13     CR?
>         BEQ     NXT2    CR ENDS LOOP
>         STA     ,X+     STORE KEY IN FILE NAME
>         CMPX    #$0954  DONE IF 8 KEYS
>         BNE     L4
> NXT2    LDX     #$0954  FILE EXTENSION LOCATION
>         LDA     #$42    B
>         STA     ,X+
>         LDA     #$49    I
>         STA     ,X+
>         LDA     #$4E    N
>         STA     ,X
>         LDD     #$0200  FILE TYPE = 2, ASCII FLAG = 0
>         STD     $0957
>         LDX     #$0000
>         STX     #$00D3  OFFSET = 0
>         JSR     $CA07   OPEN NEXT AVAIL FILE FOR INPUT
>         LDD     #RET2   RETURN ADDR FOR LOADM RTS
>         PSHS    D
>         JMP     $CFE3   LOADM
> RET2    PULS    U,Y,X,DP,B,A,CC RESTORE ALL
>         JMP     NEXT    RETURN TO FORTH
>
> This code works fine on a stock CoCo 3, as well as in VCC with a 6809
> CPU.  It is not elegant, and I don’t think I tried any fancy stuff.  Don’t
> worry about the first few lines of code - they are for linking into Color
> Forth, and that seem to be fine.
>
> As far as I can tell, this code does not initiate any disk activity when
> the CPU is a 6309, the machine simply goes off into never-never-land.
>
> Thanks, in advance, for whatever observations or advice you may have to
> offer.
>


The code listing above contains an illegal instruction. In particular:

        STX     #$00D3  OFFSET = 0

You can't use an immediate operand with STX. If that is how it actually
appears in your source code then it should be fixed.  I would be surprised
that an assembler accepts that without an error or warning.

- Darren


More information about the Coco mailing list