assembly - Modified 6502 Interrupt Returns -
i trying switch normal program flow while interrupt returns:
start sei ldx #<irq ldy #>irq stx $fffe sty $ffff cli loop1 inc $d020 jmp loop1 loop2 inc $d021 jmp loop2 irq sta savea+1 stx savex+1 sty savey+1 // routines lda #$00 pha lda #<loop2 pha lda #>loop2 pha savea lda #$00 savex ldx #$00 savey ldy #$00 rti
i wrote code accourding source: http://6502.org/tutorials/interrupts.html#1.3
but pha's cause crash, how switch normal flow loop1 loop2 in interrupt?
the simplest thing have 2 stack areas -- 1 every task. $100-$17f , $180-$1ff, example. then, have interrupt task switching code this:
pha txa pha tya pha ;saving task's registers on stack, ;where flags , pc saved ;by entering interrupt tsx stx ... ;save task's stack position ... ;select new task run/etc. ldx ... txs ;load other task's stack position pla tay pla tax pla ;restore other task's registers rti ;and continue other task
Comments
Post a Comment