programa4.doc

2
Microprocessor 8085 Appendix A Explanation : We are given two numbers at memory locations D000 H and D001 H. Let these numbers be 50 H and 20 H. We have to subtract the byte at memory location D000 H (50 H) with the byte at memory location D000 H (20 H). Initially we will store the first number in the accumulator. Using SUB instruction subtract the two contents. Result of subtraction will be stored in the A register. Store the result at memory location D002 H. For example : D000 H = 50 H 50 H D001 H = 20 H 20 H 30 H Algorithm : Step I : Start Step II : Get the first number in A register. Step III: Get the second number in memory. Step IV : Subtract the two numbers. Step V : Store the result at memory location D002 H. Step VI : Stop Flowchart : Refer flowchart 5. Program : Instruction Comment LXI H, D000 H ; L 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 SUB M ; A = A – M i.e. compute the subtraction INX H ; Increment HL to point to next memory ; location i.e. D002H MOV M, A ; Store the result at memory location ; D002 H

Upload: manpreet-kaur

Post on 19-Aug-2015

215 views

Category:

Documents


2 download

TRANSCRIPT

Microprocessor 8085 Appendix A Explanation : Wearegiventwonumbers at memorylocationsD000HandD001H. Let thesenumbers be50 H and 20 H. We have to subtract the byte at memory location D000 H (50 H) with the byte at memory locationD000 H (20 H). nitially we will store the !irst number in the accumulator. "sing#"$instructionsubtract the twocontents. %esult o! subtractionwill bestoredinthe& register. #tore the result at memory location D002 H.'or e(am)le * D000 H+ 50 H 50 HD001 H+ 20 H , 20 H-0 H Algorithm :Step I : #tartStep II : .et the !irst number in & register.Step III : .et the second number in memory.Step IV : #ubtract the two numbers.Step V : #tore the result at memory location D002 H.Step VI : #to) Flowchart : %e!er !lowchart 5. Program :InstructionCommentLXIH, D000 H ; L 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#$% M ; A & A ' M i.e. compute the su(tractionIX H ; Increment HL to point to ne!t memory ; location i.e. D00)HMOVM, A ; #tore the result at memory location ; D00) HHL* Flowchart 5