programa13.doc
TRANSCRIPT
Microprocessor 8085 Appendix A Explanation : We are given a series of numbers.The length of series is stored at memory location D000 H. We willinitialise register C as counter with the length of the series. We will initialise the accumulator with 00 H, so that the sum can be stored in the accumulator. The series begins at D001 H. So, we will initialise H the register !air as memory !ointer to !oint theseries. "sing add instruction, add the contents, of the accumulator with the contents of memory location!ointed by H register !air. The result of this addition will be stored in the # register. Then we will increment H to !oint to ne$t memory location of the series. Decrement the count inregister C. Continue this !rocess till the count is %ero i.e. all the numbers in the series are added. Store the result at memory location &000 H.Example : et D000 ' 0( H i.e. series is of ( numbers. D001 ' 0) HD00* ' 1* HD00+ ' ,- HD00- ' +- HD00( ' 0- H .esult' 0) H / 1* H / ,- H / +- H / 0- H ' C0 H &000 H ' C0 H. Algorithm :Step I : 1nitiali%e the register C with count. Step II : 1nitiali%esumin accumulator ' 0.Step III : 1nitiali%e the !ointer to memory location D001 H i.e. first number of series.Step IV: #dd the numbers in series.Step V: 1ncrement memory !ointer to ne$t memory location.Step VI: Decrement count Step VII: Chec2 if count ' 0, if not goto ste! 13Step VIII : Store the result at memory location &000 H.Step IX: Sto!. Flowchart : .efer flowchart 1(. Program : InstructionCommentLDAD000 ; A = contents of location D000 H MOVC, A ; Initialize counterXRAA ; sum = 0LXIH, D001H ; InitializeHL as memor !ointer ; for t"e seriesL1#ADD M; $%M in A= $%M in A & MI'XH ; Increment !ointerDCRC ; Decrement counter(')L1 ; if counter0 re!eat ST#&000H 4 store the result at memory location &000 H HT 4 Terminate !rogram e$ecution Flowchart 15