You are on page 1of 49

3.

8-BIT MULTIPLICATION AND DIVISION

AIM:

To write an assembly language program to


(i) Multiply two 8-bit numbers
(ii) Divide two 8-bit numbers

APPARATUS REQUIRED:

8085 Kit and Power supply

ALGORITHM:

8-BIT MULTIPLICATION:

1. Initialize a register for carry.


2. Get the two input data (multiplier and multiplicand) from memory locations.
3. Clear accumulator for repeated addition and have multiplier as count.
4. Add multiplicand with accumulator content.
5. Check for carry. If carry =1, goto next step, else goto step 7.
6. Increment the carry register.
7. Decrement the count.
8. Check for count. If count=0, goto next step, else goto step 4.
9. Store the result and carry in memory locations.
10. Stop program execution.

PROGRAM:

Address Opcode Label Mnemonics Comments


4101 MVI C,00 Move immediate 00 to C register
4102
4103 LDA 4500 Load accumulator with the content of
4104 Address 4500
4105
4106 MOV B,A Move the content of B-register to
Accumulator
4107 LDA 4501 Load accumulator with the content of
4108 Address 4501
4109
410A MOV D,A Move the content of D-register to
Accumulator
410B XRA A X-OR the content of accumulator
410C L2 ADD B Add the content of B register to
accumulator content
410D JNC L1 Jump if no carry to label location L1
410E
410F
4110 INR C Increment C register
4111 L1 DCR D Decrenent D register
4112 JNZ L2 Jump on no zero to label location L2
4113
4114
4115 STA 4503 Store accumulator content to address
4503
4116
4117
4118 MOV A,C Move the content of C-register to
Accumulator
4119 STA 4504 Store accumulator content to address
4504
411A
411B
411C HLT Halt the program execution

ALGORITHM:

8-BIT DIVISION:

1. Initialize a register for quotient.


2. Get the two input data (divisor and dividend) from memory locations.
3. Compare divisor and dividend.
4. Check for carry, if set goto step 8, else to next step.
5. Subtract divisor from dividend.
6. Increment the quotient register.
7. Go to step 3.
8. Store the remainder and quotient in memory locations.
9. Stop program execution.

PROGRAM:

Address Opcode Label Mnemonics Comments


4101 MVI C,00 Move immediate 00 to C register
4102
4103 LDA 4500 Load accumulator with the content of
4104 Address 4500
4105
4106 MOV B,A Move the content of B-register to
Accumulator
4107 LDA 4501 Load accumulator with the content of
4108 Address 4501
4109
410A L2 CMP B Compare B register content to
accumulator content
410B JC L1 Jump on carry to label location L2
410C
410D
410E SUB B Subtract the content of B register from
accumulator content
410F INR C Increment C register
4110 JMP L2 Jump to label location L2
4111
4112
4113 L1 STA 4503 Store accumulator content to address
4503
4114
4115
4116 MOV A,C Move the content of C-register to
Accumulator
4117 STA 4504 Store accumulator content to address
4504
4118
4119
411A HLT Halt the program execution

PROCEDURE:

1. Key in the opcodes.


2. Give the input data at specified memory locations.
3. Execute the program.
4. Check the results at specified output locations.

OBSERVATION :

8-bit Multiplication Address Data


Input 4500 08
4501 03
Output 4503 18 (Product LSB)
4504 00 (Carry MSB)

8-bit Division Address Data


Input 4500 08
4501 03
Output 4503 02 (Remainder)
4504 02 (Quotient)
Result:

Thus the assembly language programs for 8-bit multiplication and division are
written, executed and the results are verified.
FLOW CHART

START

LOAD MULTIPLICANT AND MULTIPLIER


TO ACT AS A COUNTER DATA IN A REG

LOAD A REG WITH 2ND DATA AND MOVE IT TO C REG

CLEAR D FOR CARRY A FOR ADDITION

ADD MULTIPLICANT REG WITH ACCUMULATOR

no
IF CY =0

yes

INCREMENT D REG

DECREMENT C REG

yes
IF NO ZERO

no

DECIMAL ADJUST THE CONTENTS OF ACCUMULATOR AND STORE PRODUCT IN MEMORY

STOP
FLOW CHART

START

LOAD DENOMINATOR VALUE IN B REG

LOAD NUMERATOR VALUE IN A REG

CLEAR C REG

S UBTRACT THE VALUE OF B FROM A

INCREMENT THE QUOTIENT VALUE

COMPARE B REG WITH ACCUMULATOR

no
IF CY =1

yes

STORE QUOTIENT AND REMINDER IN MEMORY

STOP
2.16-BIT ADDITION AND SUBTRACTION

AIM:

To write an assembly language program to


(i) Add two 16-bit numbers
(ii) Subtract two 16-bit numbers

APPARATUS REQUIRED:

8085 Kit and Power supply

16-BIT ADDITION:

ALGORITHM:

1. Clear a register for carry.


2. Get the LSBs of two 16-bit data.
3. Add the LSBs and Store the result in memory location.
4. Get the MSBs of two 16-bit data.
5. Add the MSBs with carry of LSBs.
6. Check for carry. If carry =1, goto next step, else goto step 7.
7. Increment the carry register
8. Store the result (MSBs sum) and carry in memory locations.
9. Stop program execution.

PROGRAM:

Address Opcode Label Mnemonics Comments


4101 MVI C,00 Move immediate 00 to C register
4102
4103 LHLD 4500 Load HL registers with the contents of
Address 4500, 4501
4104
4105
4106 MOV B,L Move the content of L-register to B
register
4107 LHLD 4502 Load HL registers with the contents of
Address 4502, 4503
4108
4109
410A MOV A,L Move the content of L-register to
Accumulator.
410B ADD B Add B register content to accumulator
content
410C STA 4600 Store accumulator content to address
4600
410D
410E
410F MOV A,H Move the content of H-register to
Accumulator
4110 ADC D Add with carry, D register content to
accumulator content
4111 JNC L1 Jump on no carry to label location L2
4112
4113
4114 INR C Increment C register
4115 L1 STA 4601 Store accumulator content to address
4601
4116
4117
4118 MOV A,C Move the content of C-register to
Accumulator
4119 STA 4602 Store accumulator content to address
4602
411A
411B
411C HLT Halt the program execution

16-BIT SUBTRACTION:

ALGORITHM:

1. Clear a register for carry.


2. Get the LSBs of two 16-bit data.
3. Subtract the LSBs and Store the result in memory location.
4. Get the MSBs of two 16-bit data.
5. Subtract the MSBs with borrow.
6. Check for carry (borrow). If carry =1, goto next step, else goto step 7.
7. Increment the carry register
8. Store the result (MSBs difference) and carry in memory locations.
9. Stop program execution.
PROGRAM:

Address Opcode Label Mnemonics Comments


4101 MVI C,00 Move immediate 00 to C register
4102
4103 LHLD 4500 Load HL registers with the contents of
4104 Address 4500, 4501
4105
4106 MOV B,L Move the content of L-register to B
register
4107 MOV D,H Move the content of H-register to D
register.
4108 LHLD 4502 Load HL registers with the contents of
4109 Address 4502, 4503
410A
410B MOV A,L Move the content of L-register to
Accumulator
410C SUB B Subtract B register content from
accumulator content
410D STA 4600 Store accumulator content to address
4600
410E
410F
4110 MOV A,H Move the content of H-register to
Accumulator
4111 SBB D Subtract with borrow,D register content
from accumulator content
4112 JNC L1 Jump on no carry to label location L2
4113
4114
4115 INR C Increment C register
4116 L1 STA 4601 Store accumulator content to address
4601
4117
4118
4119 MOV A,C Move the content of C-register to
Accumulator
411A STA 4602 Store accumulator content to address
4602
411B
411C
411D HLT Halt the program execution
PROCEDURE:

1. Key in the opcodes.


2. Give the input data at specified memory locations.
3. Execute the program.
4. Check the results at specified output locations.

OBSERVATION :

16-bit Addition Address Data


Input 4500 08
4501 03
4502 04
4503 07
Output 4600 0C ( LSB Sum)
4601 0A ( MSB Sum)
4602 00 ( Carry)

16-bit Subtraction Address Data


Input 4500 08
4501 0A
4502 09
4504 0B
Output 4600 01
4601 01
4602 00

RESULT:
Thus the assembly language programs for 16-bit addition and subtraction are
written, executed and the results are verified.
4. 16-BIT MULTIPLICATION AND DIVISION

AIM:

To write an assembly language program


(i) to multiply two 16-bit numbers and
(ii) to divide two 16-bit numbers

APPARATUS REQUIRED:

8085 Kit and Power supply

ALGORITHM:

16-BIT MULTIPLICATION:

1. Initialize a register pair for carry.


2. Get the two 16-bit input data (multiplier and multiplicand) directly in register
pairs.
3. Clear HL register pair for repeated addition and have multiplier as count.
4. Add multiplicand with HL register pair content.
5. Check for carry. If carry =1, goto next step, else goto step 7.
6. Increment the carry register.
7. Decrement the 16-bit count (Multiplier).
8. Check for count. If count=0, goto next step, else goto step 4.
9. Store the result and carry in memory locations.
10. Stop program execution.

PROGRAM:

Address Opcode Label Mnemonics Comments


4101 LXI B,0000 Load immediate 0000 to BC register pair
4102
4103
4104 LHLD 4500 Load HL registers with the contents of
Address 4500, 4501
4105
4106
4107 SPHL Move the content of HL-registers to
stack pointer register.
4108 LHLD 4502 Load HL registers with the contents of
Address 4502, 4503
4109
410A
410B XCHG Exchange the contents of HL and DE
register pairs
410C LXI H,0000 Load immediate 0000 to HL register pair
410D
410E
410F L2 DAD SP Add the content of stack pointer register
to HL register pair
4110 JNC L1 Jump on no carry to label location L1
4111
4112
4113 INX B Increment BC register pair
4114 L1 DCX D Decrement DE register pair
4115 MOV A,E Move the content of E-register to
Accumulator
4116 ORA D Logigally OR the content of D register to
accumulator
4117 JNZ L2 Jump on no zero to label location L2
4118
4119
411A SHLD 4600 Store the contents of HL registers to
address 4600,4601
411B
411C
411D MOV L,C Move the content of C-register to L
register
411E MOV H,B Move the content of B-register to H
register
411F SHLD 4602 Store the contents of HL registers to
address 4602,4603
4120
4121
4122 HLT Halt the program execution

16-BIT DIVISION:

ALGORITHM:

1. Initialize a register pair for quotient.


2. Get the two 16-bit data (in HL pair and in a register pair).
3. Save HL pair’s content to stack.
4. Subtract the LSBs and Store the result in L-register.
5. Subtract the MSBs with borrow.
6. Check for carry (borrow). If carry =1, goto step 9, else goto next step.
7. Increment the register pair for quotient.
8. Store the result of subtraction in H-register. Goto step 3.
9. Store the Stack register content (Remainder) and quotient in memory
locations.
10. Stop program execution

PROGRAM:

Address Opcode Label Mnemonics Comments


4101 LXI D,0000 Load immediate 0000 to DE register pair
4102
4103
4104 LHLD 4500 Load HL registers with the contents of
Address 4500, 4501
4105
4106
4107 LXI B, 16- Load immediate 16-bit data to BC
bit data register pair
4108
4109
410A SPHL Move the content of HL-registers to
stack pointer register.
410B MOV A.L
410C SUB C Load immediate 0000 to HL register pair
410D MOV L,A Move the content of L-register to B
register
410E MOV A,H
410F L2 SBB B Add the content of stack pointer register
to HL register pair
4110 JC L1 Jump on no carry to label location L1
4111
4112
4113 INX D Increment BC register pair
4114 L1 MOV H,A Decrement DE register pair
4115 JMP L2 Move the content of E-register to
Accumulator
4116 Logigally OR the content of D register to
accumulator
4117 Jump on no zero to label location L2
4118 LXI H,0000
4119
411A Store the contents of HL registers to
address 4600,4601
411B DAD SP
411C SHLD 4600 Store the contents of HL registers to
address 4600,4601
411D
411E Move the content of B-register to H
register
411F XCHG Exchange the contents of HL and DE
register pairs
4120 SHLD 4602 Store the contents of HL registers to
address 4602,4603
4121
4122
4123 HLT Halt the program execution

PROCEDURE:

1. Key in the opcodes.


2. Give the input data at specified memory locations.
3. Execute the program.
4. Check the results at specified output locations.

OBSERVATION :

16-bit Multiplication Address Data


Input 4500 24(LSB1)
4501 5A(MSB1)
4502 C2(LSB2)
4503 47(MSB2)
Output 4600 48(LSB Product)
4601 4B(LSB Product)
4602 44(MSB Product)
4603 19(MSB Product)

RESULT:
Thus the assembly language program for 16-bit multiplication is written, executed
and the results are verified.
5. (A) ARITHMETIC OPERATIONS USING BCD NUMBERS

AIM:

To write an assembly language program to


(i) Add and subtract two numbers of 2 digit (8-bit) BCD data.
(ii) Perform bit manipulation using logical instructions

APPARATUS REQUIRED:

8085 Kit and Power supply

BCD ADDITION:

ALGORITHM:

1. Initialize a register for carry.


2. Get the two input data.(One data in accumulator and another in register)
3. Add the two data.
4. Restore the result in BCD.
5. Check for carry. If carry =1, goto next step, else goto step 7.
6. Increment the carry register.
7. Store the result and carry in memory locations.
8. Stop program execution.

PROGRAM:

Address Opcode Label Mnemonics Comments


4101 MVI C,00 Move immediate 00 to C register
4102
4103 LDA 4500 Load Accumulator with the content of
Address 4500
4104
4105
4106 MOV B,A Move the content of accumulator to B
register
4107 LDA 4501 Load Accumulator with the content of
Address 4501
4108
4109
410A ADD B Add B register content to accumulator
content
410B DAA Decimal Adjust Accumulator
410C JNC L1 Jump on no carry to label location L1
410D
410E
410F INR C Increment C register
4110 L1 STA 4601 Store accumulator content to address
4601
4111
4112
4113 MOV A,C Move the content of C-register to
Accumulator
4114 STA 4602 Store accumulator content to address
4602
4115
4116
4117 HLT Halt the program execution

BCD SUBTRACTION:

ALGORITHM:

1. Get the two input data.(Minuend in accumulator and Subtrahend in one


register)
2. Take the 10’s complement of Subtrahend.
3. Add the two data.
4. Restore the result in BCD.
5. Store the result memory.
6. Stop program execution.

PROGRAM:

Address Opcode Label Mnemonics Comments


4101 LDA 4500 Load Accumulator with the content of
Address 4500
4102
4103
4104 MOV B,A Move the content of accumulator to B
register
4105 MVI A,99 Move immediate 00 to A register
4106
4107 SUB B Subtract the content of B-register from
Accumulator content
4108 INR A Increment A register content
4109 MOV B,A Move the content of accumulator to B
registe
410A LDA 4501 Load Accumulator with the content of
Address 4501
410B
410C
410D ADD B Add B register content to accumulator
content
410E DAA Decimal Adjust Accumulator
410F STA 4601 Store accumulator content to address
4601
4110
4111
4112 HLT Halt the program execution

BIT MANIPULATION: (CONVERTING BCD DATA TO BINARY NUMBER)

ALGORITHM:

1. Get the BCD data in one register.


2. Mask the Units number (lower nibble) and get the ten’s number in a register.
3. Clear accumulator.
4. Load the count 10 in a register.
5. Add the Ten’s number to accumulator.
6. Decrement count.
7. Check for zero. if count=0, goto next step else goto step 5.
8. Save the product in a register.
9. Mask the ten’s number (upper nibble) of BCD data.
10. Add the units number in the above step to the product in step 8.
11. Store the binary value.
12. Stop program execution.

PROGRAM:

Address Opcode Label Mnemonics Comments


4101 LDA 4500 Load accumulator with the content of
Address 4500
4102
4103
4104 MOV E,A Move the content of Accumulator to E
register
4105 ANI F0 AND immediate F0, with the content of
accumulator
4106
4107 RLC Rotate accumulator left to carry
4108 RLC Rotate accumulator left to carry
4109 RLC Rotate accumulator left to carry
410A RLC Rotate accumulator left to carry
410B MOV B,A Move the content of Accumulator to B
register
410C XRA A X-OR the content of accumulator
410D MVI C,0A Move immediate 0A to C register
410E
410F L1 ADD B Add the content of B register to
accumulator content
4110 DCR C Decrement C register
4111 JNZ L1 Jump on no zero to label location L1
4112
4113
4114 MOV B,A Move the content of Accumulator to B
register
4115 MOV A,E Move the content of E register to
Accumulator
4116 ANI 0F AND immediate 0F, with the content of
accumulator
4117 ADD B Add the content of B register to
accumulator content
4118 STA 4501 Store accumulator content to address
4501
4119
411A
411B HLT Halt the program execution

PROCEDURE:

1. Key in the opcodes.


2. Give the input data at specified memory locations.
3. Execute the program.
4. Check the results at specified output locations.
OBSERVATION :

BCD Addition Address Data


Input 4500 24
4501 55
Output 4601 79
4602 00

BCD Subtraction Address Data


Input 4500 24
4501 55
Output 4601 31

Bit Manipulation(BCD to Address Data


Binary Conversion)
Input 4500 45(BCD)
Output 4501 2D(Binary)

RESULT:
Thus the assembly language programs for BCD Addition, BCD Subtraction and
Bit manipulation (BCD to Binary conversion) are written, executed and the results are
verified.
6.CODE CONVERSION

AIM:

To write an assembly language program to


(i) Convert 8-bit Binary data to ASCII code
(ii) Convert ASCII code to Binary number

APPARATUS REQUIRED:

8085 Kit and Power supply

BINARY TO ASCII:

ALGORITHM:

1. Get the data in a register.


2. Mask the upper nibble of binary (Hex) data.
3. Call subroutine CODE to get ASCII code of the lower nibble and store in a
memory.
4. Mask the lower nibble of binary(Hex) input data.
5. Rotate upper nibble to lower nibble position.
6. Call subroutine CODE to get ASCII code of the upper nibble and store in a
memory.
7. Stop.

ALGORITHM FOR SUBROUTINE “CODE”:

1. Compare the nibble in Accumulator with 0A(Hex).


2. If Carry=1, goto step 4, else goto next step.
3. Add 07(Hex) to the nibble in Accumulator.
4. Add 30(Hex) to the nibble in Accumulator.
5. Return to main program.

PROGRAM:

Address Opcode Label Mnemonics Comments


4101 LDA 4200 Load accumulator with the content of
Address 4200
4102
4103
4104 MOV B,A Move the content of Accumulator to B
register
4105 ANI 0F AND immediate 0F, with the content of
accumulator
4106
CALL Code Call the Subroutine labeled “Code”

STA 4201 Store accumulator content to address


4201

MOV A,B Move the content of B register to


accumulator
ANI F0 AND immediate F0, with the content of
accumulator

4107 RLC Rotate accumulator left to carry


4108 RLC Rotate accumulator left to carry
4109 RLC Rotate accumulator left to carry
410A RLC Rotate accumulator left to carry
410B CALL Code Call the Subroutine labeled “Code”
410C
410D
410E STA 4202 Store accumulator content to address
4202
410F
4110
4111 HLT Halt the program execution

4112
4113 Code: CPI 0A Compare immediate 0a with the content
of accumulator
4114
4115 JC L1 Jump on carry to label location L1
4116 ADI 07 ADD immediate 07, with the content of
accumulator
4117
4118 L1 ADI 30 ADD immediate 30, with the content of
accumulator
4119
411A RET Return to main program
OBSERVATION :

Binary(HEX) to ASCII Address Data


Input 4200 E4(HEX)
Output 4201 34(ASCII Code for 4)
4202 45(ASCII code for E)
Result:

Thus the assembly language programs for the code conversion (Binary to ASCII
and ASCII to Binary) are written, executed and the results are verified.

VIVA QUESTIONS:

1. What is the difference between RLC and RAL?


2. What are machine control instructions?
3. How many machine cycles are required for STA 4500?
4. What is T-State?
5. What are I/O related instructions?
10.INTERFACING KEYBOARD/DISPLAY CONTROLLER TO 8085

AIM:
To interface Keyboard/Display controller(8279) with 8085 processor and to
display a particular string.

ALGORITHM: (To display the string “HELLO”)

1. Form the look up table.


2. Move the control word to accumulator and out it through control register.
3. Get the letters one by one from memory and out it.
4. Check whether all letters are displayed. If not, display next character.
5. Stop of program.

PROGRAM:

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


4500 21 LXI H, 4600 Load immediate HL register
pair with 4600
4501 00
4502 46
4503 3E MVI A, 10 Move immediate 10 to
accumulator
4504 90
4505 D3 OUT 01 Out it through CR
4506 01
4507 7E L1 MOV A,M Move memory content to
accumulator
4508 D3 OUT 00 Out it through 8279 port
4509 00
450A 23 INX H Increment HL register pair
450B 7D MOV A,L Move the content of L
register to accumulator
450C FE CPI 06 Compare immediate with 06
450D 06
450E C2 JNZ L1 Jump on no zero to label
location L1
450F 07
4510 81
4511 76 HLT Halt the process
PROCEDURE:

1. Key in the opcodes.


2. Give the input data from look up table at the specified memory locations.
3. Execute the program and verify the character display.

RESULT:
The Keyboard/Display controller is interfaced with 8085 and the character display
is verified.

FLOWCHART FOR KEYBOARD DISPLAY INTERFACING:


8. STRING MANIPULATION

AIM:To Write A Program to move a block of data from one location to another location
using processor 8085,To add an array of numbers

APPARATUS REQUIRED:

8085 Kit and Power supply

PROGRAM:

Moving a block of data from one location to another:

LXI H, add1
LXI B, add2
MVI D, count
Loop1: MOV A,M
STAX B
INX H
INX B
DCR D
JNZ Loop1
HLT

Adding an array of data:

LXI H, add
MVI D,00
MOV C,M
INX H
MOV A,M
Loop1: INX H
MOV B,M
ADD B
JNC Loop
INR D
Loop : DCR C
JNZ Loop1
STA add1
MOV A,D
STA add2
HLT

OBSERVATION :

MOVING A BLOCK
Binary(HEX) to ASCII Address Data
Input 4200 02
4201 08
4202 09
Output 4500 02
4501 08
4502 09

ADDING AN ARRAY
Address Data
Input 4200 02
4201 08
4202 03
Output 4500 OD

RESULT:

Thus the assembly language programs for moving an array of data and adding an
array of data are written, executed and the results are verified.
9 PROGRAMS FOR SORTING/ SEARCHING (USING 8085,8086)

AIM:To Write A Program to sort the given numbers using 8085 and 8086

APPARATUS REQUIRED:
8085 Kit and Power supply

PROGRAM:
i) Sorting of an array of 8-bit numbers using 8085

LXI H,add1
MOV B,M
MOV C,B
Loop3: LXI H,add1
MOV D,B
Loop2: MOV A,M
INX H
MOV B,M
CMP B
JC / JNC Loop1
MOV M,A
DCX H
MOV M,B
INX H
Loop1: DCR D
JNZ Loop2
DCR C
JNZ LooP3
HLT
ii) Searching a number in an array of data using 8085

MVI D,00
LXI H, add
MOV C,M
INX H
MOV B,M
Loop2: INX H
MOV A,M
CMP B
JNZ Loop1
INR D
Loop1: DCR C
JNZ Loop2
MOV A,D
STA add
HLT

iii) Sorting an array of 8-bit numbers using 8086

MOV SI, add


MOV BL, [SI]
MOV DL,BL
Loop3: MOV SI,add2
MOV DH, BL
Loop2: MOV AL,[SI]
INC SI
MOV BH,[SI]
CMP AL,BH
JC/JNC Loop1
MOV [SI],AL
DEC SI
MOV [SI],BH
INC SI
Loop1: DEC DH
JNZ Loop2
DEC DL
JNZ Loop3
HLT

iv) Sorting an array of 16-bit number using 8086

MOV SI, add


MOV BL, [SI]
MOV DL,BL
Loop3: MOV SI,add2
MOV DH, BL
Loop2: MOV AX,[SI]
INC SI
INC SI
MOV CX,[SI]
CMP AX,BX
JC/JNC Loop1
MOV [SI],AX
DEC SI
DEC SI
MOV [SI],CX
INC SI
INC SI
Loop1: DEC DH
JNZ Loop2
DEC DL
JNZ Loop3
HLT

OBSERVATION:
SORTING:
Address Data
Input 4200 02
4201 08
4202 03
4203 09
Output 4500 02
4501 03
4502 08
4503 09

SEARCHING:TO SEARCH 02
Address Data
Input 4200 02
4201 08
4202 03
4203 09
Output 4500 02

RESULT:
Thus the assembly language programs for sorting and searching in an array of data
are written, executed and the results are verified
13.INTERFACING & PROGRAMMING 8259

Interfacing 8259 with 8085 microprocessor


AIM:To interface 8259 with microprocessor
ALGORITHM:
Initialize 8259 with the following specifications:
ICW4 needed, single 8259, Interval of ------(8085), Edge triggered mode, Vector
address(8085)/ Type number(8086) of IR0 ------, ------- mode, Normal EOI, Non-
buffered mode, Not special fully nested mode, Mask all interrupts except ---------.

A0 – Address with A0 = 0
A1 – Address with A0 = 1
1.Initialize 8259 for the given specification
2.Send ICW1 to A0
3.Send ICW2 to A1
4.Send ICW4 T0 A1
5.Send OCW1 to A1
6.Send OCW2 To A0

Using 8085:

MVI A, ICW1
OUT A0
MVI A,ICW2
OUT A1
MVI A,ICW4
OUT A1
MVI A,OCW1
OUT A1
HLT
ISR: MVI A,OCW2 ; Non-specific EOI command
OUT A0
HLT

RESULT:Thus 8259 is interfaced with 8085


MODE 2:
KIT 1:
MVI A,C0 ;Control word to set PA in mode2
OUT CR
LOOP: IN PC ; Check the status of OBF
ANI 90
JZ LOOP
MVI A, DATA ; Transfer data
OUT PA
LOOP1: IN PC ; Check the status of IBF
ANI 20
JZ LOOP1
IN PA ; Get data
STA ADD
HLT

KIT2:
MVI A, C0 ; Control word to set PA in mode2
OUT CR
LOOP: IN PC ; check the status of IBF
ANI 20
JZ LOOP
IN PA ; get data
STA ADD
LOOP1: IN PC ; Control word to set PA in mode2
ANI 90
JZ LOOP1
MVI A, DATA ; Transfer data
OUT PA
HLT
11. REVERSING AN ARRAY OF DATA

AIM:

To write an assembly language program to perform reversing


an array of elements.

APPRATUS REQUIRED:
8085 KIT

ALGORITHM:

1. Load the HL register pair with some data in 4200


2. Load the BC register pair in 4300
3. Move immediately the data 05H to the register D.
4. Move the C-register value to the accumulator.
5. Add the content of the accumulator with D-register.
6. Move the accumulator content to the C-register.
7. Decrement the content of the BE-register pair.
8. Move the content of M to the accumulator.
9. Store the content of the BC-register pair.
10. Increment the content of the HL-register pair.
11. Decrement the content of the BC-register pair.
12. Decrement the content of D-register.
13. If no zero jump to the loop.
14. Stop the process.

PROGRAM:

Reversing An Array Of Elements:

ADDRESS HEXCODE LABEL MNEMONICS OPERAND COMMENTS


4100 21,00,42 LXI H,4200 Load the HL pair with
some data in 4200
4103 D1,00,43 LXI B,4300 Load the BC pair in
4300
4106 16,05 MVI D,05 Move immediately the
data 05H to D register
4108 79 MOV A,C Move the C-register
value to the A
4109 82 ADD D Add the content of D
with Accumulator
410A 4F MOV C,A Move the accumulator
content to the C-register
410B 0B DCX B Decrement the content
of the BE-register pair
410C 7E Loop MOV A,M Move the content of M
to the accumulator
410D 02 STAX B Store the content of the
BC-register pair
410E 23 INX H Increment the content
of the HL-register pair
410F 0B DCX B Decrement the content
of the BC-register pair.
4110 15 DCR D Decrement the content
of D-register.
4111 62,0C,41 JNC Loop If no carry jump to the
loop.
4114 76 HLT Stop the process.

PROCEDURE::

1. Key in opcode from the specified location.


2. Enter the data into the memory and execute the program.
3. Check for the result and stop the program.

RESULT:
Thus reversing an array of element is executed successfully and the output is
verified.

CONTENT ADDRESS FIELD DATA FIELD


INPUT FIELD 4200 01H
4201 02H
4202 03H
4203 04H
4204 05H

OUTPUT FIELD 4300 05H


4301 04H
4302 03H
4303 02H
4304 01H
FLOWCHART

Start

Load the HL,BC register address 4200&4300

Move the data 05H to the D-Register

Move the contents of C to accumulator

Add the content of D-register with A

Move the contents of A to the C-register

Decrement BE-register pair

Move the content of M to the accumulator

Store in BC-register pair

Increment the content of the HL-register pair

Decrement the BC-register pair and D reg

NO
If
CY=1

YES
Stop
FLOWCHART FOR REVERSING AN ARRAY OF ELEMENTS
1.ADDITION OF TWO 8 BIT NUMBERS

AIM:
To write a program for adding the given two 8- bit number and store the result
in the memory .

APPARATUS REQUIRED:
Microprocessor :Intel 8085
Operating Frequency :3.012MHz
User RAM Area :4100-5FFF

ALGORITHM:

1. Load the accumulator by data in the address 4200H


2. Move the contents of the accumulator to B Register
3. Load the accumulator by data in the address 4201H
4. Clear C Register
5. Add the content of the accumulator to B Register content
6. If no carry jump to loop
7. Increment C Register
8. Shift the content of the accumulator to the location 4203
9. Move the contents of the C Register to accumulator.
10. Shift the content of the accumulator to the location 4204
11. Halt the current Program
HEX LABEL
ADDRESS OPERAND COMMENTS
CODE MNEMONICS
4100 3A,00,42 LDA 4200 Load the accumulator with
data in 4200
4103 47 MOV B,A Move the contents of the
accumulator to B Register
4104 3A,01,42 LDA 4201 Load the accumulator with
data in 4201
4107 0E,00 MVI C,00 Clear C Register

4109 80 ADD B Add the content of the B


Register to accumulator.
410A D2,0E,41 JNC loop
If no carry jump to loop
410D 0C INR C Increment C Register

410E 32,02,42 STA 4202 Shift the content of the


Loop accumulator to the location
4202
4111 79 MOV A,C Move the contents of the C
Register to the accumulator.

4112 32,03,42 STA 4203 Shift the content of the


accumulator to the location
4203
4115 76 HLT Stop the current Program
PROGRAM:

PROCEDURE:
1. Key in opcode from the address specified
2. Enter data to 4200, 4201.
3. Execute the program and check the result at 4202 and 4203.

RESULT:
Thus the 8-bit addition with carry is performed.
CONTENT ADDRESS FIELD DATA FIELD

INPUT FIELD 4200 04H


4201 09H

OUTPUT FIELD
4202 0DH
4203 00H
11.INTERFACING STEPPER MOTOR WITH 8086 USING 8255

AIM:
To write an assembly language program to interface stepper motor with 8086.
APPARATUS REQUIRED:
8086 microprocessor kit
Key board
Stepper motor
Stepper motor Interface Board

THEORY:
A motor in which the rotor is able to assume only discrete stationary angular
position is a stepper motor. The basic two-phase motor has two pairs of stator poles
with its own windings. The excitation of any one winding generates a north and South
Pole gets induced at the diametrically opposite sides.

The stator frame is continuous and magnetic field passes through the cylindrical
annular ring. The rotor magnetic system has two end faces. The left face is
magnetized permanently as south pole and right face as north pole. North pole
structure is twisted with respect to south pole structure such that south pole comes in
between two north poles.Step angle is the minimum degree of rotation associated
with single step. Revolution is the number of steps needed to complete one rotation or
360 degree.

STEP SEQUENCE – 2 PHASE SCHEME

Anti Clockwise Rotation Clockwise Rotation


Step A1 A2 B1 B2 Value A1 A2 B1 B2 Value

1. 1 0 0 1 09 1 0 1 0 0A

2. 0 1 0 1 05 0 1 1 0 06

3. 0 1 1 0 06 0 1 0 1 05

4. 1 0 1 0 0A 1 0 0 1 09
ALGORITHM:
1. Load the stepping sequence in DI register
2. Move the count value to CL register.
3. Move the contents of destination index to AL.
4. Output the loaded values between delay
5. Decrement the contents of DX register
6. If no zero jump to the L1
7. Increment destination index register.
8. Loop to loop1.
9. Move the delay value to BX register.
10. Decrement the contents of BX register
11. If no zero jump to L2.
12. Jump to beginning address
13. Stop the program.
14. Load the look up table values before execution

PROGRAM:
Start: MOV DI,1200
MOV CL,04
Loop1:MOV AL,[DI]
OUT C0,AL
L1: MOV DX,1010
DEC DX
JNZ L1
INC DI
LOOP LOOP1
MOV BX,0FFF
L2: DEC BX
JNZ L2
JMP Start
HLT
PROCEDURE:
1.Key in the code from the address specified
2Enter the count value and enter the look up table value at the specified address
3.Execute the program and check the result.
RESULT:
Thus program to perform stepper motor interface with 8086 was executed and
verified.

FLOWCHART FOR STEPPER MOTOR

START

STORE STEP SEQUENCE IN DI REGISTER


AND SET COUNT VALUE

MOVE VALUES IN LOOK UP TABLE


SEQUENTIALLY TO OUTPUT PORT

CALL DELAY & INCREMENT DI REGISTER

IF
DI>Cou
nt

CALL DELAY

STOP
13.SQUARE WAVE GENERATION USING 8253 INTERFACE WITH 8086

AIM:
To write an assembly language program to generate a square wave using 8253
interfacing with 8086 processor.
APPARATUS REQUIRED:
8086 microprocessor kit
Key board
8253 Interface Board
THEORY:
8253 acts as Timer/Counter. It generates accurate time delays and square
waves. contains three 16 bit independent counters. The device has 6 different
counting modes including square wave generation and monostable operation.
Control word:

0 0 1 1 0 1 1 0
D7 D0
D7:D6 - Counter 0
D5:D4 - LSB first MSB next
D3:D1 - Square wave rate generator
D0 - Binary Code
Divisor Value:
Divisor Value = Clock frequency of Counter0
Desired Frequency
ALGORITHM:
1. Load the Control word
2. Output the value through the port
3. Load the divisor value to count the specific frequency (LSB value)
4. Output the value through the port
5. Load the divisor value to count the specific frequency (MSB value)
6. Output the value through the port
7. Stop the program.

PROGRAM:
MOV AL,36
OUT 16,AL
MOV AL,0A
OUT 10,AL
MOV AL,00
OUT 10,AL
HLT
PROCEDURE:
1. Key in the code from the address specified
2. Load the control word for specific frequency
3. Execute the program and check the result.
RESULT:
Thus the square wave was generated by interfacing 8086 with 8253 and the
program was executed and verified.
14.TRAFFIC CONTROLLER USING 8255 WITH 8085

AIM:
To write an assembly language program to do traffic signal controller and store
result in memory.

APPARATUS REQUIRED:
Microprocessor : INTEL 8085
Operating frequency : 3.102 MHZ
User RAM area : 4100-5FFFH

ALGORITHM:
1. Load the HL-register pair, move the data OC to C-register.
2. Move the pair to A-register, out the counter
3. Increment HL pair, move HL pair to A-register.
4. Out the port A, increment HL pair.
5. Move the HL pair to A-register, out port B, call delay.
6. Increment HL pair, decrement C register.
7. If no jump to loop1, jump to start.
8. Push B, initialize 05 to C-register.
9. Move D-register to accumulator
10. OR the E-register
11. If no jump to loop, decrement C register.
12. If no jump to loop, pop the B-register.
13. Return.

PROGRAM:

ADDRESS HEXCODE LABEL MNEMONICS OPERAND COMMENTS


4100 21,00,45 Start LXI H,4500 Load the HL-register pair
4103 OE,OC MVI C,OC Move data OC to C register
4105 7E MOV A,M Move HL contents to
accumulator
4106 D3,OF OUT CNT Count the value
4108 23 INX H Increment HL pair
4109 7E Loop1 MOV A,M Move the content of M to
A-register
410A D3,OC OUT A Out A port
410C 23 INX H Increment HL register pair
410D 7E MOV A,M Move the content of M to
accumulator
410E D3,OD OUT B Out B port
4110 CD,1B,41 CALL Delay Call the Delay
4113 23 INX H Increment HL pair
4114 OD DCR C Decrement the C register
4115 C2,09,41 JNZ LOOP1 If no zero jump to loop
4118 C3,00,41 JMP Start Jump to Start
411B C5 Delay PUSH B Push B register
411C OE,05 MVI C,05 Move data 05 to C register
411E 11,FF,FF Loop3 LXI D,FF,FF Load the DE-pair
4121 1B Loop2 DCX D Decrement D-register
4122 7A MOV A,D Move D-register to
accumulator
4123 B3 ORA E OR the E-register
4124 C2,21,41 JNZ Loop2 If no zero jump to Loop2
4127 OD DCR C Decrement C-register
4128 C2,1E,41 JNZ Loop3 If no zero jump to Loop3
412B C1 POP B Pop the B-register
412C C9 RET Return

PROCEDURE:
4. Key in opcode from the specified location.
5. Enter the data in 4500 to 4508.

RESULT:
Thus the traffic signal controller is carried out.

CONTENT ADDRESS FIELD DATA FIELD


Input field 4500 80,1A,A1,64,
A4,81,5A,64,54
5.(B)BCD MULTIPLICATION
AIM:
To write a program for multiplying the given two 8-bit BCD number and store
the result in the memory.
APPARATUR REQUIRED:
Microprocessor :Intel 8085
Operating Frequency :3.012MHz
User RAM Area :4100-5FFF
ALGORITHM:
1. Load the accumulator by data in the address 4200H
2. Move the contents of the accumulator to B Register
3. Load the accumulator by data in the address 4201H
4. Move the contents of the accumulator to C Register
5. Clear D Register and Accumulator
6. Add the content of the accumulator to B Register content
7. Adjust for decimal
8. If no carry jump to loop
9. Increment D Register
10. Decrement C Register
11. Jump on no zero to loop1
12. Store the content of the accumulator to the desired location
13. Move the contents of the D Register to accumulator
14. Store the content of the accumulator to the desired location
15. Halt the current Program
PROGRAM:

HEX LABEL
ADDRESS OPERAND COMMENTS
CODE MNEMONICS
4100 3A,00,42 LDA 4200 Load the accumulator with
data in 4200
4103 47 MOV B,A Move the contents of the
accumulator to B Register
4104 3A,01,42 LDA 4201 Load the accumulator with
data in 4201
4107 4F MOV C,A Move the contents of the
accumulator to C Register
4108 AF XRA A Clear A register
4109 16,00 MVI D,00
Clear D register
410B 80 ADD B Add the contents of B
Loop1
register to A
410C 27 DAA Decimal adjust the contents
of accumulator
410D D2,11,41 JNC Loop Jump to given location if
there is no carry
4110 14 INR D Increment the D register
4111 0D Loop DCR C Decrement the C register
4112 C2,0B,41 JNZ Loop1 Jump on no zero to Loop1
4115 32,02,42 STA 4202 Store the content of A to the
location 4202
4118 7A MOV A,D Move the contents of the to
D Register to accumulator
4119 32,03,42 STA 4203 Store the content of A to the
location 4202
411C 76 HLT Stop the current Program
PROCEDURE:
1. Key in opcode from the address specified
2. Enter data to 4200, 4201.
3. Execute the program and check the result at 4202 and 4203.

RESULT:
Thus the 8-bit BCD multiplication is performed.

CONTENT ADDRESS FIELD DATA FIELD

INPUT FIELD 4200 04H


4201 03H

OUTPUT FIELD
4202 12H
4203 00H

You might also like