0% found this document useful (0 votes)
11 views8 pages

Z80 Trainer Program Execution Guide

The document describes several problems involving executing programs on an ADTEK Z80 Trainer to input and manipulate data and display results. Example programs are provided that double input data, multiply by 5, increase values 7 times, and take the difference between values in the accumulator and register C. The programs demonstrate instructions like IN, OUT, ADD, SUB, and LD and the resulting register contents are shown.

Uploaded by

-Kenjie Ordoñez
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views8 pages

Z80 Trainer Program Execution Guide

The document describes several problems involving executing programs on an ADTEK Z80 Trainer to input and manipulate data and display results. Example programs are provided that double input data, multiply by 5, increase values 7 times, and take the difference between values in the accumulator and register C. The programs demonstrate instructions like IN, OUT, ADD, SUB, and LD and the resulting register contents are shown.

Uploaded by

-Kenjie Ordoñez
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

POLYTECHNIC UNIVERSITY OF THE PHILIPPINES

College of Engineering
Computer Engineering Department
NDC Campus, Sta. Mesa, Manila

Laboratory Activity

Program Execution on ADTEK Z80 Trainer

Submitted By:

Agut, Raymond Kevin M.


Ordoñez, Kenjie D.
Sevilla, Evan M.
Talantor, Maria Regine N.

Submitted To:

Engr. Julius S. Cansino

Date Performed: August 2, 2010


Date Submitted: August 2, 2010
PROBLEM A

Input and double the data from the input port 01H and output it to the output port 00H.

EXAMPLE 1: A= 0AH
Instruction Content of Registers
Opcode HEX A B C D E ZF CY SF PF OF HC
IN A, (01H) 00 00 DB 01 0AH ? ? ? ? 0 0 0 1 0 0
ADD A, A 00 00 00 87 14H ? ? ? ? 0 0 0 1 0 1
OUT (00H), A 00 00 D3 00 14H ? ? ? ? 0 0 0 1 0 1
HALT 00 00 00 76 - - - - - - - - - - -

SIMULATION:
IN A, (01H); A = 0AH 0000 1010
ADD A, A; A= A + A 0000 1010
+ 0000 1010
0001 0100 = 14H
OUT (00H), A; 0001 0100 = 14H
HALT; STOP
LED OUTPUT 0000 0000

EXAMPLE 2: A=02H
Instruction Content of Registers
Opcode HEX A B C D E ZF CY SF PF OF HC
IN A, (01H) 00 00 DB 01 02H ? ? ? ? 0 0 0 0 0 0
ADD A, A 00 00 00 87 04H ? ? ? ? 0 0 0 0 0 0
OUT (00H), A 00 00 D3 00 04H ? ? ? ? 0 0 0 0 0 0
HALT 00 00 00 76 - - - - - - - - - - -

SIMULATION:
IN A, (01H); A = 02H 0000 0010
ADD A, A; A= A + A 0000 0010
+ 0000 0010
0000 0100 = 04H
OUT (00H), A; 0000 0100 = 04H
HALT; STOP
LED OUTPUT 0000 0000
PROBLEM B

Input the data on the input port 01H; multiple this data by five, and output it to the output port 00H.

EXAMPLE 1: A=05H
Instruction Content of Registers
Opcode HEX A B C D E ZF CY SF PF OF HC
IN A, (01H) 00 00 DB 01 05H ? ? ? ? 0 0 0 1 0 0
LD B, A 00 00 00 47 05H 05H ? ? ? 0 0 0 1 0 0
ADD A, A 00 00 00 87 0AH 05H ? ? ? 0 0 0 1 0 0
ADD A, A 00 00 00 87 14H 05H ? ? ? 0 0 0 1 0 1
ADD A, B 00 00 00 80 19H 05H ? ? ? 0 0 0 0 0 1
OUT (00H), A 00 00 D3 00 19H 05H ? ? ? 0 0 0 0 0 1
HALT 00 00 00 76 - - - - - - - - - - -

SIMULATION:
IN A, (01H); A = 05H 0000 0101
LD B, A; B = 05H 0000 0101
ADD A, A; 2A= A + A 0000 0101
+ 0000 0101
0000 1010 = 0AH
ADD A, A; 4A= 2A + 2A 0000 1010
+ 0000 1010
0001 0100 = 14H
ADD A, B; 5A = 4A + A 0001 0100
+ 0000 0101
0001 1001 = 19H
OUT (00H), A; 0001 1001 = 19H
HALT; STOP
LED OUTPUT 0000 0000

EXAMPLE 2: A=04H
Instruction Content of Registers
Opcode HEX A B C D E ZF CY SF PF OF HC
IN A, (01H) 00 00 DB 01 04H ? ? ? ? 0 0 0 0 0 0
LD B, A 00 00 00 47 04H 04H ? ? ? 0 0 0 0 0 0
ADD A, A 00 00 00 87 08H 04H ? ? ? 0 0 0 0 0 0
ADD A, A 00 00 00 87 10H 04H ? ? ? 0 0 0 0 0 1
ADD A, B 00 00 00 80 14H 04H ? ? ? 0 0 0 1 0 1
OUT (00H), A 00 00 D3 00 14H 04H ? ? ? 0 0 0 1 0 1
HALT 00 00 00 76 - - - - - - - - - - -

SIMULATION:
IN A, (01H); A = 04H 0000 0100
LD B, A; B = 04H 0000 0100
ADD A, A; 2A= A + A 0000 0100
+ 0000 0100
0000 1000 = 08H
ADD A, A; 4A= 2A + 2A 0000 1000
+ 0000 1000
0001 0000 = 10H
ADD A, B; 5A = 4A + A 0001 0000
+ 0000 0100
0001 0100 = 14H
OUT (00H), A; 0001 0100 = 14H
HALT; STOP
LED OUTPUT 0000 0000
PROBLEM C

Input data on the input port 01H; increase this data seven times and output it to the output port 00H.

EXAMPLE 1: A=02H
Instruction Content of Registers
Opcode HEX A B C D E ZF CY SF PF OF HC
IN A, (01H) 00 00 DB 01 02H ? ? ? ? 0 0 0 0 0 0
LD B, A 00 00 00 47 02H 02H ? ? ? 0 0 0 0 0 0
ADD A, A 00 00 00 87 04H 02H ? ? ? 0 0 0 0 0 0
ADD A, B 00 00 00 80 06H 02H ? ? ? 0 0 0 1 0 0
ADD A, A 00 00 00 87 0CH 02H ? ? ? 0 0 0 1 0 0
ADD A, B 00 00 00 80 0EH 02H ? ? ? 0 0 0 0 0 0
OUT (00H), A 00 00 D3 00 0EH 02H ? ? ? 0 0 0 0 0 0
HALT 00 00 00 76 - - - - - - - - - - -

SIMULATION:
IN A, (01H); A = 02H 0000 0010
LD B, A; B = 02H 0000 0010
ADD A, A; 2A= A + A 0000 0010
+ 0000 0010
0000 0100 = 04H
ADD A, B; 3A= 2A + A 0000 0100
+ 0000 0010
0000 0110 = 06H
ADD A, A; 6A= 3A +3A 0000 0110
+ 0000 0110
0000 1100 = 0CH
ADD A, B; 7A = 6A + A 0000 1100
+ 0000 0010
0000 1110 = 0EH
OUT (00H), A; 0000 1110 = 0EH
HALT; STOP
LED OUTPUT 0000 0000

EXAMPLE 2: A=06H
Instruction Content of Registers
Opcode HEX A B C D E ZF CY SF PF OF HC
IN A, (01H) 00 00 DB 01 06H ? ? ? ? 0 0 0 1 0 0
LD B, A 00 00 00 47 06H 06H ? ? ? 0 0 0 1 0 0
ADD A, A 00 00 00 87 0CH 06H ? ? ? 0 0 0 1 0 0
ADD A, B 00 00 00 80 12H 06H ? ? ? 0 0 0 1 0 1
ADD A, A 00 00 00 87 24H 06H ? ? ? 0 0 0 1 0 1
ADD A, B 00 00 00 80 2AH 06H ? ? ? 0 0 0 0 0 1
OUT (00H), A 00 00 D3 00 2AH 06H ? ? ? 0 0 0 0 0 1
HALT 00 00 00 76 - - - - - - - - - - -

SIMULATION:
IN A, (01H); A = 06H 0000 0110
LD B, A; B = 06H 0000 0110
ADD A, A; 2A= A + A 0000 0110
+ 0000 0110
0000 1100 = 0CH
ADD A, B; 3A= 2A + A 0000 1100
+ 0000 0110
0001 0010 = 12H
ADD A, A; 6A= 3A +3A 0001 0010
+ 0001 0010
0010 0100 = 24H
ADD A, B; 7A = 6A + A 0010 0100
+ 0000 0110
0010 1010 = 2AH
OUT (00H), A; 0010 1010 = 2AH
HALT; STOP
LED OUTPUT 0000 0000
PROBLEM E

Load a byte F8H to the accumulator, and then load another byte at Register C. Take the difference
between the accumulator and Register C. Display the result at the output port 00H.

EXAMPLE 1: A=48H, C=03H


Instruction Content of Registers
Opcode HEX A B C D E ZF CY SF PF OF HC
LD A, 48H 00 00 3E 48 48H ? ? ? ? 0 0 0 1 0 0
LD C, 03H 00 00 0E 03 48H ? 03H ? ? 0 0 0 1 0 0
SUB A, C 00 00 00 91 45H ? 03H ? ? 0 1 0 0 1 1
OUT (00H), A 00 00 D3 00 45H ? 03H ? ? 0 1 0 0 1 1
HALT 00 00 00 76 - - - - - - - - - - -

SIMULATION:
LD A, 48H; A = 48H 0100 1000
LD C, 03H; C = 03H 0000 0011
SUB A, C; 0100 1000
0000 0011 – 1111 1100
+ 0000 0001
1111 1101 = TWO’S COMPLEMENT
0100 1000
+ 1111 1101
1 0100 0101 = 45H
OUT (00H), A; 0100 0101 = 45H
HALT; STOP
LED OUTPUT 0000 0000

EXAMPLE 2: A=48H, C=05H


Instruction Content of Registers
Opcode HEX A B C D E ZF CY SF PF OF HC
LD A, 48H 00 00 3E 48 48H ? ? ? ? 0 0 0 1 0 0
LD C, 03H 00 00 0E 05 48H ? 05H ? ? 0 0 0 1 0 0
SUB A, C 00 00 00 91 43H ? 05H ? ? 0 0 0 0 1 1
OUT (00H), A 00 00 D3 00 43H ? 05H ? ? 0 0 0 0 1 1
HALT 00 00 00 76 - - - - - - - - - - -

SIMULATION:
LD A, 48H; A = 48H 0100 1000
LD C, 03H; C = 05H 0000 0101
SUB A, C; 0100 1000
0000 0101 – 1111 1010
+ 0000 0001
1111 1011 = TWO’S COMPLEMENT
0100 1000
+ 1111 1011
1 0100 0011 = 43H
OUT (00H), A; 0100 0011 = 43H
HALT; STOP
LED OUTPUT 0000 0000

You might also like