Data Transfer
Data Transfer
Result:
Before Execution:
After Execution:
After Execution:
Let N = 06h
mov r3,#6 //length of the array
mov dptr,#4000H //starting address of array
movx a,@dptr
mov r1,a
Result:
Before Execution:
After Execution:
Let N = 06h
mov r0,#05H //count (N-1) array size = N
loop1: mov dptr, #9000h //array stored from address 9000h
mov r1,#05h //initialize exchange counter
loop2: movx a, @dptr //get number from array and store in B register
mov b, a
inc dptr
movx a, @dptr //next number in the array
clr c //reset borrow flag
mov r2, a //store in R2
subb a, b //2nd-1st No, since no compare instruction in 8051
jnc noexchg // JC - FOR DESCENDING ORDER
mov a,b //exchange the 2 nos in the array
movx @dptr,a
dec dpl //DEC DPTR - instruction not present
mov a,r2
movx @dptr,a
inc dptr
Result:
Before Execution:
Note:
Analyze the bubble sort algorithm for the given data. Also try with different sorting
algorithms.