Did bit one of the Intel 8080's Flags register, the bit between the carry and parity flags, get set to one on startup? If so what was the reason for this, and was this inherited from the 8008 Flags register?
3 Answers
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, separate flags. Which are, like other answers correctly describe, in random states after power-up/reset.
The 8080 flags have no access in register form for the programmer. Only testing in conditioned instructions is possible. Setting could only be done via instructions with implied result stored in any of them. The only access as byte data was when pushed onto the stack.
When storing the flags to the stack (PUSH PSW) the second byte is synthesized from the flag bits and completed by 'filler' values for positions 1, 3, 5 (1, 0, 0). This guarantees that in memory bit 1 always will be 1.
(From "8080 Assembly Language Programming Manual", "Rev B", p.22/23)
During store (PUSH PSW)
If register pair PSW is specified, the first byte of information
saved holds the contents of the A register; the
second byte holds the settings of the five condition bits,
i.e., Carry, Zero, Sign, Parity, and Auxiliary Carry. The format
of this byte is:
| | | |A| | | | |
|S|Z|0|C|0|P|1|C|
S State of Sign bit
Z State of Zero bit
0 always 0
AC State of auxiliary Carry bit
0 always 0
P State of Parity bit
1 always 1
C State of Carry bit
For retrieval (POP PSW):
[...] If register pair
PSW is specified, the byte of data indicated by the contents
of the stack pointer plus one is used to restore the values of
the five condition bits (Carry, Zero, Sign, Parity, and Auxiliary
Carry) using the format described in the last section.
If so what was the reason for this, and was this inherited from the 8008 Flags register?
In part, as they were separate single-bit entities. Except the 8008 did not allow any access to the flags beside testing them in conditional instructions. There was no instruction to store or retrieve them at all.
Tidbits on x80-Family Flags:
The grand daddy of all things 80, the Datapoint 2200 laid the ground here by defining them as separate flip-flops, only accessible using conditional instructions. They are not presented as a register-like structure in any way.
The 8008, being a single chip implementation of the 2200, followed that, while the 8080 did introduce a register-like view for its programming model, but not in hardware.
Only the follow up 8085 did introduce a real flag register (*1), still not in the register file, but kept separate, like the A register (*2). Now bit 1 was used as V flag. That's one of the incompatibilities with 8080 code - and one way to detect a 8085: by pushing a cleared HL, popping PSW, pushing PSW again and then checking L. If bit 1 is still cleared, it's an 8085.
The Z80, in contrast, added a flag register (or more accurately two, as there's one in the alternate register set too) as part of its huge register file, but workings were still based on separate flip-flops located near the ALU. At the beginning of every instruction the content of the flag register in use got copied into the flag flip-flops, and copied back at the end. This process is a must when handling two separate register sets and also keeping the flags close to the ALU.
The Datapoint 2200 Version 2 also had two register sets: no flag register, but two sets of flag flip-flops multiplexed toward the ALU (like the registers).
*1 - Well, almost, as only 7 storage bits are implemented. Bit 3 was replaced by a circuit to always drive 0 when read.
*2 - On the 8008 and 8080, the A register was also not a member of the register file.
According to the Intel 8080 microcomputer systems user’s manual, the contents of registers are indeterminate on startup:
The contents of its program counter, stack pointer, and the other working registers are naturally subject to random factors and cannot be specified.
And further on:
Note, however, that the
RESEThas no effect on status flags, or on any of the processor's working registers (accumulator, registers, or stack pointer). The contents of these registers remain indeterminate, until initialized explicitly by the program.
- 1,611
- 14
- 31
- 121,835
- 17
- 505
- 462
According to the manual, the only thing that is explicitly set after RESET in the 8080 is the program counter. Everything else is indeterminate:
Note, however,that the RESET has no effect on status flags, or on any of the processor's working registers (accumulator, registers, or stackpointer). The contents of these registers remain indeterminate, until initialized explicitly by the program.
If they don't initialize anything at all, it is very unlikely they'd initialize something that isn't even used.
- 1,554
- 14
- 21
- 34,832
- 4
- 89
- 170
-
2I like the 'unlikely' part :)) Except, for all ever visible to programmers, they will look like initialized. Cool, isn't it? – Raffzahn Sep 12 '19 at 18:14


PUSH PSW, is there a known reason why they weren't just stored in, say, bits 0-4, without any "gap bits"? Or, like bit 1 happening to be stored as a 1, is this likely to be just an "accident" of the way the chip was laid-out? – TripeHound Sep 13 '19 at 09:48