Jump to content
Sign in to follow this  
Sheddy

Mads assembler best way to end align code?

Recommended Posts

Not just Mads, but I'm kinda new to Mads and maybe there's an easy way in Mads:

 

I've some compressed data/code where it allocates memory to the uncompressed size, but to save memory the compressed data should be aligned to the end of uncompressed area, not the start. Obviously I don't want data the full size of the uncompressed data to be assembled.

 

EG

 

/0000000000000000/ (uncompressed)

/0000000000xxxxxx/

 

X being the compressed data.

 

Anyone have experience of doing this without it being run through an external packer utility?

Thanks!

Share this post


Link to post
Share on other sites

You need some way to get the length of the compressed data so that you can compute the starting address by subtracting the length from the ending address that you want to align it to. I couldn't find a way to do that in one pass in MADS. You can use .get to read a file into memory within MADS but I don't see a way to get the length of the array. You could do it in two passes. Create one file like this:

 

    org $0
    ins 'compressed.dat'
    .put [0] = <*
    .put [1] = >*
    .sav 'compressed.len',2

This will create a two byte file named compressed.len which will contain the length of the file compressed.dat. Now you have what you need to align the data as follows:

 

    .get 'compressed.len'
?length equ .wget[0]
    .get 'compressed.dat'
 
    org $C000-?length
    .sav ?length

You can then set up your build process to assemble these files in the correct order. Example Makefile:

 

endalign.obx: endalign.asm compressed.len compressed.dat
        mads $<

compressed.len: getlength.asm compressed.dat
        mads $<

Code:

 

endalign.zip

  • Like 2

Share this post


Link to post
Share on other sites

Thanks guys, "get" looks very promising for what I'm doing. (The compressed and uncompressed size will vary depending on the data when the self extractor is assembled). I'll check it out later.

Share this post


Link to post
Share on other sites

>I couldn't find a way to do that in one pass in MADS.

 

?length =.filesize 'compressed.dat'

 

org $c000-?length

 

should work.

  • Like 4

Share this post


Link to post
Share on other sites

>I couldn't find a way to do that in one pass in MADS.

 

?length =.filesize 'compressed.dat'

 

org $c000-?length

 

should work.

Thanks JAC! That's what I was looking for. Looks like the English version of the documentation needs to be updated. It also doesn't have .WGET and a few other commands I noticed.

Share this post


Link to post
Share on other sites

Yes, update of the English doc (which still is 1.9.4) is on the todo list.

  • Like 5

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...