MA Lab Exp1-2 (A)
MA Lab Exp1-2 (A)
PRN:1032233457
//EXP1:A
;//Addition of two 8 bit numbers
ORG 00H ;start at location
MOV R5,#25H ;load 25H into R5
MOV R7,#34H ;load 34H into R7
MOV A,#0 ;Load 0 into A
ADD A,R5 ;Add content of R5 to A
ADD A,R7 ;Add content of R7 to A
ADD A,#12H ;Now A=A+12H
HERE:SJMP HERE ;stay in this loop
END
--------------------------------------------------------------------------------------------------------------------------------------
//EXP 1:B (ADD 16-BIT NUMBERS 12345678 RESULTS STORE IN R6 AND R5)
ORG 0000H
MOV R1,#05 ;counter for addition of numbers
MOV R0,#40H ;memory address 40 contents to be shifted to R0
LABEL:ADD A,@R0 ;start addition
INC R0
DJNZ R1,LABEL ;continue counter R1 addition address reg R0 till becomes 0
MOV R6,A
MOV 46H,R6
END
//EXP 2:B
ORG 0000H
MOV R1,#00H; counting how many times carry flag is set
MOV R2,#08H; scanning of bits 8 times for a byte
MOV A,#0FFH; load the number to be checked into accumulator
back:RRC A; rotate accumulator right through carry
JC Count
SJMP NEXT
COUNT: INC R1
NEXT:DJNZ R2,BACK
END
//EXP 2:A
; Finding square of numbers using DPTR
ORG 0000H
MOV DPTR, #0100H
MOV R1, #40H
MOV R0, #09H
BACK:
MOV A, R0
MOVC A, @A+DPTR
MOV @R1, A
INC R1
DEC R0
JNZ BACK
ORG 0100H
TABLE: DB 0,1,4,9,16,25,36,49,64,81
END