Mon May 13, 2013 11:58 pm
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,A ; initialize loop count i to 0
again movlw n-1 ; number of comparisons to be made
; the next instruction implements the condition C (i = n)
cpfslt i,A ; 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,A ; is arr_max > arr[i]?
bra replace ; no
bra next_i ; yes
replace movwf arr_max,A ; update the array max
next_i incf i,F,A
goto again
done nop
end
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
Powered by phpBB © phpBB Group.