The Z-80 has a 4-bit ALU. Here's how it works.
righto.com
righto.com
One thing I'm missing from this article is an approximate gate count. Obviously going 4 bit was motivated by gate and area saving, but halving the ALU size isn't going to halve the gate count or area, because it still needs the same width bus and extra latches for the partial answer. Or was it critical path? What kind of saving was it from an 8 bit ALU?
[1] See page 10 in http://archive.computerhistory.org/resources/access/text/Ora...
Note: if you're interested in Z-80 architecture, you seriously should read that link.
[1] The 8080 also had these decimal arithmetic hacks but it didn't have an alternate set of registers to pull from.
General question: what things about the Z-80 would you guys like me to write about? Any particular features of the chip? Register-level architecture, gates, or the silicon? Analyzing instructions do cycle by cycle? Gate counts by category? Comparison with other microprocessors?
Undocumented instructions! The MOS 6502 had plenty of these and I understand the Z-80 did too.
I only ever saw it used for game scores... and the following, which prints a byte as hex, and is a neat example of cute 6502 code. Saves a few bytes over having a table of hex digits, and you don't need to save X or Y.
HEX: PHA
LSR:LSR:LSR:LSR
JSR HEX2
PLA
AND #15
HEX2: CLC
SED:ADC #$90:ADC #$40:CLD
JMP PUTCH
(PUTCH takes an ASCII character in A.)The 68000 had BCD as well. Never used it and don't recall ever seeing it used. I think they only included it so they could have an instruction called ABCD.
Also would be useful for 7-segment LED displays.
The result was that the Atari's, without even trying, had more accurate decimal math algorithms than other contemporary computers. Something to do on the demo machines of the day in stores was to run this loop:
10 let x = 100
20 print x
30 let x = x - 0.01
40 goto 20
On an Atari this would accurately count down from 100 to zero with zero round off errors. The exact same loop on an IBM PC after about 5 steps started printing things like 99.94999999998 instead of 99.95.Edit: formatting
I think the BCD instructions were never intended to be used outside of software arithmetic libraries, but they provide speedups for crucial operations in such libraries. Sort of like Intel's recently introduced AES instructions, which will probably only be used in encryption libraries.
Of course, it turns out that BCD-based arithmetic isn't much used, because IEEE-style floating-point has a fundamental advantage (you can store more precision in a given amount of space) and is also compatible with hardware FPU's.
[1] http://en.wikipedia.org/wiki/Floating-point_unit#Add-on_FPUs
[1] (PDF link) http://education.ti.com/guidebooks/sdk/83p/sdk83pguide.pdf see pages 22-23
This has, of course, little to do with the width of the ALU.
I don't know that, I just think that. :-)
I don't know who is mangling the URL (Chrome, Apache, MITM?) nor why it's happening.
I think the poster of the URL originally mangled it, but it would be nice if the HN software filtered out invisible characters from URLs. There's not much the destination server can do about it.
(Yes, I've dealt with too many character set issues in the past.)
Does that work?
I copied and pasted it from a Google search result (because otherwise the file downloads without showing me the URL). Google of course has decided "copy link to" shouldn't work.
There's an addon for that.
I agree with mpyne, though, that it shouldn't be necessary.
The course actually has you make a ALU from logic gates, so you understand at a deep level just how it's done.
i remember there was a cross-compiler and a software utility + serial cable ... after some googling:
http://www.ticalc.org/programming/columns/86-asm/el-helw/les...