Jump to content
IGNORED

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!

Link to comment
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
Link to comment
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.

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...