Hot answers tagged

97

The General Advice Answer For a failure that happens so quickly (at most 89 instructions) I'd recommend simply looking at what your emulator does at each instruction and determine if did everything correctly. If the error occurs after thousands or millions of instructions then it would be more fruitful to compare it against an 8080 emulator that gets the ...


53

For the most part the Z-80 extends the 8080 instruction set. If we consider just the 8080 instructions themselves there are a few incompatibilities: Overflow flag. On the 8080 bit 2 of the flags register only reports the parity of the accumulator after an ALU operation. On the Z-80 it reports parity for logical operations and overflow for arithmetic ...


52

8086 was designed to make asm source porting from 8080 easy (not the other direction). It is not binary compatible with 8080, and not source-compatible either. 8080 is not an x86 CPU. 8080 is a more distant ancestor that had some influence on the design of 8086, but it's not the same architecture. As an analogy, all x86 CPUs are the same genus but ...


43

As was said in the comments, this is the binary long division algorithm. The long division is performed by carefully juggling the bits between the registers and the carry flag. The algorithm is probably best analysed by looking at each half of the loop as a whole. MOV D, A MOV A, E RAL MOV E, A DCR C JZ exit The first half of the loop shifts ...


39

In the case of the Z80, the ALU is only 4 bits wide. That's no problem, since the internals of the CPU are controlled by a program internal to the processor, called the microprogram (or microcode), which is responsible for piping data around in the necessary way to execute some instruction. So if the Z80 gets an instruction like ADD HL, BC, the microprogram ...


38

[Preface: This is neither about discussing programming tricks nor how some changes could squeeze out a byte or two. Code can often be optimized by narrowing down the environment. The examples are meant rather for a generic estimation. ] The question has already been asked in ways of 6502 vs. Z80 and PNDC provided a good answer pointing out that real code ...


37

It was very common to build CPUs out of TTL logic prior to the 4004, 8080 and the 6800. This was the standard way to build later minicomputers. Examples are the Data General NOVA, Xerox Alto and TI-990. Also, if a company needed a processor for, say, a CNC machine or a video game (Vectorbeam), it wasn't unusual for them to build a unique processor from TTL. ...


37

An instruction set can be considered as a Huffman coding of an idealised instruction stream. So the question is really asking which CPUs have a good balance of short encodings for common tasks to longer encodings for rare tasks. However, it is not sufficient to just look at the encoding of individual instructions because a RISC instruction generally does ...


36

How did 8 bit processors such as the Z80 and 8080 perform 16 bit arithmetic? Same way one adds multiple digit numbers on paper. One digit (-pair) at a time and iterating over all digits while incooperating any carry. With(in) a CPU the chunks are ALU sized units like 4/8/16 or 32 bit. As with paper based addition this method can be used for numbers of ...


36

The stack starts wherever you as the programmer choose to initialize it to. Note that the stack grows downwards (i.e. towards lower memory addresses) so you would normally initialize the stack pointer to point to the top of a free area of RAM.


35

The designers of the Z80 thought it would be useful for code to quickly determine whether signed arithmetic operations overflowed. There were a few ways they could have accommodated this: Add a new flag, and use up a couple of opcodes to branch based upon whether the new flag is set or clear. This would require giving up two precious opcodes that could ...


34

The definition of "instruction" and "OP code" (aka operation code) is a bit fuzzy because it depends on how humans view the CPU. So the designers and their marketing department mostly get to pick the numbers. Operation code is the easier of the two: it is the number of different valid instruction byte sequences, excluding those parts of the instruction that ...


33

Did bit one of the Intel 8080's Flags register, the bit between the carry and parity flags, get set to one on startup? TL;DR: No, as there is no flag register on the 8080. Only separate flags. The 'filler' bits (1, 3, 5) only get their values when PUSH PSW is executed. Long Read: The 8080 does not have a flag register, but like its predecessor the 8008, ...


27

... a scaled-down, cost-reduced, clone of the Intel 8080. The Z80 had a massively extended instruction set, featured more addressing modes and had more registers than the 8080. It also had a built-in DRAM refreshing logic. ... and it was more expensive than the 8080! This is the opposite of "cost-reduced". It only used a 4-bit ALU. I assume this would ...


26

Would anyone mind helping me out where the "Stack" start on an Intel 8080? After Reset content of the stackpointer is undefined. Keep in mind, these are early 8 bit machines. There is no huge hardware and microcode that puts every part into a well defined state. For the 8080 the only thing guaranteed is that the PC will be reset to zero and execution ...


26

It didn't move anything. There is no ROM at the beginning of memory. As the system did not include any code in ROM at all by default, ROMs were optional and usually placed at the end of memory. ROM is not needed, because the front panel can be used to halt the CPU, enter a program into RAM without CPU intervention, and command the CPU to execute the code ...


25

To supplement @PeterCordes's excellent answer, I thought it would be worth going into the details of exactly how close to source code compatible the two processors are -- for example, how easy would it be to use textual substitutions (e.g. macros) to automatically translate 8080 code to 8086 code, and what the limitations would be. The first point would be ...


25

I thought the i8080 had 8 16-bit IN ports and 8 16-bit OUT ports. The 8080 does not have any I/O Ports. It's a microprocessor, not a microcontroller. (Maybe the system you're playing with does have these 8+8 ports, but they are always external to the CPU) The 8080 features a 16 bit data/program address space and an 8 bit I/O i/o address space. Or in other ...


25

Would providing full 8080 compatibility have interfered with or made more complicated implementing new features the Z80 designers wanted? It would have made it impossible. Any extension adding functionality will naturally add incompatibility as it needs to use existing resources in a new way. The task to solve is which change will have the least impact and/...


24

Here is an homebrew / educational computer made of LSI / MSI chips : http://www.kenbak-1.net/index.htm Designed in 1971 256 bytes of memory made of MOS shift registers.


23

Foremost, there are direct continuations, CPU's able to execute 8080 code and (basically) hardware compatible, like the 8085, Intel's answer to the Z80, as it's mostly software and hardware compatible. Beside Intel's direct extension, there is of course the series of enhancements of Z80 design, from Z800/Z280 all the way to the eZ80, which in some way can be ...


22

Space Invaders uses a simple display format where bytes are read from memory in order via an address counter, and shifted out via a shift register. Timing is controlled by discrete hardware. The video hardware has priority over the CPU. When it needs to read a byte it asserts the 8080's READY signal, giving it exclusive access to the memory bus. This can be ...


22

I'm going to say "No" simply because the 8086 doesn't support the alternate registers of the Z80. That was a fairly important concept that you can not directly mimic on the 8086. Mind, if you're willing to dedicate memory and whatnot to support it, then, "sure". Replace the Z80 functionality with a macro, say. But now you're stretching it....


21

The 8085, which came out two years after the 8080, rapidly became more popular for most applications because it required only +5 V power (as opposed to +5/-5/+12 V) and less external support circuitry. (Today there are a number of 8085 single-board computer designs available, such as glitchworks and OMEN; 8080 designs exist but seem few and far between.) ...


21

The Z80 is "binary compatible" with the 8080. It adds a bunch of new instructions, but places them all in unused (well, undocumented) opcodes. yes .. err, no, they placed them on redundant opcodes. For example the whole 00-xxx-000 group were NOP instructions for the 8080, while Zilog only left 00h as NOP, while the others became jumps (and EX). ...


20

This document calls out some differences: http://www.msxarchive.nl/pub/msx/mirrors/hanso/datasheets/chipsz80leventhal3.pdf Z80 uses P flag for 2's complement overflow, where 8080 does not DAA instruction corrects both subtraction as well as addition on Z80, but addition only on 8080. Z80 rotate instructions clear the AC flag, but the 8080 does not. Also, ...


20

Hmm, an interesting question to be sure. It certainly would have been possible to make something like a 4004 style microprocessor from TTL chips. In fact, when Intel made their microprocessor, the first in the world, they chose not to pursue a patent for it, because they felt that there was no invention there; it was obvious for someone to go and combine the ...


19

The 8080 is not a microcontroller, but a microprocessor, so it had no special provision for LCD displays, as modern microcontroller may have, except maybe for the ability to use packed BCD numbers. It had no in-built host peripherals that would support protocols like RS232 or SPI. You don't mention what kind of LCD display your college used, so this is only ...


19

I'm actually not aware of any major 8080 test suites; everything I've ever found has been for the Z80 rather than its parent. That aside, I'd heavily suggest you don't discard the CP/M solutions you've found as they're usually pretty trivial to set up as test cases without any of the main substance of a CP/M environment. For example, to run the CP/M version ...


19

85% A Z-80 program will be 15% smaller than an 8080 program. To come up with this guess I took a reasonably tight Z-80 program, the TRS-80 4K Level 1 BASIC ROM and estimated the cost of replacing the Z-80 specific instructions with 8080 code. I'll get back to the limits of this methodology later but for now let me plow on with this example. Of the 4096 ...


Only top voted, non community-wiki answers of a minimum length are eligible