Professional Documents
Culture Documents
MPMC Lab Record
MPMC Lab Record
NAME :
SEMESTER : V
AIM:
To add two 16-bit immediate values to perform with and without carry operation.
APPARATUS REQUIRED: emu8086 emulator.
ALGORITHM:
1. Load the first data in AX register.
2. Load the second data in BX register.
3. Clear CL register.
4. Add the two data and get the sum in AX register.
5. Store the sum in source index register.
6. Check for carry, if carry flag is set then go to next step, otherwise go to step-8.
7. Increment CL register.
8. Store the carry high order byte of the data register (DH).
9. Stop.
PROGRAM:
1
OUTPUT:
SI: 3332H
DH: 01H
SI: 2468H
DH: 00H
RESULT:
Thus the two 16-bit numbers are added and the results are observed for
both with and without carry operations at different registers.
Ex.No : 2 Multi-byte Addition using 8086
DATE : 24-07-2020
AIM:
To perform addition operation among two multi-byte data.
ALGORITHM:
1. Load the starting address of 1st data in SI register.
2. Load the starting address of 2nd data in DI register.
3. Load the starting address of result in BX register.
4. Load the byte count in CL register.
5. Load a byte of 1st data in AL register.
6. Add the corresponding byte of 2nd data in memory to AL
register along with previous carry.
7. Store the sum in memory.
8. Increment the byte pointer (BX) and result pointer (BP).
9. Decrement the byte count (CL).
10. If byte count (CL) is zero go to next step, otherwise go to step-8.
11. Store final carry in memory.
12. Stop.
PROGRAM:
RESULT:
Thus the addition of multi-byte numbers have been performed and results are observed at
different locations of the memory.
Ex.No : 3 16-bit Data Multiplication using 8086
DATE : 06-08-2020
AIM:
To multiply two 16-bit values and to view the result in memory locations.
ALGORITHM:
PROGRAM:
MOV SI,1100H
MOV AX, [SI]
MOV BX, [SI+2]
MUL BX
MOV [SI+4], AX
MOV AX, DX
MOV [SI+6], AX
HLT
INPUT:
1100: 43
1101: 43
1102: 11
1103: 11
OUTPUT:
1104: 73
1105: EA
1106: 7B
1107: 04
RESULT:
Thus the two 16-bit numbers are multiplied and the results are observed at
different locations of the memory.
Ex.No : 4 16-bit Data Division using 8086
DATE : 06-08-2020
AIM:
To divide a 16-bit value by a 8-bit number and to view the result in memory locations.
ALGORITHM:
PROGRAM:
MOV SI,1100H
MOV AX, [SI]
MOV BX, [SI+2]
DIV BX
MOV [SI+4], AX
MOV AX, DX
MOV [SI+6], AX
HLT
INPUT:
1100: 24 1100: 23
1101: 24 1101: 11
1102: 02 1102: 02
1103: 00 1103: 00
OUTPUT:
1104: 12 1104: 91
1105: 12 1105: 08
1106: 00 1106: 01
1107: 00 1107: 00
RESULT:
Thus the a 16-bit number is divided by a 8 bit number and the results are
observed at different locations of the memory.
Ex.No : 5 BCD Addition using 8086
DATE : 06-08-2020
AIM:
To perform BCD addition among
I. Two 8-bit values and to store the results in different location of memory.
II. Two 16-bit values and to store the results in different location of memory.
ALGORITHM:
PROGRAM:
INPUT: OUTPUT:
1100: 11 1102: 22
1101: 11 1103: 00
INPUT: OUTPUT:
1100: 11 1102: 10
1101: 99 1103: 01
B. 16-BIT BCD ADDITION
INPUT: OUTPUT:
1100: 11 1104: 22
1101: 11 1105: 22
1102: 11 1106: 00
1103: 11 1107: 00
INPUT: OUTPUT:
1100: 11 1104: 10
1101: 11 1105: AA
1102: 99 1106: 01
1103: 99 1107: 00
RESULT:
Thus the BCD addition of 8-bit and 16-bit numbers are performed and the results are
observed for both with and without borrow operations at different location of memory.
Ex.No : 6 1’s complement and 2’s complement number using 8086
DATE : 14-08-2020
AIM:
To perform 1’s and 2’s complement of a16-bit data.
ALGORITHM:
PROGRAM:
Input Output
Memory Data
1100 11 1102: EE 1104: EF
Thus 1’s and 2’s complement of a 16-bit data are performed and the results are noted.
Ex.No : 7 16-bit Logical Operations using 8086
DATE : 14-08-2020
AIM:
To perform logical operations such as AND, OR,XOR, and NOT among two 16-bit
data.
ALGORITHM:
MOV SI,1100H
MOV AX, [SI]
MOV BX, [SI+2]
AND AX, BX
MOV [SI+4], AX
HLT
b. 16-bit OR operation
MOV SI,1100H
MOV AX, [SI]
MOV BX, [SI+2]
OR AX, BX
MOV [SI+4], AX
HLT
MOV SI,1100H
MOV AX, [SI]
MOV BX, [SI+2]
XOR AX, BX
MOV [SI+4], AX
HLT
MOV SI,1100H
MOV AX, [SI]
NOT AX
MOV [SI+2], AX
HLT
Input Output
AND OR XOR
Memory Data
1100 11 1104: 00 1104: 11 1104: 11
1101 23
1102 00 1105: 23 1105: 23 1105: 00
1103 23
NOT gate
Input: Output:
1100: 11 1102: EE
1101: 23 1103: DC
AND gate
OR gate
XOR gate
NOT gate
RESULT:
Thus the logical operations such as AND, OR, XOR and NOT among two 16-bit data
are performed and the results are noted.
Ex.No : 8 Data Block Movement using
AIM:
To perform data block movement without overlap.
ALGORITHM:
PROGRAM:
MOV SI, 2000H
MOV DI, 3000H
MOV CX,0004
REP
MOVSW
HLT
ALGORITHM:
PROGRAM:
MOV SI, 2000H
MOV DI, 3000H
MOV CX,0004
REP
MOVSW
HLT
Input Output
Method-1 Method-2
2000: 1A 3000: 1A 3000: 1A
2001: 1B 3001: 1B 3001: 1B
2002: 1C 3002: 1C 3002: 1C
2003: 1D 3003: 1D 3003: 1D
Method-1
Method-2
16 - BIT BLOCK TRANSFER
ALGORITHM:
PROGRAM:
Thus the operation of data block movement have been performed and results are
observed at different locations of the memory.
Ex.No : 9a Code Conversion using 8086
DATE : 28-08-2020
AIM:
To perform code conversion operation
ALGORITHM:
PROGRAM:
2000: 37 2500: 07
RESULT:
DATE : 28-08-2020
AIM:
To convert a hexadecimal nibble to ASCII number.
ALGORITHM:
PROGRAM:
RESULT:
DATE : 04-09-2020
AIM:
To convert an 8-bit hexadecimal number to BCD number.
ALGORITHM:
5. Checks carry flag. If carry flag is set then go to step-9, otherwise go to next step.
6. Subtract 64 (100 ) from AL register.
H 10
10. Checks carry flag. If carry flag is set then go to step-14, otherwise go to next step.
11. Subtract 0A (10 ) from AL register.
H 10
PROGRAM:
MOV BX, 1100H
MOV AL, [BX]
MOV DX, 0000H
HUN: CMP AL, 64H
JC TEN
SUB AL, 64H
INC DL
JMP HUN
TEN: CMP AL, 0AH
JC UNIT
SUB AL, 0AH
INC DH
JMP TEN
UNIT: MOV CL, 04
ROL DH, CL
ADD AL, DH
MOV [BX+1], AL
MOV [BX+2], DL
HLT
DATE : 04-09-2020
AIM:
To convert an 8-bit BCD number to hexadecimal number.
ALGORITHM:
PROGRAM:
500 – 18 600 – 12
RESULT:
AIM:
To perform addition and subtraction operation among two 4x4 matrices.
ALGORITHM:
PROGRAM:
Matrix Addition
MOV SI,2000H
MOV DI,3000H
MOV CL,04H
L1: MOV AL, [SI]
MOV BL, [DI]
ADD AL, BL
MOV [DI], AL
INC DI
INC SI
DEC CL
JNZ L1
MOV AH, 4CH
HLT
Matrix Subtraction
MOV SI,2000H
MOV DI,3000H
MOV CL,04H
L1: MOV AL, [SI]
MOV BL, [DI]
SUB AL, BL
MOV [DI], AL
INC DI
INC SI
DEC CL
JNZ L1
MOV AH, 4CH
HLT
OUTCOME:
Matrix Addition:
Input Output
Memory Location Data Memory Location Data Memory Location Data
Input Output
Memory Location Data Memory Location Data Memory Location Data
RESULT:
Thus the addition and subtraction of two 4x4 matrices have been performed and results
are observed at different locations of the memory.
Ex.No : 10b String Manipulations using 8086
DATE : 11-09-2020
AIM:
i.To perform string of data copy operation using 8086.
ii.To reverse the string of input data.
i. ALGORITHM:
PROGRAM:
String Copy
ii. ALGORITHM:
String Reversal
String Copy
String Reversal
OUTCOME:
String Copy:
Input Output
Memory Location Data Memory Location Data
2000 01 2100 01
2001 05 2101 05
2002 04 2102 04
2003 03 2103 03
String Reversal:
Input Output
Memory Location Data Memory Location Data
2000 08 3000 01
2001 07 3001 02
2002 06 3002 03
2003 05 3003 04
2004 04 3004 05
2005 03 3005 06
2006 02 3006 07
2007 01 3007 08
RESULT:
Thus the string manipulation operations such as copying string of data and reversal
have been performed and results are observed at different locations of the memory.
Ex.No : 11 Data Arrangement in ascending/ descending order
using 8086
DATE : 18-09-2020
AIM:
To sort an array of numbers in ascending and descending order and to view the
result in memory locations.
ALGORITHM:
PROGRAM:
Ascending Order:
JC LOOP
XCHG AL, [SI]
XCHG AL, [SI - 1]
LOOP: DEC CH
JNZ REM
DEC CL
JNZ REPEAT
HLT
Descending Order:
JNC LOOP
XCHG AL, [SI]
XCHG AL, [SI - 1]
LOOP: DEC CH
JNZ REM
DEC CL
JNZ REPEAT
HLT
Ascending Order:
Descending Order:
ASCENDING ORDER:
INPUT:
1100: 04
1101: 03
1102: 06
1103: 05
1104: 02
OUTPUT:
1101: 02
1102: 03
1103: 05
1104: 06
DESCENDING ORDER:
INPUT:
1100: 04
1101: 06
1102: 03
1103: 05
1104: 07
OUTPUT:
1101: 07
1102: 06
1103: 05
1104: 03
RESULT:
Thus sorting an array of numbers in ascending and descending order have been
done and the results are observed at different locations of the memory.
Ex.No : 12 Search for data in an array using
AIM:
To search a given data in an array and also to determine the position and address of
the data in the array.
ALGORITHM:
PROGRAM:
RESULT:
Thus data search in an array done and the results such as its availability, position and
address are observed.
Ex.No : 13 Password Checking using
AIM:
To check whether the password is correct or not.
ALGORITHM:
PROGRAM:
DATA SEGMENT
PASSWORD DB 'MPMC1234'
LEN EQU ($-PASSWORD)
MSG1 DB 10,13,'ENTER YOUR PASSWORD: $' //10-ascill character in new
line,13carriage return
MSG2 DB 10,13,'WELCOME TO ELECTRONICS WORLD!!$'
MSG3 DB 10,13,'INCORRECT PASSWORD!$'
NEW DB 10,13,'$'
INST DB 10 DUP(0) // 10-equilaent hexa value of 16, dup(0)- bytes, avoid garbage
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1 //load effective address
MOV AH,09H // dos interrupt ,display string on screen first message will be displayed
INT 21H
MOV SI,00
UP1:
MOV AH,08H // keyboard input without any echo
INT 21H // CALLS Interrupt handler
CMP AL,0DH
JE DOWN
MOV [INST+SI],AL
MOV DL,'*'
MOV AH,02H // request single display chatracter
INT 21H //software interrupt
INC SI
JMP UP1
DOWN:
MOV BX,00
MOV CX,LEN
CHECK:
MOV AL,[INST+BX]
MOV DL,[PASSWORD+BX]
CMP AL,DL
JNE FAIL //jne-jump if nit equal
INC BX
LOOP CHECK
LEA DX,MSG2
MOV AH,09H // request display
INT 21H
JMP FINISH
FAIL:
LEA DX,MSG3
MOV AH,009H
INT 21H
FINISH:
INT 3
CODE ENDS
END START
END
RESULT:
DATE : 09-10-2020
AIM:
To read create customized time delay to print the string.
PROGRAM:
.MODEL SMALL
.DATA
MSGIN DB 'Enter delay duration (0-50): $'
MSG1 DB 'This is Microprocessor! $'
DELAYTIME DW 0000H
.CODE
MOV DX,@DATA
MOV DS, DX
LEA DX, MSGIN
MOV AH, 09H
INT 21H
IN1: MOV AH, 01H
INT 21H
CMP AL, 0DH
JE NXT
SUB AL, 30
MOV DL, AL
MOV AX, BX
MOV CL, 0AH
MUL CL
MOV BX, AX
AND DX, 00FFH
ADD BX, DX
MOV DELAYTIME, BX
LOOP IN1
NXT:
MOV CX, DELAYTIME
MOV DL, 10
MOV AH, 02H
INT 21H
LEA SI, MSG1
LP:PUSH DX
MOV DL,[SI]
CMP DL,'$'
JE NXT2
MOV AH, 02H
INT 21H
ADD SI, 1
POP DX
MOV DI, DELAYTIME
MOV AH, 0
INT 1Ah
MOV BX, DX
Delay:
MOV AH, 0
INT 1Ah
SUB DX, BX
CMP DI, DX
JA Delay
LOOP LP
NXT2:
MOV AH, 4CH
INT 21H
END
Note:
i.model is the part of program which tells assembler which model we need to use for
our program. In this program we are using SMALL, but there are many like TINY,
SMALL and LARGE
.MODEL SMALL
ii.After setting up DATA SEGMENT, CODE SEGMENT starts, which tells assembler
that our program has been started. We define CODE SEGMENT same as we defined
DATA SEGMENT.
.CODE
OUTPUT:
Time delay :2 ms
This is Microprocessor
RESULT:
Thus the time delay of a string has been created and verified using the simulator.
EX NO: 15 Digital clock using 8086
DATE: 09-10-2020
AIM:
To write an ALP to display Digital clock using 8086
PROGRAM:
.MODEL SMALL
.STACK 100H
.DATA
TIME DB '00:00:00$'
.CODE
MAIN PROC
MOV DS, AX
CALL GET_TIME
INT 21H
INT 21H
INT 21H
MAIN ENDP
GET_TIME PROC
PUSH AX
PUSH CX
INT 21H
CALL CONVERT
CALL CONVERT
CALL CONVERT
POP CX
POP AX
RET
GET_TIME ENDP
CONVERT PROC
PUSH DX
DIV DL
POP DX
RET
CONVERT ENDP
END MAIN
OUTPUT:
Current system Time is: 11:06:46
RESULT:
Thus the Digital Clock is displayed using 8086.
AIM:
To check the Status of Printer using 8086.
PROGRAM:
name "charchar"
org 100h
print_new_line macro
mov dl, 13
mov ah, 2
int 21h
mov dl, 10
mov ah, 2
int 21h
endm
mov dx, offset msg1
mov ah, 9
int 21h
; input the string:
mov dx, offset s1
mov ah, 0ah
int 21h
; get actual string size:
xor cx, cx
mov cl, s1[1]
print_new_line
mov bx, offset s1[2]
print_char:
mov dl, [bx]
mov ah, 2
int 21h
print_new_line
inc bx
loop print_char
; wait for any key...
mov ax, 0
int 16h
ret
msg1 db "ENTER THE STRING: $"
s1 db 100,?, 100 dup(' ')
end
OUTPUT:
ENTER THE STRING: PADMA
P
A
D
M
A
RESULT:
AIM:
To control stepper motor in clock wise and counter clock wise direction using 8086.
PROCEDURE:
1. Load the program
2. Click on emulator
3. Click on run option to see the stepper motor rotation
ALGORITHM:
1. The virtual port 7 is configured.
2. The port connected to the stepper motor does the rotation based on the value specified in the table.
PROGRAM:
name "stepper"
jmp start
start:
mov bx, offset datcw ; start from clock-wise half-step.
mov si, 0
mov cx, 0 ; step counter
next_step:
; motor sets top bit when it's ready to accept new command
wait: in al, 7
test al, 10000000b
jz wait
inc si
cmp si, 4
jb next_step
mov si, 0
inc cx
cmp cx, steps_before_direction_change
jb next_step
mov cx, 0
add bx, 4 ; next bin data
OUTPUT:
RESULT:
Thus the rotation of stepper motor have been observed in both clock wise and counter
clockwise direction for specific time interval.
EX NO: 18 Interfacing of Traffic Light controller with 8086
DATE: 12-10-2020
AIM:
To interface the traffic light using 8086.
PROCEDURE:
1.Load the program
2.Click on emulator
3.Open traffic.exe from virtual devices tab
4.Click on run to see the traffic light control
ALGORITHM:
1.Move the contents to AX register.
2.Initialize traffic lights.
3.Load SI register with offset values.
4.Set AX with SI register values.
5.Change the light status after a certain period of time.
6.Send the command from the array table to the port.
7.Stop the program.
PROGRAM:
name "traffic"
mov ax, all_red
out 4, ax ; traffic lights
mov si, offset situation
next:
mov ax, [si]
out 4, ax
; FEDC_BA98_7654_3210
situation dw 0000_0011_0000_1100b
s1 dw 0000_0110_1001_1010b
s2 dw 0000_1000_0110_0001b
s3 dw 0000_1000_0110_0001b
s4 dw 0000_0100_1101_0011b
sit_end = $
OUTPUT:
RESULT:
Thus the traffic lights been adjusted for specific time interval and the results are
observed.
Ex.No : 19 Arithmetic Operations using 8051
DATE: 12-10-2020
AIM:
To perform the arithmetic operations of 8051.
PROGRAM:
a) 8 BIT ADDITION
MOV A, #33H
MOV R1, #22H
ADD A, R1
MOV DPTR, #4500H
MOVX @DPTR, A
END
OUTPUT:
4500 – 55
b) 8 BIT SUBTRACTION
MOV A, #33H
MOV R7, #22H
SUBB A, R7
END
OUTPUT
A - 11
c) MULTIPLICATION
MOV A, #0FFH
MOV B, #02H
MUL AB
END
OUTPUT
A - FE
B – 01
d) DIVISION
MOV A, #0BH
MOV B, #02H
DIV AB
END
OUTPUT
A - 05
B – 01
e) Adding data from RAM memory and storing result in RAM memory
(using direct addressing method)
p1 – 07
PROGRAM
DATE: 15-10-2020
AIM:
To perform logical operations such as AND, OR,XOR, and NOT among two 8-bit data.
ALGORITHM:
8-bit AND operation
3. Load the first data in A register.
4. The contents of Ais AND with 8 BIT DATA register and store the result in B register
5. Stop.
8-bit OR operation
1. Load the first data in A register.
2. The contents of Ais ORED with 8 BIT DATA register and store the result in B register
3. Stop.
PROGRAM:
a. 8-bit AND operation
MOV A,#0CH
ANL A,#09H
MOV B,A
END
b. 8-bit OR operation
MOV A,#0CH
ORL A,#09H
MOV B,A
END
c. 8-bit XOR operation
MOV A,#0CH
XRL A,#09H
MOV B,A
END
MOV A,#4CH
CPL A
MOV B,A
END
AND
OUTPUT:
B - 08
OR
OUTPUT:
B - 0D
XOR
OUTPUT:
B – 05
NOT
OUTPUT:
B - B3
RESULT:
Thus the logical operations such as AND, OR,XOR, and NOT among two 8-bit data are performed
and the results are noted.
AIM:
To find cube of a number using 8051.
PROGRAM:
org 0000h
mov a, #n //assign value 'n' in decimal to A
mov 41h, b
mov r1, a
mov a, b
mov b, r0
mul ab
mov b, a
mov r2, b
mov a, r1
mov b, r0
mul ab
mov 50h, a
mov r3, b
mov a, r2
add a, r3
mov b, a
mov 51h, b
end
INPUT: OUTPUT:
a – 02 50 –08
b – 02 51 –00
r0 – 02
RESULT:
Thus a cube program is done in 8051 microcontroller.
AIM:
To write an ALP to perform the code conversion of BCD to ASCII.
ALGORITHM:
1.Get a number
2.Add the number with 30 H
3. Move the content to any register .
4.Store the result.
5.Stop the program
PROGRAM:
MOV A,#02H
ORL A,# 30H
MOV B,A
END
RESULT: