programa20.doc

2
Microprocessor 8085 Appendix A ØØ Explanation : We have an array of N numbers. For e.g. we initialize the count with 5. Also we initialize a pointer to point the elements in the array. We will check for the MSB. If the MSB of number is 1, the number is negative. Increment count for counting the negative numbers. Increment the pointer to point to the next element. Check if MSB is 1. Repeat process till all the numbers are scanned. Store the count of negative numbers. ØØ Algorithm : Step I : Initialize count for number of elements Step II : Get the number. Step III : AND the number with 80H. Step IV : Check if MSB is 1. If yes, goto step V, else goto step VI. Step V : Increment count for counting negative numbers. Step VI : Increment pointer. Step VII : Decrement count. Step VIII : Check for count = 0. If yes, goto step IX else goto step III. Step IX : Store the count for number of negative numbers. Step X : Stop.

Upload: manpreet-kaur

Post on 19-Aug-2015

219 views

Category:

Documents


6 download

TRANSCRIPT

Microprocessor 8085 Appendix A Explanation : Wehaveanarrayof Nnumbers. For e.g. weinitialize the count with 5. Also we initialize a pointer to point the elementsin the array. Wewill checkfor the MS. !f the MSofnumber is "# the number is negative. !ncrement count for counting the negativenumbers. !ncrement the pointer to point to the ne$telement. %heck if MS is ". &epeat process tillall the numbers are scanne'. Store the count of negative numbers. Algorithm : Step I :!nitialize count for number ofelementsStep II: (et the number.Step III: AN) the number with *+,.Step IV: %heckifMSis". !f yes# gotostep -# else goto step -!.Step V: !ncrement count for countingnegative numbers.Step VI: !ncrement pointer.Step VII: )ecrement count.Step VIII : %heck for count . +. !f yes#gotostep !/ else goto step !!!.Step IX: Store the count for number ofnegative numbers.Step X: Stop. Flowchart : &efer flowchart 00. Program : InstructionCommentLDAD000HMOV C,A ; Initialize countMVIB,00 ; Initialize the Negative number count0L!IH,D00"H ; Initialize #ointer to arra$ BAC%& MOVA,M; 'et the numberFlowchart 22ANI(0H; Chec) *or M+B,-+%I. ; Chec) i* M+B"IN/B; Increment negative number count+%I.& IN!H ; Increment #ointerDC/C ; Decrement count,N-BAC% ; I* count 0 re#eatMOV A, B+0A1000H; +tore the re2ultMicroprocessor 8085 Appendix AHL0 ; 0erminate #rogram e3ecution