Sujet : Re: The integral type 'byte' (was Re: Suggested method for returning a string from a C program?)
De : antispam (at) *nospam* fricas.org (Waldek Hebisch)
Groupes : comp.lang.cDate : 27. Mar 2025, 02:10:11
Autres entêtes
Organisation : To protect and to server
Message-ID : <vs28hh$2ug7$1@paganini.bofh.team>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
User-Agent : tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64))
bart <
bc@freeuk.com> wrote:
On 26/03/2025 18:09, Janis Papanagnou wrote:
, primitive CPU architectures,
8-bit architectures were fine, just a bit short of registers and with
limitation instruction sets. But that is to be expected with only 27,000
transistors on a chip or whatever it was for Z80.
All sources that I found say that Z80 is about 8000 transistors.
You probably took number from 8086 which was climed to have 27000
transitors.
Z80 (like earlier 8080) in "general" instructions required
accumulator as one of arguments, that severly limited utility
of registers.
(BTW, have a go at emulating such a processor in sofware; tell me in 3
months how you got on.)
Lone processor is not very interesting. I do not think coding
simple emulator would take a lot of time. Z80 instruction set
is a bit bulky, due to prefixed instructions, but decode could
be done quite naively using 5 tables with 256 positions each
(or a bit smarter using 3 tables). One needs hundreds of
routines to implement all instructions, but large part is reasonably
regular, so could be mechanically generated from small number
of templates. Code implementing less regular instructions
would take some time to write, but 3 months look like quite
generous estimate.
Of course I mean implementing documented Z80 instructions.
Finding out what happens for undocumented opcodes is a can
of worms and could take large effort.
BTW: In old book I have table of 8080 and Z80 instructions.
This table for each instruction has short pseudo-code
explaining what each instructions is doing. Table has
30 pages, but much of it is whitespace and other info,
pseudo-code probably is less than 1000 lines. Written
in C it will take more space, but clearly Z80 emulator
is not going to be a big program.
BTW2: Other 8-bit processors from that era, that is 8080 or
6500 are simpler than Z80.
But also at that time - early 80s when Spectrums etc were popular -
there were some wonderful new 16/32-bit processors such as 68000,
Z8000/0 and NS32032, of which only the first survived.
Looking at short description of Z8000, it does not look nice:
it has ugly "segmentation" scheme to address more than 64kB
of memory. AFAICS the only advantage of this scheme is that
such ugliness can not survive long (unlike 8086 segmentation).
-- Waldek Hebisch