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

Code Exp1&2 Ma

The document contains several assembly language programs for various arithmetic and counting operations. It includes programs for adding 8-bit and 16-bit numbers, summing N 8-bit numbers from memory, calculating the square of a number using a data pointer, counting the number of 1's in a byte, and counting odd and even numbers in an array. Each program is presented with its respective code and comments for clarity.

Uploaded by

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

Code Exp1&2 Ma

The document contains several assembly language programs for various arithmetic and counting operations. It includes programs for adding 8-bit and 16-bit numbers, summing N 8-bit numbers from memory, calculating the square of a number using a data pointer, counting the number of 1's in a byte, and counting odd and even numbers in an array. Each program is presented with its respective code and comments for clarity.

Uploaded by

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

(1)Write assembly language program for addition of two 8-bit numbers

CODE:

ORG OOOH
CLR C
MOV A, #10H
ADD A,#11H
MOV R1, A
MOV A, #15H
ADD A, #168
MOV R0, A
END

(2) Write assembly language program for addition of two 16-bit numbers.

CODE:

ORG OOOOH
CLR C
MOV A, #108
ADD A, #118
MOV R1, A
MOV A, #128
ADDC A, #13H
MOV R2, A
END

(3) Write assembly language program for addition of N 8-bit numbers Take the input numbers from
memory and store the result in memory

CODE:

ORG 000H
MOV RO, #40H
MOV R2,50H
MOV 46H,#OOH
MOV 45H,#00H
MOV A,#00H
L2: ADD A, GRO
JNC L1
INC 45H
L1: INC RO;
DJNZ R2, L2
MOV 46H, A
END
(4) Find the square of a number using DPTR.

CODE:

ORG 0000H
MOV DPTR, #300H
MOV R1, #00H
BACK: MOV A,R1
MOVC A, @A+DPTR
MOV 40H, A
INC R1
SJMP BACK
ORG 300H
TABLE: DB OH,1H, 4H,9H,16H,258,36H,49H,64H,81H
END

(5) Program to count number of 1’s in a given byte.

CODE:

ORG 0OOH
MOV R2,#08H; Number of bits in the number
MOV A,#55H;
back: RLC A: Rotate left through carry
JC COUNT: Jump if carry indication one encountered in the number
SJMP NEXT: If no carry means zero encountered
COUNT: INC Ri: Count ones
NEXT: DJNZ R2, BACK: If 8 bits not completed jump to back and check for new bit
END

(6) Program to count number of Odd and Even numbers from a given array.

CODE:

ORG 00OOH
MOV R2, #00H
MOV R3, #008
MOV R4, #OSH
MOV RO, #30日
BACK:
MOV A, @R0
INC R0
MOV B, #028
DIV AB
INC R3
SJMP NEXT
ODD:
INC R2
NEXT:
DJNZ R4, BACK
SJMP $
END

You might also like