santiontanon / mdlz80optimizer

MDL (a Z80 assembler optimizer)
Apache License 2.0
81 stars 6 forks source link

Z80N and Z180 support #27

Closed spth closed 2 years ago

spth commented 3 years ago

The Z80N and Z180 are very similar to the Z80, as they only add few instructions. So it should not require too much effor to support them in mdl.

Even if the Z80N and Z180 instructions are not optimized, it would already be helpful, if normal Z80 code in a file that also contains some Z80N- or Z180-specific instructions could be optimized.

For sdasz80, this could be autodetected, as the assembler files for Z80N contain a .zxn to switch to the Z80N instruction set, and those for Z180 contain .hd64.

santiontanon commented 3 years ago

Indeed! This would be very nice! I already had a "to do" item to add support for Z80N, but Z180 would be even easier I think, as it's only one extra instruction, and then adjusting the timings of the rest.

Do you have any pointer to any github o any other available source code online where I can get examples of Z80N or Z180 source code to use as tests?

spth commented 3 years ago

The Z180 has a few new instructions: mul, tst, slp and various I/O instructions. In the "Z8018x Family MPU Manual" they are marked by two stars in the "Instruction Summary" section. The Z80N on the other hand, has the same timing as Z80. For asm source, see the my reply to issue #26.

P.S.: Also, the Z180 does not support the undocumented Z80 instructions. AFAIK, any attempted use of them raises a non-maskable trap interrupt. If one really wanted to use them, one could emulate them in the interrupt handler, though.

santiontanon commented 2 years ago

Quick update on this issue: Z80next support has already been added (starting from the current preliminary 2.2 release: https://github.com/santiontanon/mdlz80optimizer/releases/tag/v2.2 ).

I'll be working to add support for Z180 before the final 2.2 release. This one is taking a bit longer, since, if I am reading the z180 manual correctly, the timing of all regular z80 instructions is slightly different in the z180, so, I need to create a complete new instructions table for this CPU to make sure all timings are correct.

santiontanon commented 2 years ago

Z80n and z180 are supported in the latest preliminary release, and will be included in the upcoming v2.2. Closing this issue, but feel free to re-open it if there are any problems :)