2. 8051 Assembly Programming_Practice
2. 8051 Assembly Programming_Practice
Practice
Addition
ORG 0000h
MOV R0, #03H // move the value 3 to the egister R0//
MOV A, #05H // move the value 5 to accumulator A//
Add A, R0H // add A value with R0 value and stores the
result in A//
END
What will be the content in A?
A= 03+05 = 08H
ORG 0000h
MOV R0, #03H // move the value 3 to the egister R0//
MOV A, #05H // move the value 5 to accumulator A//
Add A, 00H // add A value with R0 value and stores the
result in A//
END
What will be the content in A?
MOV 07h,#01h
MOV A, #08h
ADD A,07h
A= 0F H and B 00 H
Division
ORG 0000h
MOV B, #03H // move the value 3 to register R0//
MOV A, #15H // move the value 5 to accumulator A//
DIV AB // final value is stored in the Accumulator A //
END
ANS: Bank 3
MOV A,#0 ;
MOV R2,#04;
Loop
A = 0,clean ACC
the multiplier is replaced in R2
AGAIN:ADD A,#02h ; add the multiplicand to the ACC
DJNZ R2, AGAIN ; repeat until R2 = 0
MOV R5 , A ; save A in R5 ;
A=0
R2=04
A=A+02=02
R2=3!=0
A=A+02=02+02=04
R2=2!=0
A=04+02=06
R2=1!=0
A=06+02=08
R2=0; R5=A=08
MOV A, #00H //00H is stored in the A register//
MOV DPTR, #0500H //DPTR points 0500h address in the
memory//
MOVC A, @A+DPTR //send the value to the A register//
MOV R0, A //date of A send to the PO registrar//
ORG:500H
DB:0AH
END
What will be the content in R0?