;variables temp1 ds 1 temp2 ds 1 inc1 ds 2 ap ds 2 swap: clr temp1 clr temp2 clr inc1 clr inc1+1 clr addmem clr addmem+1 cicloswap: mov inc1,addmem mov inc1+1,addmem+1 jsr rdxxx mov datmem,temp1 lda inc1+1 add ap+1 sta addmem+1 lda inc1 adc ap sta addmem jsr rdxxx mov datmem,temp2 mov temp1,datmem jsr wrxxx mov inc1,addmem mov inc1+1,addmem+1 mov temp2,datmem jsr wrxxx lda #$01 add inc1+1 sta inc1+1 lda #$00 adc inc1 sta inc1 lda inc1 cmp ap blt cicloswap lda inc1+1 cmp ap+1 blt cicloswap jsr sndstat rts