8051 Smallest Element in an Array

Smallest Element in an Array

THEORY:

  • Let Internal memory location (say 40H) has the biggest number i.e. zero.
  • Now the biggest number in internal memory location is stored in memory as the Result.
  • Now compare the first number with internal memory location. If it is greater, move it to internal memory

INPUT:

  • 8600        05H, 09H, 06H, 05H, 03H     
  • 8605        07H, 0AH, 0BH, 7FH ,04H

OUTPUT:

  • 860A      7FH       

PROGRAM:

ADDRESSOPCODEMNEMONICSCOMMENDS
850090 86 00MOV DPTR,#8600 
850375 40 00MOV 40,#00 
85067D 0AMOV R5,#0A 
8508E0LOOP2: MOVX A,@DPTR 
8509B5  40 08CJNE A,40,LOOP1 
850CA3LOOP3: INC DPTR 
850DDD F9DJNZ R5,LOOP2 
850FE5 40MOV A,40H 
8511F0MOVX @DPTR,A 
851280 FEHLT: SJMP HLT 
851440 F6LOOP1: JNC LOOP3 
8516F5 40MOV 40H,A 
851880 F2SJMP LOOP3 

You may also like...

error: Content is protected !!