150 likes | 494 Views
Lecture 11 Z80 Registers. 동국대학교 홍유표. Registers in CPU. A CPU has registers that store key information for CPU operation. For example, PC is a register that stores the address of memory for next instruction fetch. Z80 Registers. Program Counter (PC).
E N D
Lecture 11Z80 Registers 동국대학교 홍유표
Registers in CPU A CPU has registers that store key information for CPU operation. For example, PC is a register that stores the address of memory for next instruction fetch.
Program Counter (PC) The program counter holds the 16-bit address of the current instruction being fetched from memory. The PC is automatically incremented after its contents have been transferred to the address lines.
Accumulator and Flag Registers “A” is an 8-bit accumulators and associated 8-bit flag register “F”. The accumulator holds the results of 8-bit arithmetic or logical operations while the FLAG register indicates specific conditions for 8-bit or 1 16-bit operations, such as indicating whether or not the result of an operation is equal to zero.
Memory Stack 1000 • Bottom of stack: 4001 • As stack grows, SP decreases • No FULL, EMPTY flags • Instead, use CPU register to hold upper/lower limits of stack and checked before PUSH after POP Program Instr. PC 2000 Data AR 3000 Stack SP 3999 4000 4001 DR Stack is placed in a finite portion of main memory SP is a special-purpose register
Stack Pointer (SP) The stack pointer holds the 16-bit address of the current top of a stack located anywhere in external system RAM memory. The external stack memory is organized as a last-in first-out (LIFO) file. Data can be pushed onto the stack from specific CPU registers or popped off of the stack to specific CPU registers through the execution of PUSH and POP instructions.
General Purpose Registers General-purpose registers do not have specific mission so they can be used for any purpose that the programmer wants. each set containing six 8-bit BC, DE, and HL are such registers for Z80.
JP (Jump) • 형식 : JP address • PC <- address • 형식 : JP condition address • If condition is true, PC <- address
Label 을 이용한 JP 명령어의 사용 형식 : JP LABEL (Similar to goto in C.) 예 : …. START : …. …. JP START
CALL 형식 : CALL Label (Similar to function call in C.) 예 : …. CALL DELAY …. DELAY : …. RET
DEC • 형식 : DEC reg • Decrement the content of reg. • If register pair HL contains 1001H, at execution of DEC HL the contents of HL are 1000H.
HW #4 여러분의 Z80 oneboard상 LED에불이 켜지는 코드를 작성해 봅시다. 즉, output port 주소 7번에 다음과 같은 데이터가 나가는 프로그램을 작성해서 내일 실습시간에 보드에 올려 보도록 해요. 0000 1111 프로그램은 오늘 밤 9시까지 작성하여 yhong@dgu.edu와 ykang@mmchips.com로 보내 주세요.