Switch to full style
PIC Assembly Articles
Post a reply

find out the number of elements in an array of 8-bit element

Wed May 15, 2013 1:54 pm

find out the number of elements in an array of 8-bit elements that are a multiple of 8
Code:
#include <p18F8720.inc>
ilimit equ 0x20 ; loop index limit
count set 0x00
ii set 0x01 
; loop index
mask equ 0x07 
; used to masked upper five bits
org 0x00
goto start
… 
; interrupt service routines
start clrf count
,A
movlw ilimit
movwf ii 
; initialize ii to ilimit
movlw upper array
movwf TBLPTRU
,A
movlw high array
movwf TBLPTRH
,A
movlw low array
movwf TBLPTRL
,A
movlw mask
i_loop tblrd
*+ ; read an array element into TABLAT
andwf TABLAT
,F,A
bnz next 
; branch if not a multiple of 8

incf count
,F,; is a multiple of 8
next decfsz ii
,F,; decrement loop count
bra i_loop
nop
array db 0x00
,0x01,0x30,0x03,0x04,0x05,0x06,0x07,0x08,0x09
db 0x0A
,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13
db 0x14
,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D
db 0x1E
,0x1F
end




Post a reply
  Related Posts  to : find out the number of elements in an array of 8-bit element
 find the largest element stored in the array     -  
 code to find a number all divisors using recursion     -  
 Pop the element off the end of array     -  
 Add elements to the end of an array     -  
 UnSet array element     -  
 Array element navigation     -  
 access element in array C++     -  
 Elements of the enumerated array are numbers     -  
 Return an array with elements in reverse order     -  
 Removing elements from array list with the iterator     -