Total members 11872 |It is currently Sun Jan 29, 2023 8:20 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  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     -  
 Add elements to the end of an array     -  
 Pop the element off the end of array     -  
 access element in array C++     -  
 UnSet array element     -  
 Array element navigation     -  
 Elements of the enumerated array are numbers     -  
 Return an array with elements in reverse order     -  
 Removing elements from array list with the iterator     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com