Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Algoritmi - Bubble sort non funziona
Forum - Algoritmi - Bubble sort non funziona

Avatar
drew (Normal User)
Newbie


Messaggi: 13
Iscritto: 22/03/2011

Segnala al moderatore
Postato alle 0:10
Sabato, 23/04/2011
Questo topic è stato chiuso dal moderatore

Ho apportato qualche modifica all'algoritmo BubbleSort, dividendo l'array da ordinare in n array costituiti da 10 elementi. Il codice dovrebbe ordinare prima gli n array e poi tutto l'array principale e mostrarne il contenuto, ma non ottengo alcun risultato. Qualche suggerimento?



Codice sorgente - presumibilmente Delphi

  1. .data
  2. array SDWORD 10 DUP(10009h, 10002h, 10003h, 10004h, 10001h, 10006h, 10007h, 10008h, 10005h, 10010h)
  3. len DWORD lengthof array
  4.  
  5. .code
  6. MAIN PROC
  7. INVOKE BBSORT, ADDR array, len
  8. mov esi, offset array
  9. call Funzione che visualizza parte della memoria
  10. MAIN ENDP
  11.  
  12. BBSORT PROC USES eax ecx esi, aarr: PTR SDWORD, larr: DWORD
  13. LOCAL part: DWORD, cloop: BYTE
  14. mov edx, 0
  15. mov eax, larr
  16. mov ebx, 10
  17. div ebx
  18. mov ecx, 2
  19. push edx
  20. mov part, 0
  21. mov cloop, 0
  22. lp:
  23. push ecx
  24. mov eax, 0
  25. cmp part, 0
  26. je ls  
  27. mov edx, 0
  28. mov eax, part
  29. mul ebx
  30. shl eax, 2
  31. mov edx, eax
  32. ls:
  33. dec ecx
  34. cmp ecx, 0
  35. je lr
  36. l1:
  37. push ecx
  38. mov ecx, ebx
  39. dec ecx
  40. mov esi, aarr
  41. add esi, edx
  42. l2:
  43. call DumpRegs
  44. mov eax, [esi]
  45. cmp [esi + 4], eax
  46. jg l3
  47. xchg eax, [esi + 4]
  48. mov [esi], eax
  49. l3:
  50. add esi, 4
  51. loop l2
  52. pop ecx
  53. loop l1
  54. mov esi, aarr
  55. add esi, edx
  56. inc part
  57. pop ecx
  58. loop lp
  59. jmp lr
  60. cmp cloop, 2
  61. je lr
  62. cmp cloop, 1
  63. je la
  64. pop edx
  65. mov ecx, edx
  66. mov part, 0
  67. mov cloop, 1
  68. jmp lp
  69. la:
  70. mov ecx, 100
  71. mov part, 0
  72. mov cloop, 2
  73. jmp lp
  74. lr:
  75. ret
  76. BBSORT ENDP


PM
Avatar
pierotofy (Admin)
Guru^2


Messaggi: 6230
Iscritto: 04/12/2003

Up
0
Down
V
Segnala al moderatore
Postato alle 4:12
Sabato, 23/04/2011


Il mio blog: https://piero.dev
PM