Re: How do SAVEM and CSAVEM files work?
Sean Conner via Coco <coco-uNHYcr1XS/wmlAP/[email protected]>
| Newsgroups | gmane.comp.hardware.tandy.coco |
|---|---|
| Message-ID | <[email protected]> |
It was thus said that the Great Allen Huffman via Coco once stated: > I just noticed that the lwasm assembler will generate multiple segments if > you have an RMB in your code. For example: > > > ORG $3F00 > START RTS > END > > If you use the -fbasic option, you get a BASIC loader that loads data at > 3F00, as expected > > But if there is an RMB: > > ORG $3F00 > START RTS > RMB 10 > RTS > END > > …It makes two segments with a start-end for the first part (RTS) then a > start-end for the next part, 10 bytes down. > > I assume if I put this in memory and did a CSAVEM/SAVEM, it has no idea > about gaps like that so the file itself will just be one continual block > of data” Pretty much. The syntax for the CSAVEM/SAVEM commands don't really allow for multiple segments. > 57 for RTS, then the zeros: > > 3F00: 57,0,0,0,0,0,0,0,0,0,0,57 > > But M files support segments, such as multiple ORG statements, don’t they? > > ORG $3F00 > START RTS > > ORG $3F08 > START2 RTS > > END Yup. In my assembler [1], when outputing a Coco binary file, will only generate multiple segments if it ends up being smaller. So, for instance, the following (contrived) example: org $3000 rts rmb 5 rts will generate one segment, while: org $3000 rts rmb 6 rts will generate two. A segment headers is five bytes long, and thus, any gap less than that isn't worth making a new segment. While a 1-byte gap might seem silly, there has to be a cutoff at some point and that's what I picked. > Is there any utility in toolshed, etc. that can dump an M file and show > how it looks inside? I don't use toolshed, so I don't know, but I did write my own as it's not that hard. A Coco binary file has the following structure: 00 One byte marker for data block LLLL two byte length of block AAAA two byte address to load FF One byte marker for end of binary file 0000 no length AAAA execute at this address (unless 0000) There can be multiple blocks starting with 00, and there should only be one starting with FF. What the data blocks are is anybody's guess, but I assume any block that overlaps the execution address does contain executable code. -spc [1] https://github.com/spc476/a09 -- Coco mailing list [email protected] https://pairlist5.pair.net/mailman/listinfo/coco