Write an Assembly Language Program to Count the Occurrence of the Data Byte Ach in a Memory Nock Stored from 7401h to 7405h. Store the Count at the Memory Location 7406h.
Advertisements
Question
Write an Assembly Language Program to count the occurrence of the data byte ACH in a memory Nock stored from 7401H to 7405H. Store the count at the memory location 7406H.
Advertisements
Solution
| Label |
Mnemonic + Operand |
Comments |
|
START:
LOOP:
NEXT:
END: |
MVI C, 05H MVI B, 00H LXI H, 7401H MOV A, M CPI ACH JNZ NEXT INR B INX H DCR C JNZ LOOP MOV A, B STA 7406H RST 1.0 |
; Store count 05H in register C ; Initialize occurrence count in register B ; Initialize H-L pair with starting address ; Get the number in the accumulator ; Check whether the number in the accumulator is ACH ; If no? jump to label NEXT ; Yes, increment content in register B by 1 ; Increment H-L pair ; Decrement count ; Is count zero? No-jump to label LOOP ; Get count in accumulator ; Store count of occurrence 7406H ; Restart |
shaalaa.com
Is there an error in this question or solution?
