Z80N documentation?

Do you live and breathe hexadecimal? Do you like speaking to hardware directly?

Moderator: Programming Moderators

Post Reply
thomasharte
Posts: 4
Joined: Tue Mar 20, 2018 2:02 pm

Z80N documentation?

Post by thomasharte » Mon Dec 17, 2018 8:29 pm

Hi; I might be failing miserably at basic searching but is there a simple up-to-date summary of the Z80N's additional instructions anywhere?

This site seems to have a lot of content on the updated video hardware but all I can find on the processor is the limited wiki content (highlight: "Details of ACC32, which appears to be a Next extension, are unknown at present.") and comparing with the source code of Zesarux et al, which disagree with the Wiki — where e.g. the wiki's 16-bit multiply is absent, replaced by an 8-bit multiply.

If it helps at all as to my motivation for asking, I am the author of a subcycle-accurate emulator that includes a Z80, getting exactly 100% for the clkfreq test with its ZX81 implementation, so beyond mere extra instructions, I'd love to know what, if anything, the Z80N tweaks as to machine cycles and their timing distance; I also wrote a vector 3d engine for the Sam Coupe, so new instructions of the multiply/multiply-with-accumulate/divide type are of particular interest to me, and I pledged for a Next.

Ped7g
Posts: 109
Joined: Mon Jul 16, 2018 7:11 pm

Re: Z80N documentation?

Post by Ped7g » Tue Dec 18, 2018 2:10 pm

The wiki page is very outdated, mentioning many things which were considered back then, but got not implemented (like acc32 or 16b multiply). The bottom table of opcodes is most close to the real state (and even there is the scaled ldi, which didn't make it yet into hw). And now KS update #41 mentions new barrel shift (variable amount) instructions, and new "jp" instruction, without any further details.

So actually the Zesarux emulation is closer to the HW than wiki, although not in sync with latest development either. There's also considerable chunk of docs in the distribution files ( https://www.specnext.com/latestdistro/ ), although that's a bit outdated too, considering text of update #41. So I'm waiting for somebody from core team to leak the info... they should probably focus on updating firmware first, and commit changes to git ( https://gitlab.com/thesmog358/tbblue ) as working on it, so the most impatient can check the changes log to pick up the info as early as possible. :)

thomasharte
Posts: 4
Joined: Tue Mar 20, 2018 2:02 pm

Re: Z80N documentation?

Post by thomasharte » Wed Dec 19, 2018 6:31 pm

Oh, well it's a shame if the team isn't sharing technical documentation as I'd have loved to give the 3d tyres a kicking. No great loss to the world, but a personal disappointment!

I'll keep my fingers crossed for a stable, documented Next in the future.

Ped7g
Posts: 109
Joined: Mon Jul 16, 2018 7:11 pm

Re: Z80N documentation?

Post by Ped7g » Thu Dec 20, 2018 12:50 am

Oh, I'm not sure we understand each other correctly. The team definitely *does* share technical documentation, and the final goal is to make whole project as "open" as possible, including all the HW schematics, etc...

My disappointment is stemming from my impatience, that few core people already have some working code with the new features, while I don't even have docs about the changes.

As per this post, the details are slowly coming: https://www.specnext.com/forum/viewtopi ... 8511#p8511 and more should come, but the question is "when", they are doing the project in spare time, and it's getting a bit long, so one can easily understand they have some fun with development first, and resolve information hungry individuals like me a bit later.

For me the most important thing is, that the whole thing will be open upon delivery (or I rather mean it will be "delivered" when it is fully open, not just when the case arrives in box, that's also nice, but not enough), and that the core team does pick up the feedback from facebook and forum eventually, although they don't exactly like to discuss too much about it, for example my comment about Z80 having already `inc sp (6T)` instruction lead to removal of `pop /dev/null` Z80N, which was doing basically the same as 2x `inc sp`, but much slower.

Similarly the sprites are now much improved (with scanline-render-buffer scheme, so they are less dynamic, but I definitely prefer the new variant, dynamics per-scanline with lot more performance looks as excellent compromise to me)...

Now I'm not sure what more could be improved without seriously changing current design (I would still love to see some gfx capabilities closer to GBA chip, i.e. also tiled modes, etc, but that's like completely different planet, compared to current design), I had one more proposal on clip-window calculation, and now I would also prefer more accurate docs, and also the emulators authors to pick up on the details and being in sync with HW (seems like some people run into quite some discrepancies between the actual board, and emulators, especially when trying to push it a bit more, like reduced DMA inits, etc).

Anyway, for your purpose of 3D engine, I believe the current sprites changes are irrelevant. And the 16b mul doesn't seem to be on the roadmap (neither acc32), so I think the specs are final enough for you to do some preliminary prototyping.

Maybe if you do that, and show some particular code, and suggestions, they may eventually work as further food for thought for the core team.

thomasharte
Posts: 4
Joined: Tue Mar 20, 2018 2:02 pm

Re: Z80N documentation?

Post by thomasharte » Thu Dec 20, 2018 11:54 am

You're correct that the sprawling labyrinthine array of different bits of sprite functionality aren't interesting for me; I'm also wary of the effect on tooling of changing specifications with no single authoritative source. You're too reliant on specific authors continuing to update the specific tools.

As I'm confident I'd have nothing of value to add to the Next's design, I'll wait for a finished, shared specification and see what I can do about getting a workflow set up from there. I'm dating to imagine I'll have to do a lot of rolling my own, since I don't use Windows.

The only thing I'd say is that the Atari Lynx's provision of multiply, divide et al as an external MMU is really helpful as it makes a lot of the shuffling behind cuing up values achievable in parallel to the arithmetic. No need to monkey about with extra opcodes.

Alcoholics Anonymous
Posts: 508
Joined: Mon May 29, 2017 7:00 pm

Re: Z80N documentation?

Post by Alcoholics Anonymous » Fri Dec 21, 2018 4:47 am

Your project is really interesting.

For the Z80N I'd say it's a long way from being finished. A lot of earlier opcodes were abandoned because they took too much space. They took too much space because they weren't actually integrated into the Z80 architecture. Another visit will come when there is time to determine what will / can go in there. Mainly the extra opcodes would be inspired by the Z280, Z380, Rabbit architectures as well as the needs of the hardware.

User avatar
feilipu
Posts: 1
Joined: Mon May 29, 2017 11:17 pm

Re: Z80N documentation?

Post by feilipu » Sat Dec 22, 2018 1:40 am

There is a list of Z80N opcodes and timing maintained by @albrec at the Z88DK site. The whole issue #312 is worth reading.

The implementation of z80asm supports all known z80n variant opcodes (prior to KS Update 41), and there is substantial standard library support for the ZX Next.
Last edited by feilipu on Mon Jul 15, 2019 3:54 am, edited 1 time in total.
Backer #154
Engineering is interesting,
and if you don't agree you can fuck off.
text
code
@_feilipu

thomasharte
Posts: 4
Joined: Tue Mar 20, 2018 2:02 pm

Re: Z80N documentation?

Post by thomasharte » Sun Dec 23, 2018 10:07 am

Cool, that's already much better information than I had! 8x8->16 multiply is actually really useful: a trivial optimisation that works for most 3d engines of the relevant vintage is to keep and rotate all individual objects in 8-bit coordinates, saving the more expensive transforms for their centres in order to then map the whole thing into a 16.8 space.

Freescape doesn't even do that — each room is described in 8-bit coordinates only.

And z88dk even doesn't constrain me to trying to remember how to use Windows, so that's a bonus!

An 8-bit divide with remain would have made run-slice line drawing and edge scanning cheaper, but whatever.

It actually struck me the other day that you could do something like Stunt Car Racer with filled polygons and no overdraw and very cheap calculation of frame differences, for just repainting the pixels that have changed, especially on a machine like the next where the opponent can be kicked into a separate layer. But I'm terrible at finishing things, so that's probably academic.

The CPU additions also look small enough that I could probably add the Next to my emulator without too much fuss. Though it doesn't even do the Spectrum yet, and I'm knee-deep back in the composite video decoding, having read a paper that treats the problem as purely trigonometric rather than the usual signals processing solution, so we'll see.

User avatar
intrepidis
Posts: 3
Joined: Tue Jan 22, 2019 4:39 pm

Re: Z80N documentation?

Post by intrepidis » Fri Feb 01, 2019 7:52 am

I put together this handy spreadsheet of ASM instructions, which has a tab for the new NEXT opcodes and includes byte sizes and timings. It also indicates which flags are set.

https://docs.google.com/spreadsheets/d/ ... qWOM_V5AGE

Post Reply