0% found this document useful (0 votes)
218 views7 pages

8-bit Arithmetic and Conversion Programs

The document contains program code for performing various arithmetic and conversion operations using 8-bit registers on a microcontroller. It includes programs to add and subtract two 8-bit numbers, multiply and divide two 8-bit numbers, convert binary to Gray code, and convert Centigrade to Fahrenheit temperatures. The programs demonstrate the use of MOV, ADD, SUB, MUL, DIV, RRC, ANL, XRL instructions to perform the necessary calculations and data transfers between registers.

Uploaded by

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

8-bit Arithmetic and Conversion Programs

The document contains program code for performing various arithmetic and conversion operations using 8-bit registers on a microcontroller. It includes programs to add and subtract two 8-bit numbers, multiply and divide two 8-bit numbers, convert binary to Gray code, and convert Centigrade to Fahrenheit temperatures. The programs demonstrate the use of MOV, ADD, SUB, MUL, DIV, RRC, ANL, XRL instructions to perform the necessary calculations and data transfers between registers.

Uploaded by

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

7.

(i) Program for addition of two 8-bit numbers using registers

ADDRESS HEXCODE LABEL OPCODE OPERAND


MOV R0,#45H
MOV R1,#30H
MOV A,R0
ADD A,R1
MOV R3,A
JNC (LOOP)
MOV R2,#01H
LOOP: LCALL 0003H

INPUT OUPTUT

R0= R3=
R1= R2= (CARRY)
gisters
7.(ii) Program for subtraction of two 8-bit numbers using registers

ADDRESS HEXCODE LABEL OPCODE OPERAND


MOV R0,#45H
MOV R1,#30H
MOV A,R0
SUBB A,R1
MOV R3,A
JNC (LOOP)
MOV R2,#01H
LOOP: LCALL 0003H

INPUT OUPTUT

R0= R3=
R1= R2= (CARRY)
8 (i). Product of two 8-bit numbers using MUL instruction stored at 50h and 51h locations

ADDRESS HEXCODE LABEL OPCODE OPERAND


MOV 50H,#02H
MOV 51H,#04H
MOV A,50H
MOV 0F0H,A
MOV A,51H
MUL AB
MOV 52H,A
MOV 53H,0F0H
LCALL 0003H

INPUT OUTPUT

50H= 52H=
51H= 53H=
8 (ii) Division of two 8-bit numbers using DIV instruction stored at 50h and 51h locations

ADDRESS HEXCODE LABEL OPCODE OPERAND


MOV 50H,#04H
MOV 51H,#02H
MOV 0F0H,51H
MOV A,50H
DIV AB
MOV 52H,A
MOV 53H,0F0H
LCALL 0003H

INPUT OUTPUT

50H= 52H=
51H= 53H=
9 Conversion of Binary Code to Gray Code

ADDRESS HEXCODE LABEL OPCODE OPERAND


MOV R0,#22H
MOV R1,R0
MOV A,R0
RRC A
ANL A,#7FH
XRL A,R1
MOV R2,A
LCALL 00BBH
10 Centigrade to Fahreinheit Conversion

ADDRESS HEXCODE LABEL OPCODE OPERAND


MOV R0,#05H
MOV R1,#09H
MOV R2,#20H
MOV R3,#05H
MOV A,R0
MOV 0F0H,R1
MUL AB
MOV 0F0H,R3
DIV AB
ADD A,R2
MOV R4,A
LCALL 00BBH

You might also like