[Coco] Assembler Help

Robert Gault robert.gault at worldnet.att.net
Sun Aug 17 00:49:29 EDT 2008


Charles Shrader wrote:
> Hi all!  I thought I'd break into something other than the recent copyright
> discussion and ask for some help with an odd Assembler language question.
> 
> I'm using EDTASM++.BIN.  I've written a very simple program that clears the
> screen, then waits for the user to type in eight characters.  Once eight
> characters have been typed in, the program outputs to the screen a space,
> then outputs a repeat of the string.  Very simple.
> 
> When I assemble and run this in the Z-Debugger, it runs fine, although the
> RTS at the end of the code causes unusual results.  But I can see before the
> system goes hay-wire that on the top line, my entry is repeated:
> 
> ABCDEFGH ABCDEFGH.
> 
> This runs fine also if I change the RTS line to a line that just brances to
> itself over and over.  This keeps the system from going nuts.
> 
> Now if I compile the program to disk and execute the .BIN file, my output
> is:
> 
> ABCDEFGH BCDEFGH
> 
> (Where did the first A go in the echoed second string??)
> 
> I'm totally perplexed as to why this is happening.  It's like my x index is
> not pointing to the correct start byte of STMP.  (See below)
> 
> I'll include the code below; perhaps someone here more knowledgeable than I
> may be able to figure out what's going on.  I'm doing this in the David Keil
> emulator for the Coco3 with 128K RAM:
> 
> 00100                ORG             $3F00   ;Start location of code
> 00110 START          JSR             43304   ;Clear Screen
> 00120                LDB             #0      ;Initialize register B
> 00130                LDA             #0      ;Initialize Accumulator
> 00135                STA             DEVNUM  ;Output to screen
> 00140                LDX             STMP    ;Load start address of storage
> location STMP
> 00150 LOOP           JSR             $A1C1   ;Poll for keypress
> 00160                CMPA            #0      ;Compare vs 0.  If 0, no key
> was pressed.
> 00170                BEQ             LOOP    ;No keypress so keep polling
> 00180                STA             ,X+     ;Store keypress in STMP and
> move byte pointer
> 00190                JSR             [40962] ;Output keypress to screen
> 00192                INCB                    ;Increment counter
> 00194                CMPB            #8      ;See if 8 keys have been
> pressed
> 00200                BNE             LOOP    ;Keep polling until 8 keys have
> been pressed
> 00210                LDX             STMP    ;Point to start of STMP so we
> can echo output
> 00220                LDA             #32     ;Load A with ASCII code for
> 'Space'
> 00230                JSR             [40962] ;Output character to screen
> 00240 LOOP2          LDA             ,X      ;Load A with first character of
> stored string
> 00250                JSR             [40962] ;Output to screen
> 00260                CMPX            #8      ;Have we displayed all 8
> characters?
> 00270                BNE             LOOP2   ;If not, get next character in
> string
> 00280                RTS                     ;Return to caller
> 00290 STMP           RMB             $09     ;Define storage area STMP
> 00300 DEVNUM         EQU             $6F     ;Location where output is
> designated
> 00310                END             START
> 
> Thanks for any help,
> 
> Chuck
> 

There is some code that can be cleaned up but that is a matter of style. 
What I see wrong is in loop2.

lda ,x   should be lda ,x+
cmpx #8  should be cmpb #8  preceded by an incb
regB should be cleared   231  clrb

When I made these changes, the program worked for me under Basic. To get 
it to work in EDTASM the rts should be replaced with swi. You should 
also make sure the program does not assemble over and corrupt EDTASM.



More information about the Coco mailing list