Jump to content
IGNORED

example ca65 startup code


Recommended Posts

Does anyone have an example of a stand-alone ca65 program startup using the standard atari.cfg ?

 

Attached - just changes console color to grey.

Build by 'executing' "MakeMain.bat". Since the linker likes to have some symbols, I built my own config.

Normally you have to fiddle with the config anyway to fulfil A8's memory constraints for screen, DL, font(s) and PMGs without using the dissipative .ALIGN...

MinimalASM.zip

Edited by Irgendwer
  • Like 1
Link to comment
Share on other sites

More questions, if you don't mind. What you gave me seemed to work fine, although it locks up at the end due to the the endless jmp loop you put there. Not sure why you did that, but I assumed I could replace it with a rts and all would be well. So far so good.

 

Then I added some data value, with the code as such to place a 512 byte buffer somewhere:

.include "atari.inc"

.CODE
.proc Main
lda #6
sta 710
		 rts;
END:
.endproc

.SEGMENT "EXEHDR"
.word $FFFF
.word Main
.word Main::END - 1

.segment "AUTOSTRT"
.word RUNAD ; defined in atari.h
.word RUNAD+1
.word Main

.segment "DATA"
packetdata: .res 512


 

This resulted in crashes, so I tried moving it around, etc, and it always seemed to produce some kind of bad effect, either crashes or an 'error 146', which I assume to be a spurious error. So, I'm left with the impression that I don't understand something significant about how to lay out the code. The linker shows the "DATA" segment as part of RAM, which seems to be laid out correctly in the file. What am I not understanding...

Edited by danwinslow
Link to comment
Share on other sites

Well, so in looking at the binary file format...the exehdr would be too short ( END would not have been incremented to include the 512 byte of data... ) and so the loader would have maybe thought the data buffer was actually an INITADR or something. So, if I locate the buffer between proc Main and END: it should work out...and it did.

 

So in this layout I'd have to place all code and data between those two spots?

Link to comment
Share on other sites

So in this layout I'd have to place all code and data between those two spots?

 

Yes, or you have to adapt "EXEHDR" end address. Since in this case CODE and DATA are consecutive, this shouldn't be a problem.

If not, you have to add an additional data segment file header for the output file too (source and memory config).

But if you like to 'reserve' just some data, BSS is better suited since it won't be written to the output file.

 

One of cc65's strongest points, but also highest entry threshold is the memory configuration. It's really the backbone of your output.

Edited by Irgendwer
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   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.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...