Closed andymccall closed 2 months ago
Hello, you have several options how to store current virtual device memory.
Where: these instructions store "current" content of virtual memory at their position in source code, so use them after the code and data are emitted into virtual device - your short example source is OK in this regard, saving after the instructions.
Why the example code does not work in ZEsarUX - I don't know, I was testing it only with CPCEC where the test snapshot did work (I'm not CPC user so I have no insight into the platform). You can ask ZEsarUX author if he has idea what's wrong about the snapshot (although try it first in different CPC emulators to see if it does work at least in some).
The sjasmplus SAVECPCSNA
snapshot has plenty of hard-wired configuration in it, see source code for the exact snapshot file format and baked in CRTC/PSG values. Maybe some of that is not compatible with ZEsarUX, or even not correct at all breaking it for most of the emulators - I don't know and somebody familiar with CPC has to investigate to decide if sjasmplus should be corrected or emulator improved. :) You can also post-patch the resulting file from within the source code, overwriting the hard-wired values in resulting file. It's a bit dirty trick ( #139 ), but it should work well.
Other options how to "dump" results into file are:
OUTPUT
/OUTEND
which writes stream of bytes during assembling and does work even without virtual device memory (and can be used to produce any binary file, although I'm not sure about total size, rather stay below 2GiB ;) ).SAVECDT
to create CDT "tape" - probably most difficult to use if you are not familiar with the platform.SAVEBIN
to save currently mapped virtual memory (raw binary blob)SAVEAMSDOS
= same as SAVEBIN
but prepends AMSDOS header to the file (128 bytes)SAVEDEV
= similar to SAVEBIN
, but it goes into full virtual memory block, not caring about current "mapping" in 16bit address space, so the addresses are into full device memory (like 128ki or 2Mi, etc..).I'm not sure if you want bin file with or without the AMSDOS header, without header you can use SAVEBIN "loop.cpc", start, $-start
, with AMSDOS header SAVEAMSDOS "loop.cpc", start, $-start, start
.
edit: those directives are non-destructive, so as you suggested, you can save both savecpcsna and savebin right after each other, just like you proposed.
Thank you Peter! This is brilliant. I was so close, but didn't understand the SAVEAMSDOS options.
Using the info on your reply I've been able to produce a Hello, World! binary using my setup. I've dropped the SNA as I don't really need it and when working with z88dk I'm pushing my binary out to a disk file, so doing this for sjasmplus is better for me as both builds will work the same way.
There's very little info on the Internet for programming the CPC compared to the ZX Spectrum, so I'll post some blogs on what I've done and how I'm getting on. Hopefully it will be useful to others.
EDIT: Happy to close this issue. Repo here with this working example should anyone want to refer to it in the future.
https://github.com/andymccall/amstrad-cpc-development/tree/main/02-helloworld/asm
Cool. If you have any idea how to improve the sjasmplus docs wording, let me know (although brevity is of some value too, so I'm trying to not over-explain the stuff too much, but maybe the current description is too cryptic - seems fine to me ;) ).
@andymccall checking your repo, the sjasmplus INSTALL.md recommends
git clone --recursive -j8 https://github.com/z00m128/sjasmplus.git
That way you will clone also all submodules, including LuaBridge.
Thank you! I've updated to reflect the change.
Hi,
This isn't so much an issue, more of a request for help using SJASMPlus. It's a great piece of software and I'd like to thank all those have have worked on it.
I've been using SJASMPlus for the ZX Spectrum and ZX Spectrum Next, and I wanted to use it for the Amstrad CPC too, but I'm having problems building something that I can run in ZEsarUX.
Given this program in main.asm, which should just loop:
Compiled with this:
sjasmplus --fullpath --outprefix=bin/ --lst=lst/loop.lst --sld=sld/loop.sld src/main.asm
I get .sna file corrupt when loading the loop.sna into ZEsarUX. What am I doing wrong?
Also, how would I use SAVECPCBIN so I could output both an SNA and a BIN? I understand the directive would be something like this:
But I'm not sure on the rest of the options. I'd actually prefer to use the SAVECPCBIN option as this will match my z88dk development pattern where I create a binary and copy it to a blank disk using cpcxfs, but at the moment I'd be happy with getting anything working! :-)
Thank you for any help in advance!