0% found this document useful (0 votes)
32 views3 pages

Expt 5

Uploaded by

pottivasanthi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views3 pages

Expt 5

Uploaded by

pottivasanthi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

MICRO PROCESSORS & MICROCONTROLERSECE

LABDEPARTMENT

EXP.No: 05 Date:

BINARY TO GRAY CONVERSION


AIM:

To write assembly language program to obtain binary to gray conversion of given numbers

APPARATUS: 1.Masm software

2.PC

REGISTERS USED: AX,CS,DS

FLAGS EFFECTED: CARRY FLAG

ALGORITHM:

1.Initialise the data segment

2.move 39 to AL register

3.move AL register value to BL register

4.clear carry flag

5.Rotate right through carry AL by one time

6.EX-OR AL value to BL value

7.move BL value to result [0000]

8.move 4C to AH register

PROGRAM:

ASSUME CS:CODE,DS:DATA

DATA SEGMENT

NUM EQU 39H

RESULT DB(?)

DATA ENDS

CODE SEGMENT

START: MOV AX,DATA

PRAGATI ENGINEERING COLLEGE, SURAMPALEM Page 1


MICRO PROCESSORS & MICROCONTROLERSECE
LABDEPARTMENT

MOV DS,AX

MOV AL,NUM

MOV BL,AL

CLC

RCR AL,1

XOR BL,AL

MOV[RESULT],BL

MOV AH,4CH

INT 21H

CODE ENDS

END START

CODE TABLE:_

BASE OFFSET HEXA CODE OPCODE OPERAND COMMENTS


ADDRESS
0B57 0000 B8560B MOV AX,0B56 Intialization of
data segment
0B57 0003 8ED8 MOV DS,AX Intialization of
data segment
0B57 0005 B039 MOV AL,39 Move 39to AL
0B57 0007 8AD8 MOV BL,AL Move AL value
to BL
0B57 0009 F8 CLC Clear carry flag
0B57 000A D0D8 RCR AL,1 Rotate right al
through carry
one time
0B57 000C 32D8 XOR BL,AL Ex-or BL with
AL
0B57 000E 88D1E0000 MOV [0000],BL Move BL value
to result
0B57 0012 B44C MOV AH,4CH Move 4c to AH
register
0B57 0014 CD21 INTT 21 Move 4c to AH
register

PRAGATI ENGINEERING COLLEGE, SURAMPALEM Page 2


MICRO PROCESSORS & MICROCONTROLERSECE
LABDEPARTMENT

PROCEDURE:

1. Type masmfilename.asm and press enter on the command prompt.

2. If any errors are present rectify that errors and go to step3.

3. Type link filename.obj and press enter.

4. Type debug filename.exe and press enter.

5. Press command ‘U’ and note down the code table

6. Trace the program by typing command ‘T’until INT 21H

7. Type eds: offset address of input/output variables for obtain the result.

8. Type ‘q’ command for Quit the program

OBSERVATIONS:

INPUT: 05H-0000 0101

OUTPUT:07H-0000 0111

Result:

Hence Binary to gray conversion is obtained using MASM Software

PRAGATI ENGINEERING COLLEGE, SURAMPALEM Page 3

You might also like