Advertisements
Advertisements
प्रश्न
Write an Assembly Language Program to count the number of even data bytes occurring in a block stored from memory location CO30H to CO37H. Store the count at memory location CO38H.
कोड लेखन
Advertisements
उत्तर
; 8085 Assembly Language Program
; Logic: Count even data bytes in a memory block
LABEL MNEMONICS COMMENTS
MVI C, 00H ; clear C reg (Count of even numbers)
MVI B, 07H ; set B = 07H (Loop counter)
LXI H, C030H ; set HL = C030H (Starting address)
rep: MOV A, M ; get M to A (Read data from memory)
RRC ; rotate A to right (Check LSB in Carry Flag)
JC next ; jump, if carry to next (If Carry=1, number is Odd)
INR C ; increment C (If Carry=0, number is Even)
next: INX H ; increment HL (Point to next memory location)
DCR B ; decrement B (Decrease loop counter)
JNZ rep ; jump, if no zero to rep. (Continue if B != 0)
MOV A, C ; get C to A (Move final count to Accumulator)
STA C038H ; store A at C038H (Save result)
HLT ; stop programshaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2023-2024 (July) Official Board Paper
