English

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
Advertisements

Question

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.

Code Writing
Advertisements

Solution

      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
  Is there an error in this question or solution?
2025-2026 (March) Official Board Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×