SHOW:
|
|
- or go back to the newest paste.
| 1 | .model small | |
| 2 | .stack 100h | |
| 3 | .data | |
| 4 | arr dw 5, -14, 9, 2, -5, 90, -60, 0, 3, -8 | |
| 5 | len db 9 | |
| 6 | .code | |
| 7 | entry: | |
| 8 | mov ax, @data | |
| 9 | mov ds, ax | |
| 10 | - | mov es, ax ;10 |
| 10 | + | mov es, ax |
| 11 | mov bx, offset arr | |
| 12 | ||
| 13 | xor ax, ax | |
| 14 | mov al, len | |
| 15 | push ax ;15 | |
| 16 | ||
| 17 | xor cx, cx | |
| 18 | outerloop: | |
| 19 | xor si, si | |
| 20 | - | innerloop: ;20 |
| 20 | + | innerloop: |
| 21 | pop ax | |
| 22 | cmp si, ax | |
| 23 | push ax | |
| 24 | je innerloop_end | |
| 25 | push si | |
| 26 | add si, si | |
| 27 | mov ax, [bx][si] | |
| 28 | add si, 2 | |
| 29 | mov dx, [bx][si] | |
| 30 | cmp ax, dx | |
| 31 | jb end_swap | |
| 32 | swap: | |
| 33 | mov [bx][si], ax | |
| 34 | sub si, 2 | |
| 35 | mov [bx][si], dx | |
| 36 | end_swap: | |
| 37 | pop si | |
| 38 | inc si | |
| 39 | ||
| 40 | jmp innerloop | |
| 41 | ||
| 42 | innerloop_end: | |
| 43 | ||
| 44 | pop ax | |
| 45 | cmp cx, ax | |
| 46 | push ax | |
| 47 | je exit | |
| 48 | inc cx | |
| 49 | jmp outerloop | |
| 50 | ||
| 51 | exit: | |
| 52 | mov ax, 4c00h | |
| 53 | int 21h | |
| 54 | end entry |