Jump to content
  • 0

cc65 Newbie Questions / Mistakes


rje
 Share

Question

Getting "Hello World" to work using cl65 requires knowledge buried in the docs somewhere.

It compiles.  I load it and invoke with a "sys $a200".  I'm obviously missing something.  
OH!  Do I need to worry about BANK ZERO?
=> Answered my own question: yes, but that's not the problem, it still doesn't run.

;
; cl65 -o saludo.prg -t cx16 -C cx16-asm.cfg saludo.
;

chrout          = $ffd2
                .org    $A200
                .export LOADADDR = *

Main:           ldx #0

loop:           lda hello,x
                jsr chrout
                inx

                cpx #<(hellodone-hello)
                bcc loop

exit:           rts

hello:         .byte "--- HOLA MUNDO! ---"
hellodone:      .byte 0

Edited by rje
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

If you add this at the beginning:

```

.org $080D

.segment "STARTUP"

.segment "INIT"

.segment "ONCE"

.segment "CODE"

```

Then you can just do a regular LOAD and RUN from BASIC, no SYS call required.

After that, you need to add an inx so that you are incrementing the X register, then use bne or bmi instead of bcc for your looping branch. Also, you should count on CHROUT modifying X, so you should flank that jsr with phx and plx.

If you really do want the program in banked RAM, it gets a little trickier. You need to make sure the RAM bank register is set to something other than zero before writing to $A200, or you'll blow away the Kernal state. Generally, it's best to keep code in main RAM, and save banked RAM for data. 38k is a lot of space for code on the X16!

  • Like 2
Link to comment
Share on other sites

  • 0

Thanks for that, Matt.  I also realized, just now, that I was not loading the program correctly.  So even if I set the bank correctly, if it ain’t loaded there, ain’t gonna be where I think it is.

Now about putting ML in main RAM... I figure Furball Space Program will have a lot of BASIC as well.  So I have to make sure ML doesn’t stomp on it, or vice versa.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

Please review our Terms of Use