Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Group Members
Muharam Ali 14093122-033
M.Zunair 14093122-035
M.Shanawar 14093122-032
Abdul Rauf 14093122-029
Sufian Ahmed ...
Write a program that lets the user type a list of single-digit numbers,
with one blank between numbers, calls BUBBLE to so...
Bubble Sort Example
9, 6, 2, 12, 11, 9, 3, 7
6, 9, 2, 12, 11, 9, 3, 7
6, 2, 9, 12, 11, 9, 3, 7
6, 2, 9, 12, 11, 9, 3, 7
6,...
Bubble Sort Example
6, 2, 9, 11, 9, 3, 7, 122, 6, 9, 11, 9, 3, 7, 122, 6, 9, 9, 11, 3, 7, 122, 6, 9, 9, 3, 11, 7, 122, 6, ...
Bubble Sort Example
2, 6, 9, 9, 3, 7, 11, 122, 6, 9, 3, 9, 7, 11, 122, 6, 9, 3, 7, 9, 11, 12
6, 2, 9, 11, 9, 3, 7, 12
2, 6...
Bubble Sort Example
2, 6, 9, 3, 7, 9, 11, 122, 6, 3, 9, 7, 9, 11, 122, 6, 3, 7, 9, 9, 11, 12
6, 2, 9, 11, 9, 3, 7, 12
2, 6...
Bubble Sort Example
2, 6, 3, 7, 9, 9, 11, 122, 3, 6, 7, 9, 9, 11, 12
6, 2, 9, 11, 9, 3, 7, 12
2, 6, 9, 9, 3, 7, 11, 12
Sec...
Algorithm of Bubble Sort Procedure
SI= Offset address
BX=Array size
 Outer Loop
Set SI=1st Element of Array
Set DI=2nd El...
1. .MODEL SMALL
2. .STACK 100H
3. .DATA
4. MSG1 DB 'enter elements: $'
5. MSG2 DB 'AFTER SORTING: $'
6. ARR DB 100 dup (0)...
14.XOR CX, CX ;clear CX
15.MOV AH,1
16.INT 21H ;first input
17.XOR SI,SI
18.WHILE_:
19. CMP AL, 0dH ;compare input with CR...
30. END_WHILE:
31. MOV AH,2
32. MOV DL,0DH
33. INT 21H
34. MOV DL,0AH
35. INT 21H
36. JCXZ EXIT
37. LEA SI,ARR
38. MOV BX,...
40. MOV AH,9
41. LEA DX,MSG2
42. INT 21H
43. XOR SI,SI
44. TOP:
45. MOV AH,2
46. MOV DL,ARR[SI]
47. INT 21H
48. MOV DL,' '...
1. BUBBLE_SORT PROC
2. ; this procedure will sort the array in ascending
order
3. ; input : SI=offset address of the array...
14.@OUTER_LOOP: ; loop label
15. MOV BX, CX ; set BX=CX
16. MOV SI, AX ; set SI=AX
17. MOV DI, AX ; set DI=AX
18. INC DI ;...
31. POP DI ; pop a value from STACK into DI
32. POP DX ; pop a value from STACK into DX
33. POP CX ; pop a value from STAC...
Output
bubble sorting of an array in 8086 assembly language
bubble sorting of an array in 8086 assembly language
Upcoming SlideShare
Loading in …5
×

of

bubble sorting of an array in 8086 assembly language Slide 1 bubble sorting of an array in 8086 assembly language Slide 2 bubble sorting of an array in 8086 assembly language Slide 3 bubble sorting of an array in 8086 assembly language Slide 4 bubble sorting of an array in 8086 assembly language Slide 5 bubble sorting of an array in 8086 assembly language Slide 6 bubble sorting of an array in 8086 assembly language Slide 7 bubble sorting of an array in 8086 assembly language Slide 8 bubble sorting of an array in 8086 assembly language Slide 9 bubble sorting of an array in 8086 assembly language Slide 10 bubble sorting of an array in 8086 assembly language Slide 11 bubble sorting of an array in 8086 assembly language Slide 12 bubble sorting of an array in 8086 assembly language Slide 13 bubble sorting of an array in 8086 assembly language Slide 14 bubble sorting of an array in 8086 assembly language Slide 15 bubble sorting of an array in 8086 assembly language Slide 16 bubble sorting of an array in 8086 assembly language Slide 17 bubble sorting of an array in 8086 assembly language Slide 18
Upcoming SlideShare
Assembly Language Lecture 1
Next
Download to read offline and view in fullscreen.

3 Likes

Share

Download to read offline

bubble sorting of an array in 8086 assembly language

Download to read offline

assembly language programming and organization of the ibm pc by ytha yu (chapter 10 q.6)

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

bubble sorting of an array in 8086 assembly language

  1. 1. Group Members Muharam Ali 14093122-033 M.Zunair 14093122-035 M.Shanawar 14093122-032 Abdul Rauf 14093122-029 Sufian Ahmed 14093122-031 Rizwan Ali 14093122-036
  2. 2. Write a program that lets the user type a list of single-digit numbers, with one blank between numbers, calls BUBBLE to sort them, and prints the sorted list on the next line. For example: enter elements: 2 5 8 0 1 after sorting: 0 1 2 5 8
  3. 3. Bubble Sort Example 9, 6, 2, 12, 11, 9, 3, 7 6, 9, 2, 12, 11, 9, 3, 7 6, 2, 9, 12, 11, 9, 3, 7 6, 2, 9, 12, 11, 9, 3, 7 6, 2, 9, 11, 12, 9, 3, 7 6, 2, 9, 11, 9, 12, 3, 7 6, 2, 9, 11, 9, 3, 12, 7 6, 2, 9, 11, 9, 3, 7, 12
  4. 4. Bubble Sort Example 6, 2, 9, 11, 9, 3, 7, 122, 6, 9, 11, 9, 3, 7, 122, 6, 9, 9, 11, 3, 7, 122, 6, 9, 9, 3, 11, 7, 122, 6, 9, 9, 3, 7, 11, 12 6, 2, 9, 11, 9, 3, 7, 12 First Pass Second Pass
  5. 5. Bubble Sort Example 2, 6, 9, 9, 3, 7, 11, 122, 6, 9, 3, 9, 7, 11, 122, 6, 9, 3, 7, 9, 11, 12 6, 2, 9, 11, 9, 3, 7, 12 2, 6, 9, 9, 3, 7, 11, 12 Second Pass First Pass Third Pass
  6. 6. Bubble Sort Example 2, 6, 9, 3, 7, 9, 11, 122, 6, 3, 9, 7, 9, 11, 122, 6, 3, 7, 9, 9, 11, 12 6, 2, 9, 11, 9, 3, 7, 12 2, 6, 9, 9, 3, 7, 11, 12 Second Pass First Pass Third Pass 2, 6, 9, 3, 7, 9, 11, 12Fourth Pass
  7. 7. Bubble Sort Example 2, 6, 3, 7, 9, 9, 11, 122, 3, 6, 7, 9, 9, 11, 12 6, 2, 9, 11, 9, 3, 7, 12 2, 6, 9, 9, 3, 7, 11, 12 Second Pass First Pass Third Pass 2, 6, 9, 3, 7, 9, 11, 12Fourth Pass 2, 6, 3, 7, 9, 9, 11, 12Fifth Pass
  8. 8. Algorithm of Bubble Sort Procedure SI= Offset address BX=Array size  Outer Loop Set SI=1st Element of Array Set DI=2nd Element of Array  Inner Loop Compare SI with DI If SI < DI Then jump to SKIP else exchange SI with DI  SKIP: set SI= 2nd element set DI= 3rd element ;jump to label inner loop If BX ! = 0 jump inner loop Loop outer loop
  9. 9. 1. .MODEL SMALL 2. .STACK 100H 3. .DATA 4. MSG1 DB 'enter elements: $' 5. MSG2 DB 'AFTER SORTING: $' 6. ARR DB 100 dup (0) 7. .CODE 8. MAIN PROC 9. MOV AX,@DATA 10.MOV DS,AX 11. MOV AH,9 12.lea DX,MSG1 ;DISPLAY MSG1 13.INT 21H Code
  10. 10. 14.XOR CX, CX ;clear CX 15.MOV AH,1 16.INT 21H ;first input 17.XOR SI,SI 18.WHILE_: 19. CMP AL, 0dH ;compare input with CR 20. JE END_WHILE 21. MOV ARR[SI],AL ;move input into array 22. INC SI ;SI+1 23. INC CX 24. MOV AH,2 25. MOV DL,' ' ;display space 26. INT 21h 27. MOV AH,1 28. INT 21H 29. JMP WHILE_
  11. 11. 30. END_WHILE: 31. MOV AH,2 32. MOV DL,0DH 33. INT 21H 34. MOV DL,0AH 35. INT 21H 36. JCXZ EXIT 37. LEA SI,ARR 38. MOV BX,CX 39. CALL BUBBLE_SORT
  12. 12. 40. MOV AH,9 41. LEA DX,MSG2 42. INT 21H 43. XOR SI,SI 44. TOP: 45. MOV AH,2 46. MOV DL,ARR[SI] 47. INT 21H 48. MOV DL,' ' 49. INT 21H 50. INC SI 51. LOOP TOP 52. EXIT: 53. MOV AH,4CH 54. INT 21H 55. MAIN ENDP
  13. 13. 1. BUBBLE_SORT PROC 2. ; this procedure will sort the array in ascending order 3. ; input : SI=offset address of the array 4. ; : BX=array size 5. ; output : Sorted Array 6. PUSH AX ; push AX onto the STACK 7. PUSH BX ; push BX onto the STACK 8. PUSH CX ; push CX onto the STACK 9. PUSH DX ; push DX onto the STACK 10. PUSH DI ; push DI onto the STACK 11. MOV AX, SI ; set AX=SI 12. MOV CX, BX ; set CX=BX 13. DEC CX ; set CX=CX-1
  14. 14. 14.@OUTER_LOOP: ; loop label 15. MOV BX, CX ; set BX=CX 16. MOV SI, AX ; set SI=AX 17. MOV DI, AX ; set DI=AX 18. INC DI ; set DI=DI+1 19. @INNER_LOOP: ; loop label 20. MOV DL, [SI] ; set DL=[SI] 21. CMP DL, [DI] ; compare DL with [DI] 22. JNG @SKIP_EXCHANGE ; jump to label @SKIP_EXCHANGE if DL<[DI] 23. XCHG DL, [DI] ; set DL=[DI], [DI]=DL 24. MOV [SI], DL ; set [SI]=DL 25. @SKIP_EXCHANGE: ; jump label 26. INC SI ; set SI=SI+1 27. INC DI ; set DI=DI+1 28. DEC BX ; set BX=BX-1 29. JNZ @INNER_LOOP ; jump @INNER_LOOP if BX!=0 30. LOOP @OUTER_LOOP ; jump @OUTER_LOOP while
  15. 15. 31. POP DI ; pop a value from STACK into DI 32. POP DX ; pop a value from STACK into DX 33. POP CX ; pop a value from STACK into CX 34. POP BX ; pop a value from STACK into BX 35. POP AX ; pop a value from STACK into AX 36. RET ; return control to the calling procedure 37. BUBBLE_SORT ENDP 38.END MAIN
  16. 16. Output
  • EimanNoor

    May. 31, 2018
  • SirishaKesagoni

    Apr. 20, 2018
  • chethanravi1

    Mar. 19, 2018

assembly language programming and organization of the ibm pc by ytha yu (chapter 10 q.6)

Views

Total views

19,121

On Slideshare

0

From embeds

0

Number of embeds

7

Actions

Downloads

252

Shares

0

Comments

0

Likes

3

×