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