8051 Programs for Sorting

Programs for Sorting

THEORY:

  • The sorting technique used here is relatively simple. First consider the first two numbers of the array.

INPUT:

  • 8600        05H, 08H, 07H, 06H, 04H

OUTPUT:

  • 8600      04H, 05H, 06H, 07H, 08H      

PROGRAM:

ADDRESSOPCODEMNEMONICSCOMMENDS
850078 05MOV R0,#05 
8502E8LOOP3:     MOV A,R0 
8503F9MOV R1,A 
850490 86 00MOV DPTR,#8600 
8507C0 83LOOP2:     PUSH DPH 
8509C0 82PUSH DPL 
850BE0MOVX A,@DPTR 
850CF5 F0MOV F0,A 
850EA3INC DPTR 
850FE0MOVX A,@DPTR 
8510B5 F0 00CJNE A,F0,LOOP1 
851350 09LOOP1:      JNC LOOP 
8515D0 82POP DPL 
8517D0 83POP DPH 
8519F0MOVX @DPTR,A 
851AA3INC DPTR 
851BE5 F0MOV A,F0 
851DF0MOVX @DPTR,A 
851ED9 E7LOOP:        DJNZ R1,LOOP2 
8520D8 E0DJNZ R0,LOOP3 
852280 FEHERE:        SJMP  HERE 

You may also like...

error: Content is protected !!