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

View all notifications

A block of data is stored in memory location 4500 H. The length of block is stored in memory location 44FFH. Write Assembly Language Program that searches for the first occurrence of data D9H in given block. Store the address of this occurrence in H.L. pair. If the number is not found then HL. pair should contain 5000 H. - HSC Science (Computer Science) 12th Board Exam - Computer Science 2

Login
Create free account


      Forgot password?

Question

A block of data is stored in memory location 4500 H. The length of block is stored in memory location 44FFH. Write Assembly Language Program that searches for the first occurrence of data D9H in given block. Store the address of this occurrence in H.L. pair. If the number is not found then HL. pair should contain 5000 H.

Solution

Label Mnemonics Comments
  LXI H, 44FFH ; Set H-L pointer to 44FFH
  MOV C, M ; Set count = [44FF]
  MVI A, D9H ; Set [Acc.] = D9 H
Loop : INX H ; [H-L] = [H-L] + 1
  CMP M ; Is [M-L] = D9H ?
  JZ escape ; escape, if [M-L] = D9 H
  DCR C ; count = count - 1
  JNZ Loop ; repeat, if count  0
  LXI H, 5000 H ; Set H-L pair to 5000 if number is not found
escape : RST 1.0 ; Restart
  Is there an error in this question or solution?

APPEARS IN

 2016-2017 (March) (with solutions)
Question 5.2.2 | 5.00 marks
Solution A block of data is stored in memory location 4500 H. The length of block is stored in memory location 44FFH. Write Assembly Language Program that searches for the first occurrence of data D9H in given block. Store the address of this occurrence in H.L. pair. If the number is not found then HL. pair should contain 5000 H. Concept: Instruction Set and Programming of 8085.
S
View in app×