programa11.doc

2
Microprocessor 8085 Appendix A ØØ Explanation : We are given two BCD numbers at memory locations D000 H and D001 H. Let these numbers be 02 H and 09 H. We have to add the byte at memory location D000 H (02 H) with the byte at memory location D001 H (09 H). Initially we will store the first number in the accumulator. Using ADD instruction add the two contents. Result of addition will be stored in the A register. Using DAA adjust the result to valid BCD number. Store the result at memory location D002 H. For example : D000 H = 02 H 02 H D001 H = 09 H + 09 H DAA 0B H (invalid BCD) + 06 H 11 H ( valid BCD) ØØ Algorithm : Step I : Start Step II : Get the first number in A register. Step III : Get the second number in memory. Step IV : Add the two numbers. Step V : Store the result at memory location D002 H Step VI : Stop ØØ Flowchart : Refer flowchart 13. Program : 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 13

Upload: manpreet-kaur

Post on 19-Aug-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Microprocessor 8085 Appendix A Explanation : We are given two BCD numbers at memory locations D000 H and D001 H. Let these numbers be 02H and 09 H. We have to add the byte at memory location D000 H 02 H! with the byte at memory location D001H 09 H!. "nitially we will store the #irst number in the accumulator. $sing %DD instruction add the two contents. &esult o# addition will be stored in the % register. $sing D%% ad'ust the result to valid BCD number. (tore the result at memory location D002 H.)or e*am+le , D000 H- 02 H 02 HD001 H- 09 H . 09 HD%% 0B H invalid BCD! . 0/H11Hvalid BCD! Algorithm :Step I :(tartStep II : 0et the #irst number in % register.Step III: 0et the second number in memory.Step IV : %dd the two numbers.Step V : (tore the result at memory location D002 HStep VI : (to+ Flowchart : &e#er #lowchart 11. Program :Instruction CommentLXI H,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 Flowchart 13ADDM ; A # A $M i.e. compute the a%%itionDAA ; &on'ert the H(X to 'ali% )&D result.IXH ; Increment HL to point to ne!t memory ; location i.e. D00*HMOVM, A; +tore the result at memory location ; D00* HHL, ; ,erminate thee!ecution of pro-ram