Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. .ORG $100
  2. LIST: FCB 11,3,8,7,1,9,-3,4,5
  3. LSTEND: RMB 2 ;reserve byte for list end
  4. NVAL: RMB 2 ;reserve byte for number of values
  5.  
  6. STRT: LDY #lstend ;load address of lstend to y
  7. LEAU -1,y ;load address of y - 1 to register u
  8. STU lstend ;store u to lstend
  9. LEAY -list,y ;load (y - address of list) to register y
  10. STY nval ;store value of y to nval
  11. LEAY -1,y ;load y - 1 to register Y (Decrement y by 1)
  12. LOOP1: LDX #list ;load list to x
  13. LOOP2: LDA ,x+ ;load x+1 to A
  14. CMPA ,x ;compare A with memory
  15. BLS next ;branch if lower or same
  16. LDB ,x ;load x to B
  17. STA ,x ;store A to x
  18. STB -1,x
  19. NEXT: CMPX lstend ;compare x with lstend
  20. BLO loop2 ;branch if carry set (lower)
  21. LEAX -1,x ;load address of x - 1 into register x
  22. STX lstend ;store x to memory
  23. XEND: LEAY -1,y ;load address of y - 1 to reigster y
  24. BNE loop1 ;branch if not equal (y is not equal to 0)
  25. RETN: JMP $D000
  26. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement