HSC Science (Computer Science) 12th Board ExamMaharashtra State Board
Share

Books Shortlist

# Write an Assembly Language Program to add two 8-bits BCD numbers stored at memory location 4500 Hand 4501 H. Store the two byte BCD result from memory location· 4502 H onwards. - HSC Science (Computer Science) 12th Board Exam - Computer Science 2

ConceptInstruction Set and Programming of 8085

#### Question

Write an Assembly Language Program to add two 8-bits BCD numbers stored at memory location 4500 Hand 4501 H. Store the two byte BCD result from memory location· 4502 H onwards.

#### Solution

 Label Mnemonics Comments START : LXI H, 4500 ; Initialize HL pair to memory address 4500 H MVI B, 00H ; Initialize register to store MSB of sum MOV A, M ; Move first  number in accumulator INX H ; Get address of next number ADD M ; Add next number to accumulator DAA ; Decimal adjust  accumulator JNC L1 ; In carry ? No, jump to label L1 INR B ; Increment register B L1 : INX H ; Increment HL pair by 1 MOV M, A ; Store LSB o f Sum in memory MOV A, B ; Move MSB of Sum in accumula tor INX H ; Increment HL pair by 1 MOV M, A ; Store MSB of Sum in memory END : RST 1.0 ; Restart
Is there an error in this question or solution?

#### APPEARS IN

2016-2017 (March) (with solutions)
Question 5.1.2 | 5.00 marks
Solution Write an Assembly Language Program to add two 8-bits BCD numbers stored at memory location 4500 Hand 4501 H. Store the two byte BCD result from memory location· 4502 H onwards. Concept: Instruction Set and Programming of 8085.
S