Total members 11791 |It is currently Sat Aug 17, 2019 4:32 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





find the largest element stored in the array

Code:

arr_max equ 0x00
i equ 0x01
n equ D
'80' ; the array count
#include <p18F8720.inc>
org 0x00
goto start
org 0x08
retfie
org 0x18
retfie
start movff 0x10
,arr_max ; set arr[0] as the initial array max
lfsr FSR0
,0x11 ; place address of arr[1] in FSR0
clrf i
,; initialize loop count i to 0
again movlw n
-; number of comparisons to be made
; the next instruction implements the condition C (= n)
cpfslt i,; skip if i < n-1
bra done 
; all comparisons have been done
; the following 7 instructions update the array max
movf POSTINC0
,W

cpfsgt arr_max
,; is arr_max > arr[i]?
bra replace ; no
bra next_i 
; yes
replace movwf arr_max
,; update the array max
next_i incf i
,F,A
goto again
done nop
end





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

  Related Posts  to : find the largest element stored in the array
 find out the number of elements in an array of 8-bit element     -  
 Pop the element off the end of array     -  
 Array element navigation     -  
 access element in array C++     -  
 UnSet array element     -  
 finding the largest integer     -  
 Plug In to the Web at India's Largest Adobe Conference     -  
 Array difference for associate array     -  
 Find MAC Address     -  
 Find entity by id     -  









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