MUFFAKHAM JAH COLLEGE OF ENGINEERING & TECHNOLOGY
Exp. No. 13(A)(i)
ASSEMBLY LANGUAGE PROGRAM FOR ASCENDING ORDER OF A GIVEN
NUMBERS
AIM: Write an assembly language program for arranging in ascending/descending order
using keil software (AT89C51).
APPARATUS:
1. Keil software
2. P.C.
PROGRAM FOR ASCENDING ORDER:
MOV R0,#5 ; INITIALIZE COUNTER 1
AGAIN: MOV DPTR,#2000H ; initialize memory pointer
MOV R1,#4 ; initialize counter 2
BACK: MOV R2,DPL ; save lower byte of memory address
MOVX A,@DPTR ; Get the num ber
MOV B,A ; Save the number
INC DPTR ; Increment the memory pointer
MOVX A,@DPTR ; Get the next number
CJNE A,B,n ; If not equal check for greater or less
AJMP SKIP ; Otherwise go to skip
n: JNC SKIP ;If
MOV DPL,R2 ;Exchange
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @dptr,A
SKIP: DJNZ R1,BACK ;If R1 not equal to 0 go to BACK
DJNZ R0,AGAIN ;If R0 not equal to 0 go to AGAIN
RESULT:
Inputs:
x: 0x2000 -- 05h, 02h, 01h, 04h
Output:
x: 0x2000 -- 01h, 02h, 04h, 05h
MICROPROCESSORS & MICROCONTROLERS LAB
MUFFAKHAM JAH COLLEGE OF ENGINEERING & TECHNOLOGY
Exp. No. 13(A)(ii)
ASSEMBLY LANGUAGE PROGRAM FOR DESCENDING ORDER OF A GIVEN
NUMBERS
AIM: Write an assembly language program for arranging in ascending/descending order
using keil software (AT89C51).
APPARATUS:
1. Keil software
2. P.C.
PROGRAM FOR DESCENDING ORDER:
MOV R0,#5 ; INITIALIZE COUNTER 1
AGAIN: MOV DPTR,#2000H ; initialize memory pointer
MOV R1,#4 ; initialize counter 2
BACK: MOV R2,DPL ; save lower byte of memory address
MOVX A,@DPTR ; Get the num ber
MOV B,A ; Save the number
INC DPTR ; Increment the memory pointer
MOVX A,@DPTR ; Get the next number
CJNE A,B,n ; If not equal check for greater or less
AJMP SKIP ; Otherwise go to skip
n: JC SKIP ;If
MOV DPL,R2 ;Exchange
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @dptr,A
SKIP: DJNZ R1,BACK ;If R1 not equal to 0 go to BACK
DJNZ R0,AGAIN ;If R0 not equal to 0 go to AGAIN
RESULT:
Inputs:
x: 0x2000 -- 05h, 02h, 01h, 04h
Output:
x: 0x2000 -- 05h, 04h, 02h, 01h
MICROPROCESSORS & MICROCONTROLERS LAB
MUFFAKHAM JAH COLLEGE OF ENGINEERING & TECHNOLOGY
Exp. No. 13(B)
ASSEMBLY LANGUAGE PROGRAM FOR DATA TRANSFER
AIM: Write an assembly language program for block move from one address to another
address using keil software (AT89C51).
APPARATUS:
1. Keil software
2. P.C.
PROGRAM:
MOV R0,#20H
MOV R1,#30H
MOV R3,#10H
CLR A
AGAIN:MOV A,@R0
MOV @R1,A
INC R0
INC R1
DJNZ R3,AGAIN
END
RESULT:
Inputs:
i: 0x20 -- 01h, 02h, 03h, 04h
Output:
i: 0x30 -- 01h, 02h, 03h, 04h
MICROPROCESSORS & MICROCONTROLERS LAB