Jump to content
IGNORED

Converting MADS assembly to CC65 assembly


8bit-Dude

Recommended Posts

Hey guyz,

 

I have a program mainly written in CC65, and currently I jump from my main program to sub-progs written in MADS for RMT and CIN support.

I would like to do everything in CC65, but it only supports 6502 opcodes (MADS macro are not recognized).

 

I have seen that MADS can export header files to CC65, but can it somehow convert an assembly file containing macros to one containing only 6502 opcodes?

 

Thanks in advance!!!

Link to comment
Share on other sites

Hi!

 

For true macros - these defined with .MACRO directive - you can get true mnemonics in listing (with "-l" switch).

The pseudo macros like 'mva' though - tough luck, no mnemonic output I know of.

 

If the source is huge, it would be possibly the fastest to type some kind of a script to unwind MADS pseudo macros. If you do, please share!

 

Another approach, more intellectually challenging would be modifying MADS source to spit true mnemonics in listing or some other output. It almost does as it spits bytes and we are in the realm of the machine code :).

Edited by pirx
Link to comment
Share on other sites

or what I did in with c64/lynx stuff running xasm code... write a "wrapper"... say RMT e.g. needs to be placed at a certain page aligned memory location plus RMT song module... so you actually know where they are...

 

assemble the stuff in MADS as binary file and then include those in your cc65 project as "data" file? does that make sense? worth a try same with CIN.

Link to comment
Share on other sites

or what I did in with c64/lynx stuff running xasm code... write a "wrapper"... say RMT e.g. needs to be placed at a certain page aligned memory location plus RMT song module... so you actually know where they are...

 

assemble the stuff in MADS as binary file and then include those in your cc65 project as "data" file? does that make sense? worth a try same with CIN.

 

RMT and RMT songs (both binary load files) can be included easily to a CC65 project using the means of the LD65 linker.

A custom MADS code can also be included by the means of the LD65 linker.

 

As Heaven/TQA pointed out, the main C program just must know on what addresses the MADS code is and LD65 linker must be set not to use the addresses for the C program.

 

You can download sources of the Curse of the Lost Miner game (see BAKTRA Software in my signature), The game is written in CC65, but includes RMT PLAYER and RMT songs. You can check the linker.cfg and gamedata.asm files.

Edited by baktra
  • Like 1
Link to comment
Share on other sites

Alternatively, CA65 supports macros, so you could identify which MADS pseudo macros are used and write CA65 macros for what you need. If it turns out you only need MVA, MWA, INW etc., these are simply enough to write yourself, although using traditional macros you'll lose the optimisations MADS can make (OPT R+). For example.

 

MVA #0 A

MVA #0 B

 

becomes

 

LDA #0

STA A

STA B

 

whereas a traditional macro won't track this and you'll get

 

LDA #0

STA A

LDA #0

STA B

 

Another area to consider is that CA65 is single pass only, so references to labels defined later on the source code (forward references?) won't get optimised to branches where the destination is close enough. Compare and contrast JNE in MADS and the equivalent in the longbranch "macpack" in CA65.

 

Also .proc in CA65 doesn't implement the parameter passing features of MADS.

 

Jeremy

Link to comment
Share on other sites

Most of the code is straight forward, but there are some sections that cannot easily be converted, like this piece of the CIN code:

dlist0:	dta d'pp',$70+$80
		dta $4e,a(buf0)
		:50 dta $f,$e
		dta $f
		dta $4e,0,h(buf0+$1000)
		:44 dta $f,$e
		dta $f
		dta $41,a(dlist0)

dlist1:	dta d'pp',$70+$80
		dta $4f,a(buf1)
		:50 dta $e,$f
		dta $e
		dta $4f,0,h(buf1+$1000)
		:44 dta $e,$f
		dta $e
		dta $41,a(dlist1)

Furthermore, I am also using the RMT player which is a huge amount of code.
Maybe I should compile with MADS, and use a dissasembler....

Link to comment
Share on other sites

I used RMT in a project in 2007 where I'd converted the rmtplayr.a65 code to build using ca65 and permit the song's rmt to be imported into a segment defined in the linker's cfg file.

 

The rmtplayr.a65 player sources may have changed a little since then but any diff's could easily be incorporated.

 

Happy to dig out and share if you feel that's an easier path.

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...
  • Recently Browsing   0 members

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