Hot answers tagged

94

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 ...


50

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 ...


46

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 ...


38

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 ...


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 ...


35

[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 ...


32

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, ...


31

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 ...


31

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 ...


29

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.


25

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. ...


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 ...


24

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 ...


23

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 ...


23

... 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 ...


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 ...


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

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.) ...


19

Overflow doesn't mean what you think. That flag exposes the internal ALU carry from bit 6 -> bit 7. It's needed when you are handling the most significant byte of a 2-complement number, because you can't use the carry for that purpose here: it's jumbled by the MSB sign bit. When you don't add or subtract 2-complement numbers (MSB isn't meant as sign bit but ...


19

I cannot speak about Pokémon in particular, but as a programmer for ~30 years, I'll answer thus: either laziness, incorrect assumption, or surprise. Laziness After an operation that overflows, you need to write extra code to check for the overflow, and then decide what to do about it. That's extra time, and extra work. Incorrect assumption (Often ...


18

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 ...


18

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 ...


18

How do you compare two signed numbers in z80 assembly? Signed arithmetics - this includes compare - uses the Overflow flag (P/V) to signal any over/underflow. To decode it has to be seen in relation with the sign flag. This is a two step process: Step 1: Test for equal. If Z flag is set then V (value compared) is equal to A If Z flag is reset then Vr is ...


18

The other answers explain it from a software perspective. Here is the hardware perspective, which may explain why it is another "address space". The 8080 has 16 pins for the address bus A0-A15, 8 pins for the data bus D0-D7, and pins DBIN and !WR to time reads and writes. The processor re-uses the data bus to output information ("processor state") about ...


18

For Spectrum BASIC, the routine for Small Integers (16 bit) can be seen on page 179 of the Complete ZX Spectrum ROM Disassembly, where it loops over the sixteen bits of one operand, shifting them into the carry bit, adding successively doubling values to the result value each time the test passes, and testing for overflow if the result doesn't fit in a small ...


17

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.


17

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). Likewise ...


16

It's absolutely possible and fun as well! First, skip the 8080 projects for now. They require much more "glue" logic and knowledge to get a basic computer up and running. Second, focus on either the 6502 or Z80 CPU's. BOTH, BTW, are still being made NEW today. They are still in production. I'm going to offer a little biased opinion here but for good ...


16

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 ...


16

Multiplying (and dividing) by powers of 2 has always been trivial and fast even for 8-bit processors like Z80 or 6502, with shifting instructions (commonly arithmetic shift left aka ASL). But those processors didn't have a MUL instruction so when it came to non-power of 2 multiplication, it always involved shifting, testing bit and adding shifted result if ...


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