Jump to content

Photo

example ca65 startup code


5 replies to this topic

#1 danwinslow OFFLINE  

danwinslow

    River Patroller

  • 2,561 posts

Posted Fri Mar 8, 2013 10:30 AM

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

I took a look at crt0.s but its got a lot of stuff in there that probably isn't necessary and I'd like to get the smallest startup footprint possible.

Thanks

#2 Irgendwer OFFLINE  

Irgendwer

    Stargunner

  • 1,387 posts
  • Location:Germany

Posted Fri Mar 8, 2013 12:39 PM

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

Attached Files


Edited by Irgendwer, Fri Mar 8, 2013 12:40 PM.


#3 danwinslow OFFLINE  

danwinslow

    River Patroller

  • Topic Starter
  • 2,561 posts

Posted Fri Mar 8, 2013 12:54 PM

Thanks so much, Irgendwer. This is perfect.

Edited by danwinslow, Fri Mar 8, 2013 12:55 PM.


#4 danwinslow OFFLINE  

danwinslow

    River Patroller

  • Topic Starter
  • 2,561 posts

Posted Fri Mar 8, 2013 1:51 PM

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, Fri Mar 8, 2013 1:53 PM.


#5 danwinslow OFFLINE  

danwinslow

    River Patroller

  • Topic Starter
  • 2,561 posts

Posted Fri Mar 8, 2013 2:09 PM

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?

#6 Irgendwer OFFLINE  

Irgendwer

    Stargunner

  • 1,387 posts
  • Location:Germany

Posted Fri Mar 8, 2013 3:14 PM

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, Fri Mar 8, 2013 3:15 PM.





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users