Page 1 of 1

cc65: How to get assembly _main called by BASIC starter?

Posted: Tue May 26, 2020 12:23 pm
by pixel
Have defined "_main" and exported it but instead __MAIN_START__ is getting called. Anyone an idea what's wrong? Thanks a lot in advance.

Re: cc65: How to get assembly _main called by BASIC starter?

Posted: Fri May 29, 2020 3:53 am
by groepaz
What you need to do is creating a linker config for assembly, look at the C64 config: https://github.com/cc65/cc65/blob/maste ... 64-asm.cfg ... copy this to vic20-asm.cfg and adjust the memory addresses. now you link the program like described (for C64) here: https://cc65.github.io/doc/c64.html#ss4.2 (and once you made it work, please submit the linker config and updated docs to cc65 repo)

Re: cc65: How to get assembly _main called by BASIC starter?

Posted: Sun May 31, 2020 12:42 pm
by pixel
groepaz wrote: Fri May 29, 2020 3:53 am What you need to do is creating a linker config for assembly, look at the C64 config: https://github.com/cc65/cc65/blob/maste ... 64-asm.cfg ... copy this to vic20-asm.cfg and adjust the memory addresses. now you link the program like described (for C64) here: https://cc65.github.io/doc/c64.html#ss4.2 (and once you made it work, please submit the linker config and updated docs to cc65 repo)
Thanks man, but I really need to know the trick to getting _main called.

Re: cc65: How to get assembly _main called by BASIC starter?

Posted: Mon Jun 01, 2020 4:37 am
by groepaz
there is no trick :) you'll have to post all of your non working code (including the exact commands used to build it) in order to find out whats wrong.

mind you, if you are not using C, then using the default linker config and _main as entry point is probably not what you want - since a lot of unnecessary things will happen, and you'll have to link library stuff that you probably dont need.

("__MAIN_START__" shouldnt ever get "called" btw, its not a code entry point at all - when that really happens its an indication of something else being wrong in your setup)

Re: cc65: How to get assembly _main called by BASIC starter?

Posted: Fri Jun 05, 2020 3:13 pm
by pixel
Here it is. https://github.com/SvenMichaelKlose/ing ... tifs-wedge

Went into Terminator mode trying to contribute once too often.

Re: cc65: How to get assembly _main called by BASIC starter?

Posted: Sat Jun 06, 2020 10:20 am
by groepaz
the problem is that you are only linking to vic20.lib... you either must link to the crt0.o explicitly, or use .forceimport __STARTUP__ (which will pull in the crt0.o) in the asm file (or really...anywhere).

Re: cc65: How to get assembly _main called by BASIC starter?

Posted: Mon Jun 22, 2020 7:29 am
by groepaz
Did it work? :)

Re: cc65: How to get assembly _main called by BASIC starter?

Posted: Wed Jul 08, 2020 11:03 pm
by pixel
groepaz wrote: Mon Jun 22, 2020 7:29 am Did it work? :)
Yep! Just tried with "forceimport". Thanks! :)