I'm trying to run a program that requires a bit more RAM than the
default configuration and I can't figure what I'm doing wrong.
cl65 -c -t apple2 -C apple2-system.cfg -o program.o program.c
cl65 -t apple2 -C apple2-system.cfg -m program.bin.map \
-o program.bin program.o
I can see in `appledump` that the header differs and '20 00' appears in
place of '08 03' which means that this configuration seems to change something.
But after this, I can neither 'BRUN PROGRAM' (crashes right away) nor
start it from a loader.system named PROGRAM.SYSTEM.
The documentation on internet is sparse and I'd love to get a few
pointers.
I'm trying to run a program that requires a bit more RAM than the
default configuration and I can't figure what I'm doing wrong.
Which is the environment you want to run the program in? DOS3.3,
ProDOS, ...?
cl65 -c -t apple2 -C apple2-system.cfg -o program.o program.c
There's no point in having a linker configuration file (-C *.cfg) on a compile-only command line.
cl65 -t apple2 -C apple2-system.cfg -m program.bin.map \
-o program.bin program.o
There's no point in having a target definition (-t apple2) beside a
linker configuration file on a link-only command line.
In general, there's no need for separate compile and link command
lines when just generating a program from a single source file.
Apart from that, I don't see that using apple2-system.cfg could help
you to have more RAM available. Actually pretty much the opposite.
I can see in `appledump` that the header differs and '20 00'
appears in place of '08 03' which means that this configuration
seems to change something.
For sure it does. If you don't know what it does, why do you use it?
A program generated with apple2-system.cfg isn't supposed to be
invoked in either way.
There are diverse environments to run Apple II programs in. Therefore
it is hard to provide specific guidance. The existing documentation
(authored by me) rather presumes that you exactly know "your"
environment and only provides hints on how to make the cc65 linker do
what you want it to do.
[environment?]
ProDOS.
I've simplified the command in the example for clarity, but in reality
this one builds with 2 .o's, so I suppose this is needed ?
I'm aware it is a lot of questions at once, I hope I'm not asking too
much :) I'd love to understand better what I'm doing instead of just
crossing fingers my program and data will fit!
There's no point in having a target definition (-t apple2) beside a
linker configuration file on a link-only command line.
In general, there's no need for separate compile and link command
lines when just generating a program from a single source file.
Hi again Oliver,
There's no point in having a target definition (-t apple2) beside a
linker configuration file on a link-only command line.
In general, there's no need for separate compile and link command
lines when just generating a program from a single source file.
I use both -t and -C because if removing -t apple2, I'm getting errors
which makes me think it's trying to compile for c64? :
(The differences between apple2.cfg and loader.cfg are:
- __HIMEM__: type = weak, value = $9600; # Presumed RAM end
+ __HIMEM__: type = weak, value = $BF00; # Presumed RAM end
[snip]
cc65 linker configurations aren't 100% stable. So you are strongly
advised to _not_ copy one, just edit a value or two and use the copy.
This tends to make your build break in ways you don't understand with
later cc65 versions. You're far better off with setting __HIMEM__ from
the command line as shown in the documentation.
Thanks a lot for all the details, Oliver, that helps a lot, and is >appreciated!
cc65 linker configurations aren't 100% stable. So you are strongly
advised to _not_ copy one, just edit a value or two and use the copy.
This tends to make your build break in ways you don't understand with
later cc65 versions. You're far better off with setting __HIMEM__ from
the command line as shown in the documentation.
Hi!
cc65 linker configurations aren't 100% stable. So you are strongly
advised to _not_ copy one, just edit a value or two and use the copy.
This tends to make your build break in ways you don't understand with
later cc65 versions. You're far better off with setting __HIMEM__ from
the command line as shown in the documentation.
I've done some more tests, and am still under the impression that
binaries produced with -Wl -D__HIMEM__=0xBF00 and -Wl
-D__HIMEM__=0x9600 are exactly the same.
But I've also noticed, using this test file, that the available memory
is somehow automatically made known by the loader.system mechanisme ?
https://github.com/colinleroy/aoc2022/blob/master/a2tools/src/ramtest/ramtest.c
When ran using `BRUN RAMTEST`, _heapmemavail() tells me about 28kB,
whereas when using `- RAMTEST.SYSTEM`, it tells me about 38kB.
The malloc()/memset() loop then allocates and clears what is expected
without crash.
Do I have the correct impression?
PS - on the other hand, -Wl -D,__STACKSIZE__= produces a different
binary and is clearly taken into account.
Thanks!
When you BRUN a program, you've got BASIC.SYSTEM loaded and thus its
memory is marked as allocated by ProDOS; everything from $9600 and up.
When you run a system program, i.e. `- RAMTEST.SYSTEM`, BASIC.SYSTEM
has been discarded, and you have the memory from just after your
system program up to $BEFF available. ProDOS reserves the
$BF00-$BFFF page for its global page.
I've done some more tests, and am still under the impression that
binaries produced with -Wl -D__HIMEM__=0xBF00 and -Wl
-D__HIMEM__=0x9600 are exactly the same.
But I've also noticed, using this test file, that the available memory
is somehow automatically made known by the loader.system mechanisme ?
When ran using `BRUN RAMTEST`, _heapmemavail() tells me about 28kB,
whereas when using `- RAMTEST.SYSTEM`, it tells me about 38kB.
The malloc()/memset() loop then allocates and clears what is expected
without crash.
Do I have the correct impression?
PS - on the other hand, -Wl -D,__STACKSIZE__= produces a different
binary and is clearly taken into account.
Yes, this is a feature. If your program is small enough to load both
directly and via loader.system, then you can chose if you want to
directly return with less heap memory or quit to the ProDOS
dispatcher with more heap memory.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 490 |
Nodes: | 16 (2 / 14) |
Uptime: | 59:21:39 |
Calls: | 9,676 |
Calls today: | 7 |
Files: | 13,719 |
Messages: | 6,171,346 |