CPCWiki forum

General Category => Programming => Topic started by: Interrupt on 09:13, 25 April 25

Title: Manually making AMSDOS Header in RASM?
Post by: Interrupt on 09:13, 25 April 25
I'm exploring making a size limited intro. I'm currently using RASM's built in option to generate the AMSDOS header but I'd like to explore abusing the header to squeeze more bytes out of the space (at 128 bytes with lots of unused space it seems ripe for some hacking?).

The checksum is a 16-bit unsigned sum of all the bytes up to the checksum. Is it possible to generate this in RASM itself (I see a single byte unsigned sum function) or is it simpler to post process the binary? 

Title: Re: Manually making AMSDOS Header in RASM?
Post by: Interrupt on 15:50, 26 April 25
I think I might have misunderstood how this works so I need to do some more research. I can't delete the post so please ignore. 
Title: Re: Manually making AMSDOS Header in RASM?
Post by: roudoudou on 17:46, 26 April 25
Hi
SUMMEM directive is only 8 bits checksum (i could add an option for any checksum, just...   ask for it and i will release it quickly :) )
anyway, you can use a variable and add each byte then output it with a DEFW
boring, ok, i get it :P
Title: Re: Manually making AMSDOS Header in RASM?
Post by: Interrupt on 00:45, 27 April 25
Ok, I've had a play with a hex editor and there is some scope for hacking about with the header (although it is a bit hacky and I'm not sure about compatibility).

Sorry, I can't follow how to use a variable to add each byte using the assembler - I have tried using SUMMEM but I getting errors when I try to assign the result to a variable. I couldn't see any other directive that would allow me to get the bytes from the assembled output.

Could you add the 16-bit unsigned summem directive please?

Ideally I'd like to be able to write something like...

begin
... ; first chunk of AMSDOS header stuff
dw SUMMEM16 begin, $-begin
... ; more AMSDOS header stuff
end
SAVE "file.bin",begin,end

I think I have the rest of the tools I need to build the AMSDOS header in the assembly file. (e.g. dw end - entrypoint ; file length)

Title: Re: Manually making AMSDOS Header in RASM?
Post by: roudoudou on 07:56, 27 April 25
please note that SUMMEM is a directive, not a function, it does itself the byte/word write at the directive place

ok, so i added (if you cannot compile yourself, will push a new release today)
SUM16 <start>,<end>
A header generation will be like

myHeader
defb file_user
defb 'FILENAME'
defb 'EXT'
defs 6
defb filetype ; 0:basic 1:protected basic 2:binary
defw filesize
defw loading_address
nop ; filler
defw filesize
defw execution_address
defs 36
defw filesize
nop
SUM16 myHeader,$-myHeader
defs 59

Title: Re: Manually making AMSDOS Header in RASM?
Post by: Interrupt on 09:55, 27 April 25
Amazing, thanks! I'll get the code and compile it later on today.
Title: Re: Manually making AMSDOS Header in RASM?
Post by: roudoudou on 12:35, 27 April 25
cannot edit so i must fix

it's <start>,<end> for parameters so the last parameter is not $-start but simply $
Title: Re: Manually making AMSDOS Header in RASM?
Post by: Interrupt on 15:52, 27 April 25
Tested and all working great. Thanks again!
Title: Re: Manually making AMSDOS Header in RASM?
Post by: krusty_benediction on 06:43, 28 April 25
Thx for this post.

I will retrieve your directive  for basm ! What I was using for 4dekades is far less nice

At the checksum location:

.CHECKSUM = 0
 .ADR = 0
while .ADR < 0x43
 .CHECKSUM = (.CHECKSUM + peek(.ADR)) AND 0xffff
 .ADR += 1
 wend
Powered by SMFPacks Menu Editor Mod