; 8-bit subtraction
; R7-R6
ORG 0H
ERAM EQU 4000H
MAIN:
MOV R7,#20 ; load data1 in to R7
MOV R6,#15 ; load data2 in to R6
LCALL SUB_8
SJMP MAIN
SUB_8:
CLR C ; clear carry flag
MOV A,R7 ; load data1 in to accumulator
SUBB A,R6 ; subtract data2 from data1
store:
MOV DPTR,#ERAM ; point to external RAM
MOVX @DPTR,A ; store the result
RET
END
Related topics:
8051 Program - arithmetic operation 8bit | 8051 Program - addition 8bit | 8051 Program - multiplication 8bit | 8051 Program - division 8bit | 8051 Program - addition 16bit | 8051 Program - subtraction 16bit | 8051 Program - multiplication 16bit | 8051 Program - division 16bit | 8051 Program - addition multibyte | 8051 Program - multiplication 16bit by 8bit | 8051 Program - addition 8bit 2digit bcd | 8051 Program - memory subroutines | 8051 Program - math subroutines | 8051 Program - conversion subroutines
List of topics: 8051
No comments:
Post a Comment