[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Converting 6502 Asm to PIC
On Nov 25, 1:06 pm, Toinet <antoine.vig...@laposte.net> wrote:
> On 24 nov, 23:30, PIC Newbie <allenbsf6...@gmail.com> wrote:
>
>
>
>
>
>
>
> > MESSAGE STR 'APPLE 2 FOREVER'
>
> > MAIN LDX #1 ;POINT TO FIRST ASC
> > MESSLOOP:
> > LDA MESSAGE,X
> > CMP $32
> > BNE CONV
> > SPACE JSR INT_WORD_DLY ;DELAY 6 DOT ELEMENTS ~500MS
> > CLC
> > BCC SPACE_OK
> > CONV JSR CONVERT ;CONVERT ALPHA-NUMERIC TO INDEX
> > SPACE_OK:
> > INX
> > CPX #MESSAGE+1 ;END OF MESSAGE?
> > BCC MESSLOOP
> > RTS
>
> > TIA,
>
> > Allen
>
> I would have written...
> SPACE_OK:
> INX
> CPX MESSAGE ;END OF MESSAGE?
> BCC MESSLOOP
> RTS
> ...instead of CPX #MESSAGE+1.
> The length of the string is saved in the first byte of MESSAGE not the
> second. Unless this is due to the assembler but I doubt it.
>
> I have another question regarding $32. Is there a useful info saved on
> zero page offset $32 or is it the space character (#32 or #$20)?
>
> Thank you,
> antoine- Hide quoted text -
>
> - Show quoted text -
Yes, you are absolutely right. After checking the object code
generating. I found out the result wasn't what I was expecting. I
thought CPX #MESSAGE+1 should give me the "content of message" + 1,
and it ended up as the lower byte address of (Message + 1). $32 is a
typo, it should be #' '. thanks for pointing out my mistakes. The
corrected one is as below:
ORG $800
;using LISA 2.5 by Randy Hyde
JMP main
MESSAGE STR 'APPLE 2 FOREVER'
;str will generate the message in normal ASC with the number of
characters as the first byte
MAIN LDX #0 ;POINT TO FIRST ASC
MESSLOOP:
LDA MESSAGE+1,X
CMP #32
BNE CONV
SPACE JSR INT_WORD_DLY ;DELAY 6 DOT ELEMENTS ~500MS
CLC
BCC SPACE_OK
CONV JSR CONVERT ;CONVERT ALPHA-NUMERIC TO INDEX
SPACE_OK:
INX
CPX MESSAGE ;END OF MESSAGE?
BCC MESSLOOP
RTS
Allen