Using WinAPE's built-in Assembler, I can assemble the routine directly
into the emulated CPC's memory, and I have discovered that I can
execute it by simply typing CALL <address>. That works fine in the
emulator.
Now, with the routine nicely in memory in the emulator, I want to save
it to disk - should be easy using SAVE "name",B,<start-addr>,<size>.
First question: How do I find out what <size> to use to make sure I
get all of the assembled code and the included files? The WinAPE
assembler output just shows the main routine addresses, and doesn't
give any indication of where the included files are located.
The code is located at address &1000, and given that I had no way of
determining the number of bytes I needed to save, I tried saving 32768
bytes of memory (must be far more than needed).
SAVE "test",B,&1000,32768
Now, when I try to load this back into the CPC, I get a "Memory full"
error, and it doesn't seem to load any of the file. (PEEKing where is
should be gives all zeros).
Second question: Assuming my SAVE worked as expected, how do I
subsequently LOAD the bytes back into memory?
The routine I'm trying to use is the PT3 player from
http://www.grimware.org/doku.php/sources/pt3
Any help would be very much appreciated!
I'm sure this is all very easy when you know what you're doing, but I
was brought up on the Spectrum so the CPC is still a bit of a mystery
to me :-)
--
Please remove all-your-clothes before replying.
> OK, Basically what I'm trying to do is save a machine code routine to
> disk so it can be loaded and executed on a real CPC.
>
> Using WinAPE's built-in Assembler, I can assemble the routine directly
> into the emulated CPC's memory, and I have discovered that I can
> execute it by simply typing CALL <address>. That works fine in the
> emulator.
>
> Now, with the routine nicely in memory in the emulator, I want to save
> it to disk - should be easy using SAVE "name",B,<start-addr>,<size>.
>
> First question: How do I find out what <size> to use to make sure I
> get all of the assembled code and the included files? The WinAPE
> assembler output just shows the main routine addresses, and doesn't
> give any indication of where the included files are located.
>
> The code is located at address &1000, and given that I had no way of
> determining the number of bytes I needed to save, I tried saving 32768
> bytes of memory (must be far more than needed).
>
> SAVE "test",B,&1000,32768
>
> Now, when I try to load this back into the CPC, I get a "Memory full"
> error, and it doesn't seem to load any of the file. (PEEKing where is
> should be gives all zeros).
32768 is &8000 so you are saving addresses &1000 to &8FFF inclusive. It will
try to reload into that same area unless told otherwise. Is there the
possibility that HIMEM stands lower than &9000? Alternatively you may have
a BASIC program loaded occupying addresses up beyond &1000. In either case
the proposed reload address block is already partially spoken for, hence
the error.
In the first instance try saving a smaller file.
> Second question: Assuming my SAVE worked as expected, how do I
> subsequently LOAD the bytes back into memory?
Don't quite understand here. How is this load any different from the one
mentioned above?
--
ξ:) Proud to be curly
Interchange the alphabetic letter groups to reply
>32768 is &8000 so you are saving addresses &1000 to &8FFF inclusive. It will
>try to reload into that same area unless told otherwise. Is there the
>possibility that HIMEM stands lower than &9000? Alternatively you may have
>a BASIC program loaded occupying addresses up beyond &1000. In either case
>the proposed reload address block is already partially spoken for, hence
>the error.
>
>In the first instance try saving a smaller file.
Thanks for that! I've now got it working (well, almost - the routine
doesn't work, but I've sussed the loading, saving and executing bit!)
Turns out I had two problems: Firstly, the CPC "holds your hand" a lot
more than the Spectrum, and will not let you overwrite memory which is
allocated for system use. If you try to do this, you get the "memory
full" error. So it is necessary to use the MEMORY command to clear
some room to load the file into.
The second problem was that doing MEMORY &0FFF (to clear out from
&1000 upwards) doesn't leave enough room to actually read the disk! So
yet again, you get the "Memory Full" error when trying to load the
file.
After shifting the routine to start at &2000 and doing MEMORY &1FFF,
it finally worked :-)
However, the WinAPE assembler question still remains - how to I know
how many bytes have been used, so I know how many I need to save?
Thanks :-)
Tim.
> However, the WinAPE assembler question still remains - how to I know
> how many bytes have been used, so I know how many I need to save?
>
> Thanks :-)
>
> Tim.
In the real Maxam you can use a PUT pseudo-op. If you include tHe line
PUT x,$
after the last real program instruction will put the address beyond the last
instruction into the variable passed in from basic as the parameter x. Can
the PUT command be used with WinAPE? Failing that try loading the real
Maxam and using the PUT command.
To get the length, when you compile with ctrl+F9 the 2nd column is a
hex value of the total length. ie. 001300 4501 end
If you started at org #2000, you would open calc (in scientific mode)
and subtract, ie. 4501 - 2000 = &2051
so your save would be: save "myfile.bin",B,&2000,&2051,&2000 (you
can have the last value for execution address)
hope that helps.