Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question/feature] Where is the MC10 code located by default? #20

Open
Fabrizio-Caruso opened this issue Apr 11, 2022 · 8 comments
Open
Labels
enhancement New feature or request

Comments

@Fabrizio-Caruso
Copy link

Fabrizio-Caruso commented Apr 11, 2022

Where is the code for the MC10 target located by default when compiled by running the following command?

cc68 -tmc10 foo.c -o foo

Is it located at $4200 just after text mode video ram?
I am asking because I fear that this would break any program that uses graphics mode (as they may take 3k or $4000-$4BFFF) if I am doing the math correctly.

Where are the different sections in memory? rodata? Maybe the code starts at $4C00 but it maybe the C software stack or the rodata is somewhere in $4000-$4BFFF and it is interfering with the graphics.

I have tried to use the -C and --start-addr options with cc68 but they are not available.
I have not found a cfg linker file to control where the sections are in memory (such as the ones in CC65).

Is there a way to output a map file that shows where variables are in memory?

I see there may be a way to do this by using the linker ld68 command, though.

@EtchedPixels
Copy link
Owner

The -C option to the linker sets the code address (-B bss -D data, but those otherwise just follow the code) and -Z for the direct page

The default for the MC10 is -b -C 17500 -Z 0x90 (-b is binary)

The machine locates its own system variables and possibly stack (not sure where basic puts it initially) straight after the video
memory. It also vectors the interrupts there, so you can't use the internal interrupt timer in graphics mode unless you are very clever (and work a jump bit pattern into the fixed part of your graphics at the right spot)

@Fabrizio-Caruso
Copy link
Author

Fabrizio-Caruso commented Apr 12, 2022

Thanks for replying!
"Hires" 4 color 128x96 graphics takes $4000-$4BFF (19455). So a more general default would be $4C00 (19456), because it would allow all programs to run at the cost of memory when no graphics is used.
Strangely I can have a loop writing into $4000-$4BFF without a crash/freeze.
I am compiling with the cc68 but I see that I should do it with the linker command to avoid such problems.
Is there a way to tell the high level command cc68 to start at $4C00 (so that programs with graphics would run without a crashing)? Would you please consider adding an option for this in the future?

@Fabrizio-Caruso
Copy link
Author

If the top level cc68 command does not have an option for the start-address, would you please consider having such an option to pass it to the linker for the sake of convenience? If that is not possible or too much work, would you consider $4C00 as default?

For my specific case I can rewrite my Makefile to use the explicit compile only cc68, the linker command and the tool to generate a tape image as separate commands.

@EtchedPixels
Copy link
Owner

17500.. it's the right start spot for most MC-10 code, especially as you've usually on got 4K of RAM.

I'll look at a setting to change the code base or a variant MC10 build type.

@EtchedPixels EtchedPixels added the enhancement New feature or request label Apr 12, 2022
@Fabrizio-Caruso
Copy link
Author

@EtchedPixels I understand. If a setting is too much of a hassle, a second target, e.g mc10exp, with start address at $4C00 (19456) should also do because $0C00=3k=128x96 in 4 colors, which is the highest possible resolution on an unmodified M-10.
For the unexpanded mc10, why exactly 17500? If my math is correct, $4200 (16896) would be enough for the default screen text mode and provide more memory for the code. Plain text mode should only take 32x16=512 ($0200) bytes.
So my guess is that maybe you wanted to leave 1k for the super low res graphics 64x64 in 4 colors.

@EtchedPixels
Copy link
Owner

17500 was what I was told to use - I assume there's a bit below it still being used by basic and system variables on the load/exec.

@Fabrizio-Caruso
Copy link
Author

@EtchedPixels I am no expert. I would like to run some experiments with lower and higher start address. Do I only need to change all occurrences of 17500 in cc.c or is 17500 also coded elsewhere?

@EtchedPixels
Copy link
Owner

It's only in cc.c I think - and maybe in tapeify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants