8051- Largest Element in an Array
by
eees.in
·
Largest 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:
PROGRAM:
ADDRESS | OPCODE | MNEMONICS | COMMENDS |
8500 | 90 86 00 | MOV DPTR,#8600 | |
8503 | 75 40 00 | MOV 40,#00 | |
8506 | 7D 0A | MOV R5,#0A | |
8508 | E0 | LOOP2: MOVX A,@DPTR | |
8509 | B5 40 08 | CJNE A,40,LOOP1 | |
850C | A3 | LOOP3: INC DPTR | |
850D | DD F9 | DJNZ R5,LOOP2 | |
850F | E5 40 | MOV A,40H | |
8511 | F0 | MOVX @DPTR,A | |
8512 | 80 FE | HLT: SJMP HLT | |
8514 | 40 F6 | LOOP1: JC LOOP3 | |
8516 | F5 40 | MOV 40H,A | |
8518 | 80 F2 | SJMP LOOP3 | |
Recent Comments