8 bit addition program of the 8051.
1)8-bit addition program simply use the 8 bit memory location to store element that need to be add. We can use both the internal as well as the external memory location for the addition. In the following program we use the external memory location to fetch the data and add them.program:
ORG 0000H; starting memory location
MOV B,#00H; load the 00h in the resistor b
MOV DPTR,#2000H; load the memory pointer in the DPTR
MOVX A,@DPTR; move content of memory location 2000h in the acc
MOV R2,A; store the content of the accumulator in the resistor R2
INC DPTR; increment memory pointer
MOVX A,@DPTR; move the 2001h content into accumulator
ADD A,R2; add the both content
JNC SKIP; check if carry
INC B; if the carry generated increment the resistor B
SKIP: INC DPTR; increment memory pointer
MOVX @DPTR,A; move the content of the acc into 2002h
MOV A,B; move the content of the b in the acc
INC DPTR; increment the memory pointer
MOVX @DPTR,A; load the value of the acc in the 2003h
END; stop
Comments
Post a Comment