https://github.com/cvghivebrain/axm68k I made macros for all the Z80 instructions in ASM68k. In order to get certain instructions working (add, and, neg, nop, or & sub) which are shared with 68000, I modified ASM68k (now called AXM68k) to disable them, and then re-enabled them with further macros. I've tested it on Sonic 1's sound driver and Z80 startup code, and it works as expected, but it could do with more thorough testing. "ex af,af'" must be changed to "ex af,af" (without the apostrophe) or ASM68k throws up an error. Every other instruction can be used as-is. You may now delete AS. Credit to MarkeyJester for his help, and AURORA☆FIELDS for the idea.
this is cool, though definitely a few possible issues I see with this: jr is not restricted to -$80 to $7F range, meaning invalid jump addresses will be accepted by the assembler Using invalid registers and register combinations seem to not be rejected and instead have unpredictable behavior using dc.w with ae+ will break the output of these macros Possible slow performance and huge listings dumps from all that string conparison It would be a good thing to mention using obj to tell which address is used for z80 code This is really cool and easier for portability given you don't need to replace command names, but I feel it could still be improved :P
1. Do you mean it'll accept it if the address is +$90? 2. I changed things a bit so assembly will fail on invalid registers in most cases. 3. Can you give an example? 4. I haven't tested it on something as large as a SMS/GG game, but it seemed pretty quick doing the S1 sound driver. 5. Good idea, I also added phase/dephase macros for more AS compatibility.
1. Yup. It will assemble all offsets between -$80 and $FF, meaning that if you write some Z80 code yourself and accidentally add too much stuff, then suddenly jump targets for example will be off by a lot and its difficult to find the issue. This is why I implemented some of the complex ways to replace data bytes in my version: I didn't actually find a way to restrict offsets to signed only 3: Code (Text): ae+ cpu z80 nop ; $00 ind ; $ED $AA ; expected output: $00 $ED $AA ; actual output: $00 $00 $ED $AA ; ae+ automatically aligns word/long accessed to word boundaries. Solution: use bytes only.
I disabled ae for Z80, and added a range check for jr. One thing I found is apparently "if narg = 2" doesn't work, it has to be "if narg=2" without spaces. Something to be careful of in future.
I'm really not sure if that fix will work in all cases, particularly forward jumps or ones that work based on a variable Also it's not well known but ASM68K will actually allow you to use spaces in any statement if you use opt ws+ Finally please use pusho and popo so that the user options are correctly restored after changing cpu mode
You're right about jr not working: Code (Text): D:\GITHUB\S1DISASM\SMPS.ASM(45) : Error : Expression must evaluate jr_ptr: = (load_sample)-*-2 D:\GITHUB\S1DISASM\SMPS.ASM(75) : Error : Expression must evaluate jr_ptr: = (play_segapcm)-*-2 This is the S1 sound driver I'm testing it on. Why isn't it evaluating? Looks fine to me. Edit: I think I know what's happening. It doesn't know what those addresses are because they're ahead of the macro. That's why you mentioned forward jumps.