Page 1 of 1

Assembler help for my X16-HELP.

Posted: Mon Nov 09, 2020 5:35 pm
by rje

So I wrote a proof-of-concept "help" program, and at some point things just get confused.  It just cats text to the screen... what could possibly go wrong??

I figure I'm too close to the code, PLUS there's something subtle about assembly language that trips up my newbie asm mind.

 

I've abbreviated the data section, because, you know.

 

;
; cl65 -o help.prg -t cx16 -C cx16-asm.cfg help.s
;
chrout          = $ffd2
;       .segment "STARTUP"
;       .segment "INIT"
;       .segment "ONCE"
;       .segment "CODE"
                .org    $8000
                .export LOADADDR = *
Main:   ldx #0
        lda curpos
loop:   jsr $ffd2
        inc curpos
        lda curpos
        cmp #0
        beq newline
        cmp #42         ; '*' = EOF
        bne loop        ; no
        rts
newline:
        lda #13
        jmp loop
curpos:
text:
        .asciiz "abs(n)"
        .asciiz "and; boolean or bitwise"
        .asciiz "asc(c$); petscii value"
        .asciiz "*** end of file ***"


Assembler help for my X16-HELP.

Posted: Mon Nov 09, 2020 6:05 pm
by JimmyDansbo

curpos is a label, can you increment a label?

 


Assembler help for my X16-HELP.

Posted: Mon Nov 09, 2020 7:12 pm
by Stefan

You can increase a label. Without testing the code, I think it in this case will increase the value of the first char in the first string. Not what rje intended.

You need to use an index. Assuming that the strings do not fit within 256 bytes you could use indirect indexed addressing mode, for example:

lda #<text

sta $30

lda #>text

sta $31

ldy #0

loop: lda ($30),y

cmp #'*'

beq eof

jsr $ffd2

iny

bne loop

inc $31

jmp loop

eof: rts


Assembler help for my X16-HELP.

Posted: Mon Nov 09, 2020 11:26 pm
by rje

Yes, I should be indexing!  Thank you Stefan.