Microprocessor 8085 Old Questions TU Nepal

1) Find the greatest number in an array. First data represents the size of the array.

         LXI H,3200H        // set memory pointer to array whose first data is its size
         MOV A,M            // load array size from memory
         CPI 00H             // check if array size is 00H
         JZ ZEROSIZE       // if array size is zero move to halt program
         MOV B,A           // move size to reg B as counter
         INX H            // increment memory pointer
         MOV A,M          // move first data of array to reg A, consider it to be maximum

LOOP:    DCR B            // decrease counter
         JZ LOOPFINISH    // if counter is zero stop loop
         INX H            // increase memory pointer
         CMP M            // compare current max with new array element
         JNC CONTINUE    // if new data is greater CY will be set, if CY set update current
                             max in reg A else leave it
         MOV A,M


LOOPFINISH:STA 3206H      // store max in memory from reg A

ZEROSIZE:  HLT           // terminate the program

Pages: 1 2 3 4


Post a Comment

Need Help? Make a comment below & we'll help you out... :)

Popular posts from this blog

How to write a cover letter to register free .com.np in Nepal

Add a Comment Form Message on Blogger

How to Activate Windows Free of Cost