programa6.doc

2
Microprocessor 8085 Appendix A Explanation : We are given two 16 bit numbers at memory locations D000 H, D001 H and D002 H, D003 H. Let these numbers be 1234 H and 0100 H. We have to subtract the word at memory locations D000 H and D001 H (1234 H) from the word at memory locations D002 H and D003 H (0100 H). We subtract the two LSBs and the two MSB separately. Store the result at memory locations D004 H and D005 H. Algorithm : Step I : Start Step II : Get the LSB of first 16 bit number in A. Step III : Get the MSB of the first number in register B. Step IV : Get the LSB of the second number in register C Step V : Get the MSB of the second number in register D Step VI : Subtract the LSB of two numbers. Step VII : Store the result of LSB subtraction in register L. Step VIII : Load the MSB of the first number in accumulator. Step IX : Subtract the MSB of two numbers. Step X : Store the result of MSB subtraction in register H. Step XI : Store the result at memory locations D004 H and D005 H. Step XII : Stop. Flowchart : Refer flowchart 8. Program 1 : Instruction Comment LXI H, D000 H ; HL points to the memory ; location D000 H MOV A, M ; Get the contents of location ; D000 H into the accumulator. INX H ; Increment HL to point to next ; memory location i.e. D001H Flowchart 8

Upload: manpreet-kaur

Post on 19-Aug-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Microprocessor 8085 Appendix A Explanation : We are given two 16 bit numbers at memory locations D000H, D001 H and D002 H, D003 H. Let these numbers be 123H and 0100 H. WehavetosubtractthewordatmemorylocationsD000HandD001H!123H"#romthewordat memorylocationsD002 H and D003 H !0100 H". We subtract the two L$%s and the two &$% se'arately. $tore the result at memory locations D00 H and D00( H. Algorithm :Step I: $tart Step II : )et the L$% o# #irst 16 bitnumber in *.Step III : )et the &$% o# the #irst number in register %.Step IV: )et the L$% o# the second number in register +Step V: )et the &$% o# the second number in register D Step VI : $ubtractthe L$% o# two numbers.Step VII : $tore the result o# L$% subtraction in register L.Step VIII:Load the &$% o# the #irst number in accumulator.Step IX : $ubtract the &$% o# two numbers.Step X: $tore the result o# &$% subtractionin register H.Step XI: $tore the result at memory locations D00 H and D00( H.Step XII: $to'. Flowchart : ,e#er #lowchart -. Program 1 :Instruction CommentLXIH, D000 H ; HL points to the memory ;location D000 HMOVA, M ; Get the contents of location ; D000 H into the accumulator.IXH ; Increment HL to point to ne!t ; memory location i.e. D00"H Flowchart8MOV#, M; GetthecontentsD00"Hintore$ister#i.e. M%#of &rstnum'er.IXH ; Increment HL to point to ne!t memory location i.e. D00(HMOV), M; Get thecontents D00(Hintore$ister )i.e. L%#of (n*num'er. IXH ; Increment HL to point to ne!t memory location i.e. D00+HMOVD, M; Get the contents D00+ H into re$ister ) i.e. M%# of (n* num'er. %,#) ; )ompute L%# su'tractionA- A . )MOVL, A ; %tore the result in re$ister L.Microprocessor 8085 Appendix AMOVA, #; )opy the contents of M%# of &rst num'er to the accumulator.%,#D ; )ompute M%# su'tractionA- A . DMOVH, A ; %tore the result in re$ister H.%HLD(00/ H ; %toretheresultatmemorylocations(00/Han* (000 H.HL1