******************************************************************************** *2345678911234567892123456789312345678941234567895123456789612345678971234567898 ******************************************************************************** *Name: David DiPaola *File: lessthan16.asm *Due Date: 2/23/2009 *Description: Count the number of values that are < 16 in an array *Input: 5 element array of hex values * No error checking of input *Output Count is stored in variable count *Errors No error checking in this program ******************************************************************************** ********** Constants *********************** ZERO EQU $0000 ;used for clearing registers END EQU $2004 ;number of values that are in the array (base 0) SXTN EQU 16 ;the number we're comparing everything to ********** Variable Declarations *********** ORG $2000 array DB 1,2,16,4,0 ;Array is the address of first value ($2000) count DB $00 ;the quantity of number less than 16 ********** Main **************************** ORG $3000 ;start at $3000 ldd #ZERO ;clear D ldx #array ;load the array jsr LOOP ;start loopin' ******************************************************************************** *2345678911234567892123456789312345678941234567895123456789612345678971234567898 ******************************************************************************** * Thing Name: LOOP * * It loops and stuff 'till, like, that count thing is at that one constant ******************************************************************************** LOOP cpx #END ;are we there yet? bge DONE ;if index >= END, goto DONE bra CNTR ;otherwise, goto COUNT RTLOOP inx ;increment index bra LOOP ;loop... ******************************************************************************** *2345678911234567892123456789312345678941234567895123456789612345678971234567898 ******************************************************************************** * Thing Name: CNTR * * Counts the number of values that are greater than 16 in the array array ******************************************************************************** CNTR ldab 0,X ;load the value to be compared cmpa #SXTN ;compare A with 16 bge RTLOOP ;if A >= 16, return to the loop inc count bra RTLOOP ******************************************************************************** *2345678911234567892123456789312345678941234567895123456789612345678971234567898 ******************************************************************************** * Subroutine Name: DONE * * Basically an SWI ******************************************************************************** DONE SWI ;FIN.