Assembler help for my X16-HELP.

All aspects of programming on the Commander X16.
Post Reply
rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

Assembler help for my X16-HELP.

Post 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 ***"

User avatar
JimmyDansbo
Posts: 476
Joined: Sun Apr 26, 2020 8:10 pm
Location: Denmark
Contact:

Assembler help for my X16-HELP.

Post by JimmyDansbo »


curpos is a label, can you increment a label?

 

Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
Stefan
Posts: 465
Joined: Thu Aug 20, 2020 8:59 am

Assembler help for my X16-HELP.

Post 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

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

Assembler help for my X16-HELP.

Post by rje »


Yes, I should be indexing!  Thank you Stefan.

Post Reply