Z80N documentation?

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

Moderator: Programming Moderators

User avatar
varmfskii
Posts: 287
Joined: Fri Jun 23, 2017 1:13 pm
Location: Stone Mountain, GA USA

Re: Z80N documentation?

Postby varmfskii » Wed Jan 22, 2020 5:57 pm

I believe with regards to the opcodes, yes
Backer #2741 - TS2068, Byte, ZX Evolution

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

Re: Z80N documentation?

Postby Ped7g » Thu Jan 23, 2020 1:16 pm

https://wiki.specnext.dev/Extended_Z80_instruction_set
should be "current", i.e. all info correct for core 3.0.x and so far it looks that is also what the core3.1.0 (or what will be the version for the "zero day" release) will contain - but who knows what kind of surprises has AA up his sleeves :)))

If you spot some bug there, feel free to fix it or nag me here and I will edit it.

Also the Next register list and details of each register should be quite on par with core 3.0.7, although I got kinda lost in the process and I can't recall if I did refresh *all* of them.

The various larger articles like Layer2/banking/etc.. are mostly not refreshed and often describe core 2.x state, although whenever I hit something myself, I'm trying to edit it, at least short note about new changes in latest cores.

User avatar
SevenFFF
Posts: 565
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: Z80N documentation?

Postby SevenFFF » Thu Jan 23, 2020 3:09 pm

Ped is correct, the Z80N instructions opcodes section at the bottom of the wiki page he linked to is accurate for byte values and timings.

A lot of people get quite hung up on new opcodes, but I can tell you that in practice Z80N opcodes are really quite a minor convenience feature of programming the Next, and you can more or less program with the standard instruction set if you choose to. They really only become truly essential when you're trying to optimise very high performance code.

FAR more essential are the FPGA hardware devices and features represented by the registers and I/O ports. In that sense, you can treat it as a standard Spectrum with a crapton of extra hardware addons, albeit one where you can rely on certain groupings of hardware to always be present together. There's like several THOUSAND times more juicy non-opcode features available than there are opcode features.

This page and the expanded/updated core 3.x version of it in the manual, should be your primary bible, constantly at your fingertips for reference and mental absorbtion.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins

User avatar
Maziac
Posts: 110
Joined: Sun Jul 09, 2017 5:56 am

Re: Z80N documentation?

Postby Maziac » Thu Jan 23, 2020 9:37 pm

Thanks.
I used the Z80N description now in this vscode extension:
https://github.com/maziac/z80-instruction-set
You get the description (not only Z80N but all Z80 opcodes) when hovering over an instruction.

User avatar
SevenFFF
Posts: 565
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: Z80N documentation?

Postby SevenFFF » Fri Jan 24, 2020 12:52 am

Yes it is. The list at the bottom of the page is complete. Bytes and timings are accurate for 3.5MHz..14MHz.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins

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

Re: Z80N documentation?

Postby Ped7g » Fri Jan 24, 2020 5:47 am

Maziac:
Uhm.. the `DE:=DE<<(B&15) OR DE>>(16-B&15)` is not logical "or", but bitwise OR (because that wiki doesn't have a way to write pipe char in the content as far as I know after spending about 1h on google and experimenting).

It's *rotate left* (without carry) B-many times (the top four bits of B are ignored, because even if they would count, they wouldn't change the result). Not shift.

(I see "If B.4 == 0 then 0-fill shift left of DE, (B&0Fh) times, else 0-fill shift right of DE, 16-(B&0Fh) times" in your source code, which is just something completely different from what the instruction does, it doesn't care about b.4 at all, that one is already ignored, only b.3:b.0 form value 0..15 which is used as rotation counter)

edit:
and I would be confused also by your `setae` description (by "A.#bit" I would expect it to change just one bit) ... while I admit some of the shortfx on the wiki are kinda ridiculous (mostly because I tried to keep them short), they are binary correct. Your rewording in certain cases looks really good (bsrf/etc), but setae was IMO already decent, not sure what's wrong about `A:=unsigned($80)>>(E&7)`

push nn - "the value is pushed as big-endian" that's not true, value is encoded in big-endian way, but pushed to stack "normally", i.e. `push $1234 : pop hl` is HL=$1234 and the machine code looks as `ED 8A 12 34 E1`. The info about big-endian is pretty much useless for regular user (as long as you have decent assembler which handles the argument encoding).

User avatar
varmfskii
Posts: 287
Joined: Fri Jun 23, 2017 1:13 pm
Location: Stone Mountain, GA USA

Re: Z80N documentation?

Postby varmfskii » Sat Jan 25, 2020 3:31 am

Older Motorola manuals used the Boolean symbols ∧ for bitwise and, ∨ for bitwise or, and ⊻ for bitwise xor.
Backer #2741 - TS2068, Byte, ZX Evolution

User avatar
Maziac
Posts: 110
Joined: Sun Jul 09, 2017 5:56 am

Re: Z80N documentation?

Postby Maziac » Sat Jan 25, 2020 11:09 am

@Ped7g: Thanks for the thorough review.
With some of the descriptions on the wiki I had a hard time to understand and obviously didn't get it right always.
But as explanation, the main reason I changed it was to be consistent with the already existing Z80 opcode descriptions (although I later found out that they were not consistent in themselves, so I ended up editing a lot.)

- "BRLC DE,B": I corrected the description. I misinterpreted the original description completely, sorry.
- "SETAE": I had to look at it a few times to understand what was wrong with my description. I think I got it now: the other bits should be 0. I.e. in "my syntax" this should be: A := 0, A.(7-E&07h) := 1. I want to avoid the shift symbol since the instruction itself has nothing to do with shifting. But I guess this is a matter of taste.
- "PUSH nn": I corrected the description.

I released a corrected version 0.6.2.

A question about the shift operations, e.g. ""BSLA DE,B":
Why do they use bit 0-4 of B? This means I can shift max. 31 times. But DE has a length of only 16 bits.
Why isn't it restricted to bits 0-3 like in BRLC?

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

Re: Z80N documentation?

Postby Ped7g » Sat Jan 25, 2020 1:09 pm

I'm just guessing about the intent of original author, but I think it has to do with (what you did also use yourself in that SETAE description) calculation of shift number.

Now imagine you want to recreate the BRLC with shifts, it's `(V>>(16-r)) | (V<<r)` a for "r == 0" you need shift by 16 and 0. So the 4 bit 0..15 does not cover the "shift by 16" case (and 16 is like mirror to 0 in this case).

Hm, just now it occurred to me the x86 has the exclusive 0..31 for 32 bit values (not including value 32), so the Z80N extra range seems a bit luxurious. Maybe the barrel shift unit had to support it internally any way for internal usage and so it got "public" through that instruction design.

Anyway, sometimes in C/C++ it's handy when I know I can just write shifts with calculated values without extensive range checking and knowing that the result will be correct. Even in assembly, although in assembly more often you have better control about the range and just avoid weird values completely.


Who is online

Users browsing this forum: No registered users and 2 guests