Code Exp1&2 Ma
Code Exp1&2 Ma
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
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