On 12/24/25 13:23, Tom Uban via cctalk wrote:
On 12/24/25 10:08, Robert Armstrong via cctalk wrote:
Can someone explain how the Intel 8008 (yes,
the 8008, NOT the 8080!)
handled saving and restoring the flags during an interrupt?
The 8008 has four flag bits - CZS&P - but there doesn't seem to be
any
explicit equivalent to the PSW register nor any "PUSH PSW" or "POP
PSW" type
instructions. Other than testing the flag bits with the JUMP/CALL/RET
instructions there doesn't seem to be any way to access them.
Interrupts work pretty much like the 8080 - during the interrupt
response
the peripheral forces an instruction onto the bus, typically an RST
opcode
but in theory it could be anything. RST and CALL however only appear to
save the PC on the internal stack, and RET only restores the PC. So
how do
you save and restore the flag bits?
It seems like interrupts would be pretty much useless without
this, so I
must be missing something.
Thanks,
The interrupt handler for 8008 has to save check the state of flags
and save them before doing any other work and then restore the flags
when complete. Here is the power-up/interrupt code I use on a board I
built:
A bit of topic, but seeing this I note that we implemented a hardware
single step and breakpoint for the 6809. What you had to have was a
counter for the S states of the processor, and after some number when
you would let the processor run out of either a go command in the
debugger, or if you were single stepping, you'd set the NMI which would
take you back into the interrupt.
You had to save the flag and other states, etc., before any operations
which would impact them.
Interesting to see this with this processor as well. Not sure if
there's a suitable interrupt to do this in the hardware with an 8008,
but would interesting if there is to have single stepping.
; the power-up reset and i8008 interrupt share the
same start point
; check to see if it's a cold or warm reset/interrupt
rst1: ldh ;save H register in D register
lel ;save L register in E register
lhli intsav ;point to RAM save location
lma ;save A register
sav: lai 000 ;assume zero flag is set
jtz savc ;if true, get carry bit
lai 060 ;assume sign bit is zero (positive word)
jfs savc ;if true, get carry bit
lai 300 ;sign bit was set
savc: rar ;get carry bit
jtp savw ;jump if parity is even
xri 001 ;set parity odd
savw: inl ;point to next RAM byte
lma ;save flags byte
inl ;point to next RAM byte
lmb ;save B register
inl ;point to next RAM byte
lmc ;save C register
inl ;point to next RAM byte
lmd ;save H register
inl ;point to next RAM byte
lme ;save L register
lhli coldst ;read the cold/warm reset indicator
lam ;into A
cpi WFLAG ;compare with the value for warm
jtz warm ;it is a warm reset or interrupt
; cold start, perform one-time initialization
cold:
--tom