exam2study - ; Exam2study, EE319K Fall 2007 ; Instructor:...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
; Exam2study, EE319K Fall 2007 ; Instructor: Jonathan W. Valvano org $3800 ; Globals go in RAM ;****PUT YOUR GLOBAL VARIABLES HERE******* size rmb 1 size2 rmb 2 total rmb 2 org $4000 ; object code goes in ROM ;************************************************************* ;format 8-bit unsigned, first entry is size Data1 fcb 5 , 50 , 100 , 75 , 225 , 50 ; Max1=225,Ave1=100,Cnt1=2 data1end rmb 0 ; find the maximum value ; Input parameter: RegY points to array ; Output parameter: RegA maximum value ; Error conditions: none Max1 ldaa # 0 ; A will be max value loop maxa 1 ,y+ cpy # data1end bne loop rts ; find the average value ; Input parameter: RegY points to array ; Output parameter: RegA average value ; Error conditions: none Ave1 pshy ldaa 1 ,y+ ; set a to be the counter ldx # 0 ; initialize x to 0 loop1 ldab 1 ,y+ ; add the 1st value and store the total in x abx deca beq done bra loop1 done ldd # 0 puly ldab 0 ,y ; get the size in b exg x,d idiv tfr x,a rts ; Count the number of 50's ; Input parameter: RegY points to array ; Output parameter: RegA number of 50's ; Error conditions: none Cnt1 ldx # 0 ; initialize x to 0 to hold our count of 50's until the end ldab 1 ,y+ ; use b as a counter 1loop ldaa 1 ,y+ ; load the 1st element of the array (after the size)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
cmpa # 50 ; check if it's #50 beq count ; if it is 50 then branch and increment out count decb ; decrement our subroutine counter beq endcnt1 ; When it's down to 0 then we've checked the entire array bra 1loop ; inifite loop to continuously check for #50s count inx ; increment the #50 counter decb ; decrement our subroutine counter beq endcnt1 ; When it's down to 0 then we've checked the entire array bra 1loop ; infinite loop to continuously check for #50s endcnt1 tfr X,A ; transfer the #50 counter into RegA rts ;************************************************************* ;format 8-bit signed, first entry is size Data2 fcb 5 , -50 , 100 , -75 , -50 , 50 ; Max2=100,Ave2=-5,Cnt2=3 data2end rmb
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

exam2study - ; Exam2study, EE319K Fall 2007 ; Instructor:...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online