Is the stack width always same as CPU register size?

后端 未结 4 527
青春惊慌失措
青春惊慌失措 2021-01-19 18:08

For example, for a 8-bit CPU, the stack size is expected to be 8-bit wide, and 16-bit CPU vs 16-bit stack width, and 32-bit, 64-bit CPU, and so on. Is it true for all archit

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-19 18:44

    One point not yet mentioned is that some CPUs (e.g. the Microchip PIC family) have a dedicated stack which is not accessed like normal RAM. On the PIC16 series, the stack is tied exclusively to the program counter, and the stack is (presumably) the same width as the program counter. On the PIC18 series, the stack and program counter are both 21 bits wide; the upper 20 bits can be copied to or from the program counter; code can also examine the top stack element as a 5-bit part and two 8-bit parts.

提交回复
热议问题