Saturday, April 30, 2016

8051 Program – search a byte in array and count match

; search a byte in an array of bytes
; count the number of match
; external memory
ORG 0H
MOV R0,#10 ;Array size
MOV R1,#10 ;Search value
MOV R2,#00 ;Count
MOV DPTR,#9000H
LOOP:MOVX A,@DPTR
CLR C
SUBB A,R1 ;compare
INC DPTR
JNZ SKIP
INC R2
SKIP: DJNZ R0,LOOP
SJMP $
END



Related topics:
8051 Program - search an element in an array   |   8051 Program - square of a given number 8bit   |   8051 Program - square root of a given number 8bit   |   8051 Program - square and cube operation   |   8051 Program - count number of ones in a byte   |   8051 Program - count 0 and 1 in a byte   |   8051 Program - memory subroutines   |   8051 Program - math subroutines   |   8051 Program - conversion subroutines

List of topics: 8051

No comments:

Post a Comment