Advertisement
moking51

Z80 เรียงลำดับน้อย - มาก

Dec 16th, 2019
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ORG 1800H
  2. START:
  3.     LD    B,10
  4.     LD    HL,1850H
  5.     LD     DE,1860H
  6. START: 1
  7.     LD    A,(HL)
  8.     LD    (DE),A
  9.     DEC     B
  10.     JP    Z,INI
  11.     INC    HE
  12.     INC     DE
  13.     JP    START 1
  14. INI:
  15.     LD    D,9
  16. SORT:
  17.     LD    IX,1860H
  18.     LD    B,09
  19. hee:
  20.     LD    A,(IX+0)
  21.     LD    C(IX+1)
  22.     CP    C
  23.     JP    C,NEXT
  24.     LD    (IX+0),C    ;SWAP
  25.     LD    (IX+1),A
  26. NEXT:
  27.     INC    IX
  28.     DEC    B
  29.     JP    NZ,hee
  30.     DEC    D
  31.     JP    NZ,SORT
  32.     HALT
  33.     ORG 1850H
  34.     DEFB    7
  35.     DEFB    5
  36.     DEFB    6
  37.     DEFB    8
  38.     DEFB    7
  39.     DEFB    4
  40.     DEFB    2
  41.     DEFB    3
  42.     DEFB    1
  43.     DEFB    0
  44.     END START
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement