Guest User

code golf, bubble sort, 19B, x86-16 asm

a guest
Nov 25th, 2017
219
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bubblesort16:
  2. ;; inputs: pointer in ds:si,  size in in cx
  3. ;; clobbers: al, cx=0
  4.     dec     cx          ; cx = max valid index.  (Inner loop stops 1 before cx, because it loads i and i+1).
  5. .outer:                 ; do{
  6.     push    cx
  7. .inner:                 ;   do{
  8.     lodsb               ;     al = arr[i++]
  9.     cmp     [si],al     ;     compare with arr[i (new one)]
  10.     jge     .noswap
  11.     rol     word [si-1], 8    ; swap
  12. .noswap:
  13.     loop    .inner      ; } while(i < size);
  14.     pop     cx
  15.     sub     si,cx
  16.     loop    .outer      ; while(--size);
  17.     ret
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×