home *** CD-ROM | disk | FTP | other *** search
- ;**************************************************************
- ;
- ; crgt.asm
- ;
- ; staff
- ;
- ; 07-05-90
- ;
- ; (C) Texas Instruments Inc., 1992
- ;
- ; Refer to the file 'license.txt' included with this
- ; this package for usage and license information.
- ;
- ;**************************************************************
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; This routine searches through a block of data in the data memory
- ; to store maximum value and the address of that value in memory
- ; locations MAXVAL and MAXADR respectively. The data block could be
- ; of any size defined by the Block Repeat Counter Register (BRCR).
- ;
- ; KEY C5X instructions:
- ;
- ; RPTB repeat a block of code as defined by repeat counter BRCR
- ; CRGT compare ACC to ACCB. Store larger value in both ACC, ACCB
- ; set CARRY flag if a larger than previous large is found
- ; XC execute conditionally (1 or 2 words) if flag (Carry) set
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;
- MAXADR .set 60h
- MAXVAL .set 61h
- .mmregs
- .text
-
- LDP #0 ; point to data page 0
- LAR AR0, #0300h ; AR= data memory addr
- SETC SXM ; set sign extension mode
- LACC #0FFFFh ; load minimum value
- ;;;; Use #07FFFh (largest possible) to check for minimum value
- SACB ; into ACCB
- SPLK #9,BRCR ; rpt cont = 9 for 10 data values
- RPTB endb -1 ; repeat block from here to endb-1
- startb
- LACC * ; load data from <(AR0)> into ACC
- CRGT ; set carry if ACC > previous largest
- ; Use CRLT to find minimum value
- XC #1,C ; save addr if current value > previous largest
- SAR AR0,MAXADR ;
- MAR *+
- endb
- SACL MAXVAL ; save largest which is in ACC & ACCB
-
- .data ; data is expected to be in data ram
- .word 5000
- .word 10000
- .word 320
- .word 3200
- .word -5600
- .word -2105
- .word 2100
- .word 32050
- .word 1000
- .word -1
- .end