ASM code for 16 bit Subtraction - 8051 - AT89C51 - Assembly


Flowchart:-


Program:-

ORG 0000H
MOV DPTR,#2000H
MOV R0,#50H
INC DPTR
MOVX A,@ DPTR
MOV R2,A
INC DPTR
MOVX A,@DPTR
MOV R2,A
INC DPTR
INC DPTR
MOVX A, @DPTR
XCH A,R2
CLR C
SUBB A, R2
MOV @R0,A
DEC DPL
MOVX A,@DPTR
MOV R2,A
DEC DPL
DEC DPL
INC R0
MOVX A,@DPTR
SUBB A,R2
MOV @R0,A
INC DPTR
INC DPTR
INC DPTR
JNC LOOP1
MOV A, #0FFH
INC DPTR
MOVX @DPTR, A
LOOP1: MOV R0,#51H
INC DPTR
MOV A,@R0
MOVX @DPTR,A
INC DPTR
DEC R0
MOV A,@R0
MOVX @DPTR,A
SJMP $
END

Output:-


For more ASM programs - click here

Popular posts from this blog