3

Intel 8008 CPU has an internal stack, implemented as an 8 x 14-bit scratchpad. How does it work exactly? Is there any "invisible 3-bit stack pointer"?

I want to know what happens when the stack is full and call operation is performed. Is the stack "infinite" and the oldest value is dropped, or the oldest saved return address is overwritten?

And what happens when the stack is "empty" and return operation is performed? Does it read any undefined/unpredictable value?

  • Interest only: A friend did a Masters degree using an 8008 and (AFAIR) 1702 EPROMS. About 1974 from memory. I'll send hin a link to this thread for interest :-). – Russell McMahon Aug 2 at 9:13
6

Intel 8008 CPU has an internal stack, implemented as an 8 x 16-bit scratchpad.

No, it's entries are 'only' 14 bit long, as all addressing on the 8008 supports only 14 bit (*1).

How does it work exactly? Is there any "invisible 3-bit stack pointer"?

Yes. In reality it's not a stack pointer, but selects the active PC.

A three-bit address pointer is used to designate the present
location of the program counter.

(From the 1973 User Manual section III.B.1 p.7)

I want to know what happens when the stack is full and call operation is performed.

It simply cycles (7->0).

When the capacity of the stack is exceeded, the address pointer
recycles and the content of the lowest level register is destroyed.

(From the 1973 User Manual section III.B.1 p.7)

Is the stack "infinite" and the oldest value is dropped, or the oldest saved return address is overwritten?

Erm, not clear what 'dropping' is supposed meant. The stack pointer simply runs over, reusing the oldest entry (see above)

And what happens when the stack is "empty" and return operation is performed? Does it read any undefined/unpredictable value?

It switches to the previous PC, which my hold an undefined value - or to be exact, whatever has been left here by some previous use.

The manual states that all registers, as well as stack pointer and stack are cleared (*2) on startup (*3).

When power (Voo ) and clocks (cP1 , cP2 ) are first turned on, a flip-flop internal to the
8008 is set by sensing the rise of Voo . This internal signal forces a HALT (00000000)
into the instruction register and the 8008 is then in the STOPPED state. The following
sixteen clock periods after entering the STOPPED state are required to clear (logic "0")
memories (accumulator, scratch pad, program counter, and stack). During this time the
interrupt line has been at logic "0". Any ti me after the memories are cleared, the 8008
is ready for normal operation.

(From the 1973 User Manual section V.A.2 p.20)


*1 - The top two bits of the second address byte signal the access type as

  • Program
  • Memory Read
  • IO
  • Memory Write

*2 - Personally I'd be a bit careful here, as 16 cycles do not really seam enough to do all of this.

*3 - The 8008 has no Reset input, but uses power-up to initialize.

| improve this answer | |
  • (My mistake, of course, there are 14 bit long... Thank you) – Martin Maly Aug 1 at 16:20
  • 1
    @Taschi IIUIC the stack is implemented as a ring buffer. The first 8 (nested) calls get slots 0 through 7; if there's a 9th nested call it overwrites the value in slot 0 (likewise a 10th nested call overwrites the value in slot 1, etc.). – Alex Hajnal Aug 2 at 2:55
  • 1
    @Taschi I don't think it is. – Alex Hajnal Aug 2 at 2:57
  • 1
    @Taschi Nothing. Come on, who needs more than 7 subroutine level? I'm smiling while being serious. We talk about one of the first CPUs, barely functional. There is no room to add hardware to pamper bad programming. Just think about the additional requirements beside checking, like issueing exception and handling them. That didn't become a thing in common micros until a decade later. Literally no room for such runtime issues as well, as 1 KiB semiconductor memory in 1973 was about 800-1000 USD. Last but not least, it's never accidental how many levels a program uses. – Raffzahn Aug 2 at 7:22
  • 1
    Great for teaching, but almost no real world use case. I take it you've never needed to parse JSON? – another-dave Aug 3 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.