microprocessor lab manual - study...
Post on 05-Mar-2021
25 Views
Preview:
TRANSCRIPT
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
1
Hetauda City College Affiliated to Tribhuwan University
LAB MANUAL
ON
8085 MICROPROCESSOR
BSC-CSIT: II SEM
Prepared By:
Sulav Paudel (MSc)
Lecturer
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
2
PERFORM ALL PROGRAMS AND PREPARE THE LAB REPORT INCLUDING OBJECTIVE,
ALGORITHMS, PROGRAMS, OBSERVATION AND RESULT OR COMCLUSION
LAB 1
1.1 STORE 8-BIT DATA IN MEMORY LOCATION
AIM: To perform the 8085 assembly program to store 8-bit data 2AH in a memory location
8050H.
ALGORITHM 1:
Start the program by loading the first data into an accumulator.
Store accumulator contents at given memory address.
Terminate program.
PROGRAM 1:
MVI A, 2AH
STA 8050H
HLT
ALGORITHM 2:
Start the program by loading the first data into an accumulator.
Load HL pair register with given memory address.
Store accumulator contents in memory location pointed by HL register pair.
Terminate program.
PROGRAM 2:
LXI H, 8050H
MVI M, 2AH
HLT
1.2 EXCHANGE THE CONTENTS OF MEMORY LOCATIONS
AIM: To perform the 8085 assembly program exchange the contents of memory locations
5000H and 4000H.
ALGORITHM 1:
Start the program by loading the first data of memory location 4000H into
accumulator.
Move the data to a register (B register).
Load the second data of memory location 5000H into accumulator.
Store the data of accumulator at address 4000H
Move the data back into accumulator that is saved in a register (B register).
Store the data of accumulator at address 5000H
Terminate program.
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
3
PROGRAM 1:
LDA 4000H
MOV B, A
LDA 5000H
STA 4000H
MOV A, B
STA 5000H
HLT
ALGORITHM 2:
Start the program by initializing register pair (HL) as a pointer to memory location
4000H.
Initializing register pair (DE) as a pointer to a memory location 5000H.
Move the data of memory location 4000H into a register (B register).
Move the data of memory location 5000H into an accumulator.
Move the data of accumulator into memory location pointed by register pair (HL).
Move the data from register (B) into accumulator.
Store the data of accumulator into memory location pointed by register pair (DE).
Terminate program.
PROGRAM 2:
LXI H, 4000H
LXI D, 5000H
MOV B, M
LDAX D
MOV M, A
MOV A, B
STAX D
HLT
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
4
PERFORM ALL PROGRAMS AND PREPARE THE LAB REPORT INCLUDING OBJECTIVE,
ALGORITHMS, PROGRAMS, OBSERVATION AND RESULT OR COMCLUSION
LAB 2: Use 8085 KIT (MPS 85-3)
RAM USAGE
The system monitor utilizes RAM locations 8F90H to 8FFFH for Storing the System Stack
and variables. User programs should not disturb this area; otherwise the results are
unpredictable.
2.1 EXAMINE/MODIFY MEMORY COMMAND
FUNCTION: This command is used to examine the contents of selected memory
locations. The contents can be optionally modified if the memory location is in
RAM area.
FORMAT: EXAM MEM <address> NEXT [[<data>] NEXT/PREV]* [EXEC]
Example 1: Examining a series of memory locations starting from 0000H (the start of the
keyboard monitor).
Key Pressed Display
Comments Address Field Data Field
RESET -UPS 85 System Reset
EXAM MEM . Examine Memory command
0 0000 First memory location to be
examined 0000H
NEXT 0000 F3 Contents of this location.
NEXT 0001 3E Next location and its
contents.
NEXT 0002 0F Next location and its
contents.
PREV 0001 3E Previous location and its
contents.
EXEC - Command
termination/prompt.
RESET -UPS 85 System Reset
EXAM MEM . Examine Memory command
8 0008.
D 008D. Memory location to be
examined & modified.
0 08D0. Memory location to be
examined & modified.
0 8D00.
NEXT 8D00 XX. Contents of this location
A 8D00 0A. New data to be entered
F 8D00 AF.
EXEC - Command termination
prompt
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
5
2.2 EXAMINE/MODIFY REGISTER COMMAND
FUNCTION: The Examine Register Command is used to examine and optionally
modify the contents of any of 8085s’ registers.
FORMAT: EXAM REG <reg key> [[<data>] NEXT]* [EXEC]
Example 1: Examining a series of processor register contents
Key Pressed Display
Comments Address Field Data Field
RESET -UPS 85 System Reset
EXAM REG . Examine Register Command
8/H H XX. Contents of register.
8 H 08. New data.
NEXT L XX. H register updated. Next
register’s contents displayed.
EXEC - Command termination
prompt.
2.3 GO COMMAND
FUNCTION: The GO command is used to transfer control of the system from the
monitor to user’s program.
FORMAT: GO address EXEC
Example 1: Suppose the following program is entered in the memory by EXAM MEM
command.
Location Opcode Mnemonic
8000 3E MVI A, 42
8001 42
8002 4F MOV C, A
8003 EF RST 5
To run this program, press the keys according to the following sequence.
Key Pressed Display
Comments Address Field Data Field
RESET -UPS 85 System Reset
GO XXXX. XX GO command; current PC
and the byte at this PC are
displayed.
8 0008. New starting address.
0 0080.
0 0800.
0 8000.
EXEC -UPS 85 Program is executed from
8000H control returned to
the monitor.
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
6
Example 2: Fill the registers A and C with 00H. Execute the above program from 8000H.
Later examine the contents of reg A & C. Both the registers must contain 42H.
Key Pressed Display
Comments Address Field Data Field
RESET -UPS 85 System Reset
EXAM REG . Examine Register command
A A XX. Content of reg A
0 A 00. Reg A altered.
NEXT B XX. Content of reg B
NEXT C XX. Content of reg C
0 C 00. Reg C altered.
EXEC - Command terminated
GO XXXX. XX GO Command; Current PC
and the byte at this PC are
displayed.
8 0008. New value of the PC
0 0080.
0 0800.
0 8000.
EXEC -UPS 85 Control returns to monitor
EXAM REG . Examine Reg command
A A 42. Contents of reg A
NEXT B XX. Contents of reg B
NEXT C 42. Contents of reg C
EXEC - Control returns to monitor
due to the break-point.
2.4 SINGLE STEP COMMAND
FUNCTION: This command is used to execute a program, one instruction at a time.
With each instruction executed, control is returned to the monitor. Thus, this
command is an extremely useful debugging tool.
FORMAT:
SINGLE STEP [<Start address> NEXT <Start address> NEXT]* EXEC
Example 1: Assume the program given in Example 1 of GO Command illustration is entered
in the memory. Now this program can be single-stepped as follows.
Key Pressed Display
Comments Address Field Data Field
RESET -UPS 85 System Reset
SINGLE STEP XXXX. XX Current value of PC and the
byte at this PC
8 0008.
0 0080.
0 0800.
0 8000.
NEXT 8002 4F Instruction at 8000 is
executed. Next instruction to
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
7
be executed is displayed.
NEXT 8003 EF Next instruction
EXEC - Control returns to monitor
due to the break-point.
2.5 BLOCK MOVE COMMAND
FUNCTION: This command is used to move a block of data from one area of the
memory to another area.
FORMAT:
BLK MOVE <Start address> NEXT <End address> NEXT <Destination address>
EXEC
Example 1: Moving the block of program code listed in the example for the GO command.
Key Pressed Display
Comments Address Field Data Field
RESET -UPS 85 System Reset
BLK MOVE . Block move command
8 0008. Start address of source block
0 0080.
0 0800.
0 8000.
NEXT .
8 0008. End address of source block.
0 0080.
0 0800.
3 8003.
NEXT .
8 0008. Destination address
8 0088.
0 0880.
0 8800.
EXEC - Block move operation
successful. Command
prompt.
2.6 INSERT COMMAND
FUNCTION: This command is used to insert one or more instructions into the user
program.
FORMAT:
INSERT <Low-Limit> NEXT <High-Limit> NEXT <Low Insert Address> NEXT
<No. of Bytes> NEXT <data> NEXT <data> NEXT .... [EXEC]
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
8
Example 1: Assume that the following program has already been entered into memory using
EXAM MEM Command.
LOCATION VALUE INSTRUCTION
8000 C5 PUSH B
8001 0B DELAY: DCX B
8002 78 MOV A,B
8003 B1 ORA C
8004 C2 JNZ DELAY
8005 01
8006 80
8007 C1 POP B
8008 D1 POP D
8009 E1 POP H
800A EF RET 5
Now, suppose, you discovered that you did not initialize BC register pair before starting the
DELAY. You can insert one instruction, say LXI B, 3030H starting at the location 8001 by
the following key sequence.
Key Pressed Display
Comments Address Field Data Field
RESET -UPS 85 System Reset
INSERT XXXX. XX Current Low-Limit
8 0008. The Low Limit of user
program
0 0080.
0 0800.
0 8000.
NEXT XXXX. Current High-Limit
8 0008. The High-Limit of the user
program
0 0080.
0 0800.
A 800A.
NEXT .
8 0008. Low Insert Address
0 0080.
0 0800.
1 8001.
NEXT .
3 0003. Insert one instruction of 3
Bytes
NEXT 8001 XX. Start entering the instruction
1 8001 01.
NEXT 8002 XX.
3 8002 03.
0 8002 30.
NEXT 8003 XX.
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
9
3 8003 03.
0 8003 30.
EXEC - Instruction inserted return to
command prompt.
To see that the instruction has indeed been inserted, you can use the EXAM MEM command
to observe the contents of the locations 8000H to 800DH (800A+3=800D). Also note that the
address reference for the JNZ instruction has changed from 8001 to 8004.
2.7 DELETE COMMAND
FUNCTION: This command is used to delete one or more instructions from the
user program.
FORMAT:
DELETE <Low-Limit> NEXT <High-Limit> NEXT <Low Delete Address> NEXT
<High Delete Address> EXEC
Example 1: After inserting the instruction and after examining the program in 2.6 INSERT
COMMAND, Example 1, suppose you discover that you have two extra instructions POP D
and POP H. You can delete these instructions by the following key sequence.
Key Pressed Display
Comments Address Field Data Field
RESET -UPS 85 System Reset
DELETE 8000. Current Low-Limit. You do
not want to change it. So
press NEXT.
NEXT 800A. Current Hight-Limit.
8 0008. New High-Limit
0 0080.
0 0800.
D 800D.
NEXT . Enter Low Delete Address.
Note that POP D is now at
800BH and not at 8008H
8 0008.
0 0080.
0 0800.
B 800B.
NEXT . Enter High Delete Address.
8 0008.
0 0080.
0 0800.
C 800C.
EXEC - The two bytes are deleted.
Command prompt appears.
To check the operation, use EXAM MEM key to observe the contents location 8000H to 800BH.
They should be C5, 01, 30, 0B, 78, B1, C2, 04, 80, C1, C9.
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
10
PERFORM ALL PROGRAMS AND PREPARE THE LAB REPORT INCLUDING OBJECTIVE,
ALGORITHMS, PROGRAMS, OBSERVATION AND RESULT OR COMCLUSION
LAB 3
3.1 STORE 8-BIT DATA IN MEMORY LOCATION
AIM: Loads the registers B and C with specific values and stores a specific value in a RAM
location. Assume the program is to be loaded from 8000 H. The program and the hand
assembly are shown below.
LOCATION CONTENTS MNEMONIC COMMENTS
8000 06 22 MVI B, 22H Initialize Reg B
8002 0E 82 MVI C, 82H Initialize Reg C
8004 78 MOV A, B
8005 32 00 81 STA 8100H Load the RAM
location
8008 EF RST 5 Return control to the
monitor
3.2 ADDITION OF TWO 8 BIT NUMBERS
AIM: To perform the subtraction of two 8 bit numbers using 8085 Kit (MPS 85-3) and also
run the program in 8085 Simulator.
ALGORITHM:
Start the program by loading the first data into Accumulator.
Move the data to a register (Say B Register).
Get the second data and load into Accumulator.
Add the two register contents.
Check the carry.
Store the value of sum and carry in memory location.
Terminate the program.
LOCATION CONTENTS MNEMONIC COMMENTS
8000 0E 00 MVI C, 00H Initialize register C
to 00H
8002 21 00 81 LXI H, 8100 HL points 8100H
memory location
8005 7E MOV A, M Move data
8006 23 INX H
8007 86 ADD M Add contents
8008 82 0C 80 JNC LOOP Jump control
800B 0C INR C
800C 23 LOOP: INX H
800D 77 MOV M, A
800E 23 INX H
800F 71 MOV M, C
8010 EF RST 5 Return control to the
monitor
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
11
PERFORM ALL PROGRAMS AND PREPARE THE LAB REPORT INCLUDING OBJECTIVE,
ALGORITHMS, PROGRAMS, OBSERVATION AND RESULT OR COMCLUSION
LAB 4
4.1 SUBTRACTION OF TWO 8 BIT NUMBERS
AIM: To perform the subtraction of two 8 bit numbers using 8085 Kit (MPS 85-3) and also
run the program in 8085 Simulator.
ALGORITHM:
Start the program by loading the first data into Accumulator.
Move the data to a register (Say B Register).
Get the second data and load into Accumulator.
Subtract the two register contents.
Check the carry.
If carry is present take 2’s complement of Accumulator
Store the difference value and value of borrow in memory location.
Terminate the program.
LOCATION CONTENTS MNEMONIC COMMENTS
8000 0E 00 MVI C, 00H Initialize register C
to 00H
8002 21 00 81 LXI H, 8100 HL points 8100H
memory location
8005 7E MOV A, M Move data
8006 23 INX H Increment HL pair
8007 96 SUB M Subtract contents
8008 82 0E 80 JNC LOOP Jump control
800B 2F CMA Complement Acc
800C 3C INR A Increment Acc
800D 0C INR C Increment C Reg
800E 23 LOOP: INX H Increment HL pair
800F 77 MOV M, A Move content
8010 23 INX H Increment HL pair
8011 71 MOV M, C Move content
8012 EF RST 5 Return control to the
monitor
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
12
PERFORM ALL PROGRAMS AND PREPARE THE LAB REPORT INCLUDING OBJECTIVE,
ALGORITHMS, PROGRAMS, OBSERVATION AND RESULT OR COMCLUSION
LAB 5
5.1 MULTIPLICATION OF TWO 8 BIT NUMBERS
AIM: To perform the multiplication of two 8 bit numbers using 8085 Kit (MPS 85-3) and
also run the program in 8085 Simulator.
ALGORITHM:
Start the program by loading the 00H data into Accumulator.
Get the first data to a register (Say B Register).
Get the second data to a register (Say C Register) act as a counter loop.
Add the first data with accumulator content.
Check the carry.
If carry is present, increment the value of carry.
Decrement the value of second data. (C Register)
Check the zero flag.
If zero flag is reset, then repeat addition step else store the value of product and carry
in memory location.
Terminate the program.
LOCATION CONTENTS MNEMONIC COMMENTS
8000 16 00 MVI D, 00H Initialize register D
to 00H
8002 3E 00 MVI A, 00H Initialize register A
to 00H
8004 21 00 81 LXI H, 8100 HL points 8100H
memory location
8007 46 MOV B, M Move data
8008 23 INX H Increment HL pair
8009 4E MOV C, M Move data
800A 80 LOOP: ADD B Add content
800B 2F 0F 80 JNC NEXT Jump control
800E 3C INR D Increment D Reg
800F 0C NEXT: DCR C Decrement C Reg
8010 D2 0A 80 JNZ LOOP Jump control
8013 23 INX H Increment HL pair
8014 77 MOV M, A Move content
8015 23 INX H Increment HL pair
8016 72 MOV M, D Move content
8017 EF RST 5 Return control to the
monitor
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
13
PERFORM ALL PROGRAMS AND PREPARE THE LAB REPORT INCLUDING OBJECTIVE,
ALGORITHMS, PROGRAMS, OBSERVATION AND RESULT OR COMCLUSION
LAB 6
6.1 DIVISION OF TWO 8 BIT NUMBERS
AIM: To perform the division of two 8 bit numbers using 8085 Kit (MPS 85-3) and also run
the program in 8085 Simulator.
ALGORITHM:
Start the program by loading the 00H data into Accumulator.
Get the first data to a register (Say B Register).
Get the second data to a register (Say C Register) act as a counter loop.
Add the first data with accumulator content.
Check the carry.
If carry is present, increment the value of carry.
Decrement the value of second data. (C Register)
Check the zero flag.
If zero flag is reset, then repeat addition step else store the value of product and carry
in memory location.
Terminate the program.
LOCATION CONTENTS MNEMONIC COMMENTS
8000 16 00 MVI D, 00H Initialize register D
to 00H
8002 3E 00 MVI A, 00H Initialize register A
to 00H
8004 21 00 81 LXI H, 8100 HL points 8100H
memory location
8007 46 MOV B, M Move data
8008 23 INX H Increment HL pair
8009 4E MOV C, M Move data
800A 80 LOOP: ADD B Add content
800B 2F 0F 80 JNC NEXT Jump control
800E 3C INR D Increment D Reg
800F 0C NEXT: DCR C Decrement C Reg
8010 D2 0A 80 JNZ LOOP Jump control
8013 23 INX H Increment HL pair
8014 77 MOV M, A Move content
8015 23 INX H Increment HL pair
8016 72 MOV M, D Move content
8017 EF RST 5 Return control to the
monitor
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
14
PERFORM ALL PROGRAMS AND PREPARE THE LAB REPORT INCLUDING OBJECTIVE,
ALGORITHMS, PROGRAMS, OBSERVATION AND RESULT OR COMCLUSION
LAB 7
7.1 LARGEST NUMBER IN AN ARRAY OF DATA
AIM: To find the largest number in an array of data using 8085 instruction set
ALGORITHM:
Load the address of the first element of the array in HL pair.
Move the count to a register (Say B Register).
Increment the HL pair pointer
Get the first data in a register (Say A Register)
Decrement the count.
BACK: Increment the HL pair pointer
Compare the content of memory addressed by HL pair with that of A reg.
If carry is reset, go to step: NEXT or if carry is set, proceed sequentially.
Move the content of memory addressed by HL to A reg.
NEXT: Decrement the count.
Check for Zero of the count. If ZF is reset, go to step: BACK, else proceed
sequentially.
Store the largest data in memory.
Terminate the program.
MICROPROCESSOR LAB MANUAL July 20, 2017
S. PAUDEL. MSc | LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY (BSC CSIT)
15
PERFORM ALL PROGRAMS AND PREPARE THE LAB REPORT INCLUDING OBJECTIVE,
ALGORITHMS, PROGRAMS, OBSERVATION AND RESULT OR COMCLUSION
LAB 8
8.1 SMALLEST NUMBER IN AN ARRAY OF DATA
AIM: To find the smallest number in an array of data using 8085 instruction set
ALGORITHM:
Load the address of the first element of the array in HL pair.
Move the count to a register (Say B Register).
Increment the HL pair pointer
Get the first data in a register (Say A Register)
Decrement the count.
BACK: Increment the HL pair pointer
Compare the content of memory addressed by HL pair with that of A reg.
If carry is set, go to step: NEXT or if carry is reset, proceed sequentially.
Move the content of memory addressed by HL to A reg.
NEXT: Decrement the count.
Check for Zero of the count. If ZF is reset, go to step: BACK, else proceed
sequentially.
Store the smallest data in memory.
Terminate the program.
top related