SHARE
TWEET

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

a guest Nov 25th, 2017 112 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top