Author Topic: Two sort algos.  (Read 4294 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 9726
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Two sort algos.
« on: July 07, 2017, 05:16:27 PM »
I have started to convert some of the simpler sorts from the 32 bit versions to 64 bit MASM, the first is a bubble sort which is about as useful as a hip pocket in a singlet in all but a few specialised instances and an insertion sort which is suitable for small counts, both have their uses in hybrid sort algos that use more than one design, these two are basically "trimmer" algos that address a problem with more complex sorts that handle large data but are a bit clunky on small counts, something common with quick sorts.

I have yet to convert any of the quick sort designs as stack recursion with the Win64 ABI is not immediately a simple task where you can keep dumping stack parameters with each ascending iteration as you could in Win32.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 12930
  • Assembler is fun ;-)
    • MasmBasic
Re: Two sort algos.
« Reply #1 on: July 07, 2017, 06:51:51 PM »
stack recursion with the Win64 ABI is not immediately a simple task where you can keep dumping stack parameters with each ascending iteration as you could in Win32.

As long as you don't call a Windows API inside the sort proc, you can do whatever you want, no?

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 9726
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Two sort algos.
« Reply #2 on: July 07, 2017, 08:28:26 PM »
I have to think about that one, there has to be a way to do it as the shadow space for the registers will persist after each iteration but its likely that there will need to be a lot more stack space.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 12930
  • Assembler is fun ;-)
    • MasmBasic
Re: Two sort algos.
« Reply #3 on: July 07, 2017, 08:56:56 PM »
as the shadow space for the registers will persist

You write an entry proc that handles shadow space according to the ABI but then calls the "real" recursive sort proc with no restrictions.

nidud

  • Member
  • *****
  • Posts: 2388
    • https://github.com/nidud/asmc
Re: Two sort algos.
« Reply #4 on: July 08, 2017, 01:13:38 AM »
deleted
« Last Edit: February 26, 2022, 12:52:43 AM by nidud »