Advertisements
Advertisements
प्रश्न
Write an assembly language program to find smallest number in block which begins from memory location E200H to E210H. Store the result in the accumulator.
कोड लेखन
Advertisements
उत्तर
LXI H, E000H ; Initialize HL pair with the starting address
MVI C, 10H ; Set counter (Assuming block size is 16 elements)*
MOV A, M ; Load the first number into Accumulator (Assume it's the smallest)
LOOP: INX H ; Increment HL to point to the next location
CMP M ; Compare Accumulator with the current memory byte (A - M)
JC SKIP ; If A < M, Carry = 1. Accumulator is already smaller, so skip.
MOV A, M ; If A >= M, the new number is smaller. Update Accumulator.
SKIP: DCR C ; Decrement the counter
JNZ LOOP ; If counter is not zero, repeat the loop
HLT ; Stop. The smallest number remains in the Accumulator.
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
