Advertisements
Advertisements
प्रश्न
A block of data stored in memory location 3100H and length of the block is stored at 3000H. Write Assembly Language Program to count the data BBH appeared in the given block. Store the count of the memory location at 3100H.
कोड लेखन
Advertisements
उत्तर
MVI D, 00H ; Set D = 00H (count)
LDA 3000H ; Load accumulator with length
MOV B, A ; Copy length to B (counter)
LXI H, 3001H ; Set HL with 3001H
CYCLE: MOV A, M ; Move memory content to accumulator
CPI BBH ; Compare with BBH
JNZ NEXT ; If not equal, jump to NEXT
INR D ; If equal, increment count (D)
NEXT: INX H ; HL = HL + 1 (next memory location)
DCR B ; Decrement counter
JNZ CYCLE ; If B ≠ 0, repeat
MOV A, D ; Move count to accumulator
STA 3100H ; Store count at 3100H
HLT ; Stopshaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
