English

Write an Assembly Language Program to find the largest number in a block of memory locations begins from 2400H, block length is stored at 23 FFH. Store the largest number after the end of the block.

Advertisements

Question

Write an Assembly Language Program to find the largest number in a block of memory locations begins from 2400H, block length is stored at 23 FFH. Store the largest number after the end of the block.

Code Writing
Advertisements

Solution

Label            Instruction                                            Comments

START:  LXI H, 23FFH     ; Address for count in HL pair
        MOV C, M         ; Get count in register C
        SUB A            ; Clear accumulator

LOOP:   INX H            ; Go to next memory location
        CMP M            ; Compare memory with accumulator
        JNC AHEAD        ; If A ≥ M, jump to AHEAD
        MOV A, M         ; Get larger number in accumulator

AHEAD:  DCR C            ; Decrement count
        JNZ LOOP         ; Repeat loop if count not zero
        INX H            ; Increment memory location
        MOV M, A         ; Store result in memory

END:    HLT              ; Stop execution
shaalaa.com
  Is there an error in this question or solution?
2022-2023 (March) Official
Advertisements
Share
Notifications



      Forgot password?
Use app×