Author Topic: QuickSort algorithm  (Read 463 times)

jj2007

  • Member
  • *****
  • Posts: 10678
  • Assembler is fun ;-)
    • MasmBasic
Re: QuickSort algorithm
« Reply #15 on: October 09, 2020, 02:37:48 AM »
 :thumbsup:
Code: [Select]
mov rsi,offset array1 ; In this example, we'll use
mov rdi,offset indx   ; RSI and RDI to point to bases of arrays

;call the QuickSort procedure
mov rcx,30 ; array of 30 elements
mov rdx,offset indx
mov r8,loadValueToCmp ; load pointer to procedure
mov r9, offset isItLess ; load pointer to procedure
mov r10, offset isItMore ; load pointer to procedure
SortAny proto
call SortAny ; somewhere in here appears my stack misaligned at... message; the procs!
;result in 'indx' or at [RDI]
...
Code: [Select]
  xor rbx, rbx
  .Repeat
mov rax, offset indx
lea rax, [rax+4*rbx]
mov eax, [rax]
Print Str$(" \nRes=%i", eax)
inc rbx
  .Until rbx>=30
Code: [Select]
Res=29
Res=28
Res=27
Res=26
Res=25
Res=24
Res=23
Res=22
Res=21
Res=20
Res=19
Res=18
Res=17
Res=16
Res=15
Res=14
Res=13
Res=12
Res=11
Res=10
Res=9
Res=8
Res=7
Res=6
Res=5
Res=4
Res=3
Res=2
Res=1
Res=0

i Z !

  • Member
  • **
  • Posts: 125
    • Customizable digital arts
Re: QuickSort algorithm
« Reply #16 on: October 09, 2020, 10:44:04 AM »
:thumbsup:

That's great, thanks. I might use your code for printing out in my next examples.

To anyone interested, I've added an example for sorting REAL8 values in my "example post" (the 3rd post in this topic)
I bit a bit,
got bites from bytes.
I'll ram'em back in their RAM
and machine-gun the shit out of their f*in machine...

Try out my Automatized ASM Editor for Windows 10 for 30 days. Also visit silverfox.systems/ace!

i Z !

  • Member
  • **
  • Posts: 125
    • Customizable digital arts
v4
« Reply #17 on: October 10, 2020, 11:21:49 PM »
Corrections and performance improvements in v4. Examples also added to my first post.
« Last Edit: October 11, 2020, 05:44:21 PM by i Z ! »
I bit a bit,
got bites from bytes.
I'll ram'em back in their RAM
and machine-gun the shit out of their f*in machine...

Try out my Automatized ASM Editor for Windows 10 for 30 days. Also visit silverfox.systems/ace!