| |
MrXaliasH
Registered: Oct 2013 Posts: 11 |
guide how a *.prg file is structured
Hi guys,
while working on a cross platform tool I stumbled over the problem, how to generate a prg file with this application directly.
Until now I still use the way to generate a asm file to import into an assembler (CBM prg Studio for me).
I looked at the generated prg file but got some problems in understanding why it is like it is. Of course I know that I have to use the opcodes instead of the mnemonics and I know about how addresses should be encoded (LSB,MSB), how jumps work etc...
But what i don't understand is, what is the best way to optimize the size of the prg file.
For example:
I have a screen, which I want to display.
ScreenRAM is located at $4000, ColorRAM at $4400, code to copy it to its destination at $0C00
The jump to the code is located at normal basic start ($0801)
But in the generated prg file this structure is messed up and I can't see any logic in it. So I didn't find a algorithm yet how to "pack" my code into a prg file like it is done there.
So there is my question:
Is there anywhere a guide/tutorial/document, which describes how a prg file should/could/shall be "structured"?
Thanx for your help in advance
Holger |
|
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
A prg file is just a memory dump with the two first bytes stating where to start. The rest is just binary data in linear memory. It's nothing like an object file or so like you seem to assume.
Normally you simply save the memory as is and crunch it, but sometimes it's more appropriate to manually have all data blocks after each other and a simple routine to spread them out in run time. |
| |
MrXaliasH
Registered: Oct 2013 Posts: 11 |
OK, maybe it was explained a bit complicated :D
Now it makes sense when i look at the prg file generated by the CBM prg Studio.
Thanx for pointing me into the right direction. |
| |
algorithm
Registered: May 2002 Posts: 705 |
Like JackAsser mentioned, the PRG file is merely a raw dump with the first two bytes indicating the load address.
Perhaps you were asking how a prg file is structured that has a sys line that autoruns when the run command is executed? |
| |
MrXaliasH
Registered: Oct 2013 Posts: 11 |
@algorithm:
I think its just like this: first two Bytes: $01,$08
then the SYS call and after that, maybe with some offset (filled with $00) the data/code
Of course the SYS call should point to a address where code is loaded to.
Is that correct? |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
http://csdb.dk/forums/?roomid=11&topicid=99062#99086
secondly, you can simple use a command line PC tool, which generates a packed executable for you in prg file, sys included (google for: exomizer, pucrunch) |
| |
MrXaliasH
Registered: Oct 2013 Posts: 11 |
Thanx Oswald for the tools, they will be usefull if the generated prg file gets bigger.
At the moment there is still enough left (if my assumtion that with loading a file to $0801 the whole RAM to $9FFF can be used for the file). |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
you can load fine until $d000, because all cpu writes to rom, are turned into writes to ram by wiring. |
| |
MrXaliasH
Registered: Oct 2013 Posts: 11 |
Thanx again Oswald for this valueable information :D |
| |
theWizard Account closed
Registered: Jul 2007 Posts: 109 |
eg
$00,$10
[data to load]
loader reads first 2 bytes ( in this case $1000 dec 4096 ) that tells the loader where to put the rest of the data then the data after the first 2 bytes is loaded to $1000.
basically thats the prg file structure.
first 2 bytes tell it where to load then data gets put wherever its told to go. |