You are on page 1of 10

SUBJECT: MICROPROCESSORS AND INTERFACING LAB

CLASS: III CSE


TOPIC: LOGICAL OPERATIONS

By
R. VEENA

LOGICAL OPERATIONS
1. Conversion of Packed BCD number to Unpacked BCD Number and Converting
the two digits into ASCII.

AIM: To write an 8086 Assembly Language program to convert a two digit Packed BCD number into
two Un-Packed BCD numbers and then to find ASCII equivalents of the two digits.

Apparatus Required: MASM Assembler


Program:
DATA SEGMENT
PBCD DB 63H
DIG1 DB ?
DIG2 DB ?
ASC1 DB ?
ASC2 DB ?
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX, DATA
MOV DS, AX
MOV AL, PBCD
AND AL, 0FH
MOV DIG1, AL
ADD AL, 30H
MOV ASC1, AL
MOV AL, PBCD
AND AL, 0F0H
MOV CL, 04H
ROL AL, CL
MOV DIG2, AL
ADD AL, 30H
MOV ASC2, AL
MOV AX,4C00H
INT 21H
CODE ENDS
END START

RESULT: The given Packed BCD Number 63H is Converted into two Un-Packed BCD Numbers
as 06H and 03H. The ASCII values for Un-Packed BCD numbers are 36H and 33H.

2. 8 Bit BCD to Binary


AIM: To write an 8086 Assembly Language Program to Convert 8 bit BCD Number to Binary
Number.

Apparatus Required: MASM Assembler

Program:

DATA SEGMENT
BCD DB 17h
BIN DB ?
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX, DATA
MOV DS, AX
MOV AL, BCD
MOV AH, BCD
AND AH, 0FH
MOV BL, AH
AND AL, 0F0H
MOV CL, 04H
ROR AL, CL
MOV BH, 0AH
MUL BH
ADD AL,BL
MOV BIN, AL
MOV AX, 4C00H
INT 21H
CODE ENDS
END START
RESULT: The Binary Number for the given BCD Number 17H is 11H .

3. 16 Bit BCD to Binary


AIM: To write an 8086 Assembly Language Program to Convert 16 bit BCD Number
to Binary Number.

Apparatus Required: MASM Assembler


Program:
DATA SEGMENT
BCD DW 4596h
BIN DW ?
DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA

START: MOV AX, DATA


MOV DS, AX
MOV AX, BCD
MOV BX, AX
MOV AL, AH
MOV BH, BL
MOV CL, 04H
ROR AH, CL
ROR BH, CL
AND AX, 0F0FH
AND BX, 0F0FH
MOV CX, AX
MOV AX, 0000H
MOV AL, CH
MOV DI, 03E8H
MUL DI
MOV DH, 00H
MOV DL, BL
ADD AX, DX
MOV AX, 0064H
MUL CL
ADD DX, AX
MOV AX, 000AH
MUL BH
ADD AX, DX
MOV BIN, DX
MOV AX, 4C00H
INT 21H

CODE ENDS
END START

RESULT: The Binary Number for the given BCD Number 4596H is 11F4H .
4. 8 Bit Binary to BCD

AIM: To write an 8086 Assembly Language Program to Convert 8 bit Binary Number
to BCD Number.

Apparatus Required: MASM Assembler

Program:
DATA SEGMENT
BIN DB 11H
BCD DB ?
DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA

START: MOV AX, DATA


MOV DS, AX
MOV AL, BIN
MOV AH, 00H
MOV BL, 64H
DIV BL
MOV CH, AL
MOV AL, AH
MOV BL, 0AH
MOV AH, 00H
DIV BL
XCHG AL, AH
MOV CL, 04H
ROL AH, CH
AND AH, 0F0H
OR AL, AH
MOV AH, CH
MOV BCD, AL
MOV AX, 4C00H
INT 21H

CODE ENDS
END START

RESULT: The given 8 Bit Binary Number 11H is converted into BCD Number as 17H .
5. 16 Bit Binary to BCD

AIM: To write an 8086 Assembly Language Program to Convert 16 bit Binary Number
to BCD Number.
Apparatus Required: MASM Assembler
Program:
DATA SEGMENT
BIN DW 11F4H
BCD DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS: DATA
START: MOV AX, DATA
MOV DS, AX
MOV AX, BIN
MOV DX, 0000H
MOV BX, 2710H
DIV BX
MOV AX, DX
MOV DX, 0000H
MOV BX, 03E8H
DIV BX
XCHG AL, AH
MOV CL, 04H
ROR AH, CL
MOV AL, 00H
MOV DI, AX
MOV AX, DX
MOV DX, 0000H
MOV BX, 0064H
DIV BX
MOV AH, AL
MOV AL, 00H
OR DI, AX
MOV AX, DX
MOV DX, 0000H
MOV BX, 000AH
DIV BX
MOV CL, 04H
ROR AL, CL
OR DI, AX
OR DI, DX
MOV BCD, DI
MOV AX, 4C00H
INT 21H
CODE ENDS
END START

RESULT: The given 16 Bit Binary Number 11F4H is converted into


BCD Number as 4596H .