Computer Architecture Lab/Summer2006/cpr/Z80 ATM8 PIC16F627
Instruction Set Summary for Z80, PIC16F627, and ATMega8[edit | edit source]
We compare the following three systems:
- Zilog Z80
- Microchip Technology PIC16F627
- Atmel ATMega8
While Z80 is a microprocessor, PIC16F627 and ATMega8 are microcontrollers.
Let us compare the instruction sets of our 3 CPUs which are hardware dependent (they reside in the chips). As an example, we want to calculate c = a + b + 3, where a, b and c are registers and 3 is a constant value (an immediate).
ADD A, 3 ; A + 3 ADDC A, B ; A + 3 + B + Carry Bit LD C, A ; -> C
MOVF 0x30, 0 ; 3 + register ADDLW 3 MOVWF 0x30 MOVF 0x30, 0 ; a + b -> c ADDWF 0x31, 0 MOVWF 0x32
SUBI 0x30, -3 ; 3 + register MOV 0x30, 0x32 ; a + b -> c ADD 0x32, 0x31
As one can see, Z80 and ATMega8 CPUs, which are using the registers directly, need fewer instructions compared to PIC16F627's to execute the same task. Thus the instructions of the Z80 and ATMega8 are more complex, and so these two CPUs have larger instruction sets. The PIC16F627's relatively smaller instruction set means it often requires more instructions to perform the same operations. While the microcontrollers have a Harvard architecture, the Z80 has a von Neumann.
Memory[edit | edit source]
The Z80, as every microprocessor, only has its internal registers which can be accessed directly or indirectly. The two microcontrollers also have internal RAM for data, while they use FLASH memory to store the program code. While the PIC16F627 separates its memory in four banks which are selected with two bits in the status register, the ATMega8 has only one address space, however the SRAM can only be accessed through indirect addressing. Both access the program memory through a program counter. Comparing the Stack there is also a difference between the microcontrollers. Usually the stack pointer of the ATMega8 is set to point to the end of the SRAM. Whenever a PUSH instruction is executed the stack pointer is decremented. The PIC16F627 has an extra eight-level stack which is organized as a loop, on overflow it is overwritten without affecting any flag.
Dataflow[edit | edit source]
Z80 with its Von Neumann architecture only has one bus for Data and Program, while the microcontrollers, following the Harvard architecture, have two separate busses one for Program and one for Data.
Registers[edit | edit source]
The ATMega8 has 32 general purpose registers and 64 special registers, which are used for counters, external pins, etc.. As already mentioned the PIC16F627 organizes its registers in four banks with 224 bytes for general purpose. The Z80 can use its 6 general purpose registers either as six eight-bit or three 16-bit registers. All together it has got 26 registers.
Pipelining[edit | edit source]
ATMega8 and PIC16F627 utilize a two-stages, fetch and execute, pipelining mechanism, whereas the Z80 does not have any pipelining capabilities at all. In 2001, the eZ80 was introduced, which is an enhanced version of the Z80, using also a two-stages pipelining mechanism.
Execution times[edit | edit source]
Most of the ATMega8's and PIC16F627's instructions need one clock cycle to execute, only instructions affecting the program counter take longer. Additionally ATMega8 has instructions which simply need more time due to higher complexity. The Z80's execution times vary due to no pipelining, from 1 to 6 cycles.