You are on page 1of 22

MICROPROCESSOR AND INTERFACING LAB MANUAL

INDEX
1. Introduction to 8086 trainer kit

2. Program to initialize the register with immediate data.

3. Program to move the data from memory locations to registers

4. Program to move a block of 100 bytes

5. Program to interchange two words

6. Program to add two words

7. Program to add 4 words stored consecutively in memory locations

8. Program to add 2 32 bits numbers

9. Program for 16 bit subtraction

10. Program for byte multiplication

11. Program for word multiplication

12. Program for 32 bit by 16 bit division

13. Program to add two decimal numbers (two bytes)

14. Program for sum of given ‘n’ numbers

15. Program for average of given ‘n’ numbers

16. Program for sum of squares of ‘n’ numbers

17. Program to compute the logical 1’s in a word

18. Program to find a square root of a given number

19. Program to convert 2 BCD numbers to hex

20. Program to convert hex number to BCD

21. Program to sort given 8 numbers in descending order

22. Program to convert binary to ASCII


MICROPROCESSOR AND INTERFACING LAB MANUAL

PROGRAMMES USING SDA-8086-ME TRAINER

1) This program initializes the register with immediate data. After the
execution of this program the following register contain the data shown
against them.

Address Opcode Label Mnemonics Comments


4000 B8 11 11 Mov AX,1111 Load the content
1111 into AX
4003 BB 22 22 Mov BX,2222 Load the content
2222 into BX
4006 B9 33 33 Mov CX,3333 Load the content
3333 into CX
4009 BA 44 44 Mov DX,4444 Load the content
4444 into DX
400C BE 55 55 Mov SI,5555 Load the content
5555 into SI
400F BF 66 66 Mov DI,6666 Load the content
6666 into DI
4012 cc INT 3 End of the program

Output:- AX = 1111,BX=2222,CX=3333,DX=4444,SI=5555,DI=6666
MICROPROCESSOR AND INTERFACING LAB MANUAL

2) This program moves the data from memory locations to registers.


After the execution of this program the following register contain the
data shown against them.

Address Opcode Label Mnemonics Comments

4000 A1 0041 Mov AX,[4100] Load the content of [4100]


into AX
4003 8B 1E 02 41 Mov BX,[4102] Load the content of [4102]
into BX
4007 8B 0E 04 41 Mov CX,[4104] Load the content of [4104]
into CX
400B 8B 16 06 41 Mov DX,[4106] Load the content of [4106]
into DX
400F 8B 36 08 41 Mov SI,[4108] Load the content of [4108]
into SI
4013 8B 3E 0A 41 MovDI,[410A] Load the content of [410A]
into DI
4017 cc INT 3 End of the program

INPUT:-0:4100 AAAA, 4102 BBBB, 0:4104 CCCC, 4106 DDDD,


4108 5151, 410A D1D1

OUTPUT:- AX=AAAA, BX=BBBB, CX=CCCC, DX=DDDD,


SI=5151, DI=DIDI
MICROPROCESSOR AND INTERFACING LAB MANUAL

3) This Program moves a block of 100 bytes from location 4100-4163 to


4164 onwards

Address Opcode LABEL Mnemonics Comments


4000 FC CLD Set SI,DI on auto increment
mode
4001 BE 00 MOV SI,4100 Move Source pointer to 4100
41
4004 BF 64 MOV DI,4164 Move destination pointer to
41 4164
4007 1E PUSH DS Move is always done with
respect from
4008 07 POP ES DS:SI to ES :DI

4009 B9 64 MOV CX,64 Set counter to 100


00
400C A4 MOVSB Move string byte

400D E2 FD LOOP 400C Loop till all bytes are moved

400F CC INT 3 Ends the program

Input 0:4100-4164 any data


Output 0:4164-41C7 same data as in the location
MICROPROCESSOR AND INTERFACING LAB MANUAL

4) This program interchanges two words from 4100 and 4102 locations

Address Opcode LABEL Mnemonics Comments

4000 BE 00 41 MOV SI,[4100] Move Ptr1 to 4100 location


4003 BF 02 41 MOV DI,[4102] Move Ptr2 to 4102 location
4006 8B 05 MOV AX,[DI] Move DI contents to AX
4008 8B 1C MOV BX,[SI] Move SI contents to BX
400A 93 XCHG AX,BX Exchange AX with BX
400B 89 1C MOV [SI],BX Now store them back
400D 89 05 MOV [DI],AX Move the content
400F CC INT 3 Ends the program

Input: 4100-AA 4101-AA 4102-BB 4103-BB

Output: 4100-BB 4101-BB 4002-AA 4103-AA


MICROPROCESSOR AND INTERFACING LAB MANUAL

5) This program adds two words in memory locations and stores the
results in subsequent memory locations

Address Opcode LABEL Mnemonics Comments


4000 A1 00 41 MOV Ax,[4100] Move contents of 4100 location
to AX
4003 8B 1E 02 41 MOV BX,[4102] Move contents of 4102 location
to BX
4007 01 D8 ADD AX,BX Add these 2 words results in AX

4009 A3 04 41 MOV [4104],AX Save the same in location 4104

400C CC INT 3 Ends the program

Input: 4100 -2222 4102 -3333


Output: 4104 -5555
MICROPROCESSOR AND INTERFACING LAB MANUAL

6) Program to add 4 words stored consecutively in memory locations. The numbers are in
binary
Address Opcode LABEL Mnemonics Comments
4000 B9 04 00 MOV CX,04 Set counter to 4, to add 4
words ptr
4003 BE 00 41 MOV SI,4100 To 4100 location
4006 03 04 L1 ADD AX,[SI] Add first word to AX

4008 46 INC SI Increment ptr. To point


next word
4009 46 INC SI Increment ptr. To point
next word
400A E2 FA LOOP L1 Loop till 4 words are
added up
400C 89 04 MOV [SI],AX Move the results to
location 4106
400E CC INT 3 Ends the program

Input : 4100:11 11 22 22 33 33 44 44
SET AX=0
Output : REG AX=AAAA
MICROPROCESSOR AND INTERFACING LAB MANUAL

7) Program to add 2 32 bits numbers and store the result in


memory

Address Opcode Label Mnemonics Comments


4000 A1 00 41 MOV AX,[4100] The program adds ax : bx to
cx : dx
4003 8B 1E 02 41 MOV BX,[4102] Move contents of 4102 to bx

4007 8B 0E 04 41 MOV CX,[4104] Move contents of 4104 to cx


400B 8B 16 06 41 MOV DX,[4106] Move contents of 4106 to dx
400F 01 C8 ADD AX,CX AX=ax+cx
4011 11 D3 ADC BX,DX Bx= bx +dx +carry
4013 A3 08 41 MOV [4108],AX Store result in 34108,410A
4016 89 1E 0A 41 MOV [410A],BX
401A CC INT 3

Input: 4100 11 11 22 22
4104 33 33 44 44
Output: 4108:- 44 44 66 66
MICROPROCESSOR AND INTERFACING LAB MANUAL

8) Program for 16 bit substraction

Address Opcode LABEL Mnemonics Comments


4000 A1 00 41 MOV Ax,[4100] Move contents of 4100
location to AX
4003 8B 1E 02 MOV BX,[4102] Move contents of 4102
41 location to BX
4007 29 DB SUB AX,BX Add these 2 words results in
AX
4009 A3 04 41 MOV Save the same in location
[4104],AX 4104
400C CC INT 3 Ends the program

Input: 4100 -5555 4102 -3333


Output: 4104 -2222

9) Program for Byte multiplication


MICROPROCESSOR AND INTERFACING LAB MANUAL

Address opcode Label Mnemonics Comments


4000 A0 00 41 MOV AL,[4100] Get multiplicand to AL

4003 8A 0E 01 41 MOV CL, [4101] Get multiplier to CL


4007 F6 E1 MUL CL Multiply Al,CL
4009 A3 02 41 MOV [4102],AX Store the product in
4102
400D CC INT 3

Input : 4100 33
4101 22
Output : 4102 06 C6

10) Program for word multiplication


MICROPROCESSOR AND INTERFACING LAB MANUAL

Address Opcode LABEL Mnemonics Comments

4000 A1 00 41 MOV Ax,[4100] Move contents of 4100


location to AX
4003 8B 1E 02 41 MOV BX,[4102] Move contents of 4102
location to BX
4007 F7 E3 MUL BX Multiply AX by BX ,result
in DX:AX
4009 A3 04 41 MOV Move lower word to 4106
[4104],AX
400C 89 16 06 41 MOV Move higher word to 4108
[4106],DX
400C CC INT 3 Ends the program

I/P: 4100 3333


4102 2222

O/P: 4104 92C6


4106 06 D3

11) Program for 32 bit by 16 bit division


MICROPROCESSOR AND INTERFACING LAB MANUAL

Address Opcode LABEL Mnemonics Comments

4000 A1 00 41 MOV Ax,[4100] Get the lower word to AX


4003 8B 1E 02 MOV DX, Get the higher word to DX
41 [4102]
4007 8B 0E 04 MOV CX, Get the divisor word to CX
41 [4104]
400A F7 F1 DIV CX Divide DS:AX by CX

400C CC INT 3 Result quotient in AX


remainder in DX

I/P: 4100 2489


4102 0000
AX:1244 DX:0001

12) Program to add two decimal numbers (two bytes)


MICROPROCESSOR AND INTERFACING LAB MANUAL

Address opcode Label Mnemonics Comments

4000 A0 00 41 MOV AL, Get 1st byte to AL


[4100]
4003 8A 26 01 41 MOV AH, Get 2nd byte to AH
[4104]
4007 00 E0 ADD AL,AH Add AL and AH
4009 22 DAA Adjust them for decimal
number
400A A2 02 41 MOV 4012,AL Move result to 4102
location
400D CC INT 3

Input : 4100 56
4101 24
Output : 4102 80

13) Program for sum of given ‘n’ numbers


MICROPROCESSOR AND INTERFACING LAB MANUAL

Address Opcode Label Mnemonics Comments


4000 B1 05 MOV CL,05 Set CL as 05
4002 B0 00 MOV AL,00 SET AL as 00
4004 00 C8 L1 ADD AL,CL Add AL and CL
4006 FE C9 DEC CL Decrement CL
4008 75 FA JNE L1 Jump if not equal to L1
400A CC INT 3 Ends the program

Result is stored in AL

14) Program for average of given ‘n’ numbers


MICROPROCESSOR AND INTERFACING LAB MANUAL

Address Opcode Label Mnemonics Comments


4000 B1 05 MOV CL,05 Set CL as 05
4002 88 CB MOV BL,CL Move the CL content to
BL
4004 B0 00 MOV AL,00 Set AL as 00

4006 10 C8 L1 ADC AL,CL Add AL with CL


4008 FE C9 DEC CL Decrement CL
400A 75 FA JNE L1 Jump if not equal to L1
400C F6 F3 DIV BL Divide by BL
400E CC INT 3 Ends the program

Result is stored in AL

15) Program for sum of squares of ‘N’ numbers


MICROPROCESSOR AND INTERFACING LAB MANUAL

Address Opcode Label Mnemonics Comments


4000 B1 05 MOV CL,05 Set CL as 05
4002 B3 00 MOV BL,00 Set the BL as 00
4004 88 C8 L1 MOV AL,CL Add AL with CL
4006 F6 E1 MUL CL Multiply with CL

4008 00 C3 ADD BL,AL Add BL with AL


400A FE C9 DEC CL Decrement CL
400C 75 F6 JNE L1 Jump if not equal to L1
400E CC INT 3 Ends the program

Result is stored in BL

16) Program to compute the logical 1’s in a word and store the result in
memory
MICROPROCESSOR AND INTERFACING LAB MANUAL

Address opcode Label Mnemonics Comments


4000 A1 00 41 MOV AX, Get the data words to AX
[4100]
4003 C6 06 02 41 00 MOV BPTR Initialize count location to 0
4102,00
4008 B9 10 MOV CX,0010 Set counter to 16

400B D1 C8 ROR AX,1 Shift right AX to check last


bit
400D 73 04 JAE 4013 If it not 1 jump out
400F FE 06 02 41 INC BPTR If it is 1 so increment counter
4102
4013 E2 F6 LOOP 400B Repeat for all 16 bits
4015 CC INT 3 Halt

INPUT: 4100 32 00
OUTPUT: 4102 03

17) PROGRAM TO FIND A SQUARE ROOT OF A GIVEN NUMER


MICROPROCESSOR AND INTERFACING LAB MANUAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS

4000 A1 00 41 MOV AX,[4100] Load the content in ax


4003 D1 E8 SHR AX,1 Shift ax by 1
4005 A3 02 41 MOV 4102,AX Move the content into
4102
4008 A1 00 41 MOV AX,[4100] Move the content into ax
400B BA 00 00 MOV DX,0000 Set dx as 000
400E F7 36 02 41 DIV WPTR 4102 Divide
4012 03 06 02 42 ADD AX,[4102] Add ax and content of
4102
4016 D1 E8 SHR AX,1 Shift right ax by 1
4018 3B 06 02 41 CMP AX,[4102] Compare ax,4102
content
401C 7D 05 JNL 4023 Jump to 4023

401E A3 02 41 MOV 4102,AX Move ax content to 4102


4021 EB E5 MOV 4102,AX Move ax content to 4102

4023 CC INT 3 Halt

INPUT:-0:4100-40,4101-00(64)
OUTPUT:-AX-08

18) PROGRAM TO CONVERT 2 BCD NUMBERS TO HEX


MICROPROCESSOR AND INTERFACING LAB MANUAL

ADDRESS OPCODES LABEL MNEMONICS COMMENTS


4000 A0 00 41 MOV AL,[4100] Get the data byte into al
4003 88 C3 MOV BL,AL
4005 24 0F AND AL,0F
4007 88 C7 MOV BH,AL
4009 B1 04 MOV CL,04
400B D2 CB ROR BL,CL Get the ten digit to lower
400d 80 E3 0F AND BL,0F Nibble of al,mask units
4010 B0 0A MOV AL,0A
4012 F6 E3 MUL BL Multiply by 10’s digit by 10
4014 00 F8 ADD AL,BH And add units to it
4016 cc INT 3

INPUT:-0:4100-52(DECIMAL NO)
OUTPUT:-AL-34(HEX EQUIVALENT

19) Program to convert hex number toBCD


MICROPROCESSOR AND INTERFACING LAB MANUAL

Address Opcode Label Mnemonics Comments


4000 AO 00 41 MOV AL,4100 Get the hex byte to AL

4003 B4 00 MOV AH,00 Sst AH to 0


4005 B3 64 MOV BL,64 Divide the no by 100
4007 F6 F3 DIV BL
4009 88 C5 MOV CH,AL Now 100’s are in AL move it to
CH
400B 88 E0 MOV AL,AH Get the remainder to AL

400D B4 00 MOV AH,00 Set AH to 0


400F B3 0A MOV BL,0A Now divide the no by 10
4011 F6 F3 DIV BL Now 10’s are in AL
4013 86 C4 XCHG AL,AL Units are in AH
4015 B1 04 MOV CL,04
4017 D2 C4 ROL AH,CL Position 1’s in AH to lower
nibble
4019 80 E4 F0 AND AH,0F Add it with F0
401C 08 E0 OR AL,AH Now Al will contain 10’s &
units
401E 88 EC MOV AH,CH GET 100’S to Ah from CH
4020 CC INT 3 Now the result in AH,AL

Input 4100-52
Output ax-143

20) Program to sort given 8 Numbers in descending order starting from


address 4100

Address Opcode Label Mnemonics Comments


MICROPROCESSOR AND INTERFACING LAB MANUAL

4000 B9 08 00 MOV CX,0008 Counter intialises to 8


4003 B4 00 MOV AH,00
4005 BB 00 41 MOV BX,4100 BX to point i/p stream
4008 8A 07 MOV AL,[BX] Get the byte to AL
400A 43 INC BX Increment the pointer
400B 3A 07 CMP AL,[BX] Compare AL with next byte
400D 73 0C JNC 401B IF AL>=[BL] jump out
400F 74 0A JE 401B
4011 8A 17 MOV DL,[BX] Eise exchange
4013 4B DEC BX
4014 88 17 MOV [BX],DL
4016 43 INC BX
4017 88 07 MOV [BX],AL Adjacent byte
4019 B4 01 MOV AH,01 If exchange is made flag it
401B E2 EB LOOP 4008 Loop till the end
401D 80 FC 00 CMP AH,00 Now see if a pass is exchange
free
4020 75 DE JNE 4000 No,start all over again
4022 CC INT 3 Ends the program

21) PROGRAM TO CONVERT BINARY TO ASCII


MICROPROCESSOR AND INTERFACING LAB MANUAL

Address Generated Label Mnemonics Comments


code
4000 A0 00 41 MOV AL,4100 Get the byte to AL

4003 88 C4 MOV AH,AL Save it in AH


4005 24 0F AND AL,#0F Mask higher nibble
4007 E8 0C 00 CALL 4016 Convert to ASCII
400A 86 C4 XCHG AL,AH Get the number to AL
P400C B1 04 MOV CL,#04
400E D2 C8 ROR AL,CL Get the higher nibble now
4010 24 0F AND AL,#0F
4012 E8 01 00 CALL 4016 Convert to ASCII
4015 CC INT 3
4016 3C 09 CMP AL,#09 Check if number>9
4018 72 02 JNAE 401C No jump out
401A 04 07 ADD AL,#07 Else no is A-F add 7
401C 04 30 ADD AL,#30 Add 30 hex
401E C3 RET

Input 4100-3A
Output AL=33 AH=41

You might also like