A little while back I wrote some VAT sorting routines, so right now I'm doing a little work as packaging that as a SE and debugging. I've got a bubble sort and a heap sort, but the heap is veery strange and probably extremely buggy. Here's the source for the bubble, if you feel like trying to find bugs.


;=================================Bubble Sort==================================
   ld hl,(ProgPtr)
   res 0,(IY+Asm_Flags2)
   push hl
   ld de,OP1
   call sort_getname
   call getnext
   jr z,bubble_next
   push hl
   ld de,OP2
   call sort_getname
   ld hl,OP1
   ld de,OP2
   call sort_comparename
   pop hl
   jr nc,bubble_next
   pop de
   push de
   call vatswap
   set 0,(IY+Asm_Flags2)
   ld a,'.'
   B_CALL PutC
   pop hl
   call getnext
   jr nz,bubble_start1
   bit 0,(IY+Asm_Flags2)
   jr nz,bubble_start
;hl-> first byte of VAT entry
;name saved to (de)
;kills DE, B, and A
   push hl
   ld de,-6
   add hl,de
   ld b,(hl)
   dec hl
   ld a,(hl)
   ld (de),a
   inc de
   dec hl
   djnz sort_getname1
   pop hl
;HL-> name 1 (printed forwards)
;DE-> name 2
;Carry if name 1 higher alphabetically, otherwise NC
;Kills HL, DE, B, A
   ld a,(de)
   cp (hl)
   jr nc, sort_comparename_name2big
   inc hl
   inc de
   jr sort_comparename

It's ZDS syntax, if you're wondering.
Fair enough, I'll take a look at it at some point and see if I can find bugs.
I know that this is noobish, but what is a bubble?
Actually, that's newbish... much better to be than a n00b.
In this case bubble isn't a noun on its own, but it's a bubble sort. The basic concept is that you go down the things to be sorted and compare one with another. If they're out of order, then swap then. If you make it through the entire pile without swapping any entries, then it's sorted and you're done.
Ok. That makes sense.
I made a modification of a similar routine once, but yours looks much smaller and simpler.
I definitely wouldn't mind seeing some sorting of the programmage....
I have a full-functioned routine in there; it's just disabled atm because I was having a few issues I suspected came from it.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum