Hi, I am working on a larger project and need to understand better how the structuring in files and the placing in memory works.
The project will be a pure assembler project and also will not use any BASIC operation.
Question 1:
I will need to define a lot of variables inside ZP. As far as I understood I can use $02-$7F and $A9-$AF. How do I need to setup the cx16.cfg ZP directive, that it does automatically assign the bytes to the allowed windows?
This does work (e.g compiles) to enable more ZP bytes then the normal $20-$7F ... but it obviously would just overwrite $80- $A8, which is unsave for the Kernal and might crash the machine (makes kernel functions unusable).
Question 2:
Maybe related to the first one: As I do not know how many variables I will have and may want to change them during the development process and they all have different length, I want to use the .res statement to define the length of each variable and using labels to get the symbols for the addresses of each ZP.
I did something like that:
Quote
.exportzp ZP,RAND,TRTB
.segment"ZEROPAGE": zeropage
ZP:
.res 0; The start of the zero page workspace.
RAND:
.res 4; Four 8-bit seeds for the random number generation
; system implemented in the DORND routine
TRTB:
.res 2; This is set by elite-loader.asm to point to the MOS
; keyboard translation table, which is used by the TT217
; routine to translate internal key values to ASCII
As my ZP segement starts @$02 ZP will point to $02 as well as RAND and TRPTB will point to $06. My issue with that is, that the compiler will actually create code and place it into memory after loading. Is there any other way of automatically (in opossition to calculate everything manually) define some symbols (e.g. memory addresses) but not get it actually compiled into the source code?
I can see the EXTZP segment in the cx16-asm.cfg ... but what does it mean? It has not been defined.
Also I do not understand how to load things like LOADADR correctly. It is getting imported... from where?
That brings me to my question 3:
I like to have a main PRG file (e.g. loader) and some .bin files that keep individual parts of the real program, such as models or math library or main loop etc.
From the file structure I do understand how to create multiple source files and exporting symbols I want to use from outside. However how do I instruct the assembler/linker to create a .bin file out of a given object file?
Lets assume I want to have the following three files out of the input files:
Loader.s => LOADER.PRG
math.s => GAME1.BIN
models.s => GAME2.BIN
mainloop.s => GAME3.BIN
Question 4:
Also I want to instruct the linker to put the GAME2.BIN @$A000 to be able to use it in a BANK. How can I use multiple BIN files using the same address space, as they are all sitting in BANKS (so all starting with $A000?)
Question 5: How do I get all this together, that all the parts can be loaded to the corresponding RAM areas? (I am not talking about the Loader here, but how does the linker get the correct addresses to math.s and how do I get those addresses to get my loader right (e.g. prepare the right bank before loading it).
I would be interested in a good documentation, that goes into those details to understand much better the building process. I see you heavily using it for the KERNAL but even there I do not even understand were it starts and how it works.
The official documentation does not go into any detail on that - it is a good reference, but not very good to learn.
Question
SerErris
Hi, I am working on a larger project and need to understand better how the structuring in files and the placing in memory works.
The project will be a pure assembler project and also will not use any BASIC operation.
Question 1:
I will need to define a lot of variables inside ZP. As far as I understood I can use $02-$7F and $A9-$AF. How do I need to setup the cx16.cfg ZP directive, that it does automatically assign the bytes to the allowed windows?
This does work (e.g compiles) to enable more ZP bytes then the normal $20-$7F ... but it obviously would just overwrite $80- $A8, which is unsave for the Kernal and might crash the machine (makes kernel functions unusable).
Question 2:
Maybe related to the first one: As I do not know how many variables I will have and may want to change them during the development process and they all have different length, I want to use the .res statement to define the length of each variable and using labels to get the symbols for the addresses of each ZP.
I did something like that:
As my ZP segement starts @$02 ZP will point to $02 as well as RAND and TRPTB will point to $06. My issue with that is, that the compiler will actually create code and place it into memory after loading. Is there any other way of automatically (in opossition to calculate everything manually) define some symbols (e.g. memory addresses) but not get it actually compiled into the source code?
I can see the EXTZP segment in the cx16-asm.cfg ... but what does it mean? It has not been defined.
Also I do not understand how to load things like LOADADR correctly. It is getting imported... from where?
That brings me to my question 3:
I like to have a main PRG file (e.g. loader) and some .bin files that keep individual parts of the real program, such as models or math library or main loop etc.
From the file structure I do understand how to create multiple source files and exporting symbols I want to use from outside. However how do I instruct the assembler/linker to create a .bin file out of a given object file?
Lets assume I want to have the following three files out of the input files:
Loader.s => LOADER.PRG
math.s => GAME1.BIN
models.s => GAME2.BIN
mainloop.s => GAME3.BIN
Question 4:
Also I want to instruct the linker to put the GAME2.BIN @$A000 to be able to use it in a BANK. How can I use multiple BIN files using the same address space, as they are all sitting in BANKS (so all starting with $A000?)
Question 5: How do I get all this together, that all the parts can be loaded to the corresponding RAM areas? (I am not talking about the Loader here, but how does the linker get the correct addresses to math.s and how do I get those addresses to get my loader right (e.g. prepare the right bank before loading it).
I would be interested in a good documentation, that goes into those details to understand much better the building process. I see you heavily using it for the KERNAL but even there I do not even understand were it starts and how it works.
The official documentation does not go into any detail on that - it is a good reference, but not very good to learn.
Edited by SerErrisLink to comment
Share on other sites
22 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.