# HG changeset patch # User Paul Boddie # Date 1439816126 -7200 # Node ID 1cbf83f55fcc5ff39fbc16c798fcced15912ad08 # Parent 8460f118146c1654f5b95b96643cfa32ba83edce Access the original value of A in the handler, not the version corrupted by Acorn's interrupt handler mechanism. Made the first and second test tasks more illustrative. Simplified the third task slightly. diff -r 8460f118146c -r 1cbf83f55fcc switcher.oph --- a/switcher.oph Mon Aug 17 01:03:14 2015 +0200 +++ b/switcher.oph Mon Aug 17 14:55:26 2015 +0200 @@ -142,6 +142,7 @@ ; affects: (temporary stack usage) handler: + lda $fc ; obtain the original value of A pha ; A -> stack txa pha ; X -> stack @@ -171,9 +172,9 @@ ; obtain the stack location of the stored PC MSB ldy #7 ; offset of MSB (_, _, Y, X, A, F, LSB, MSB) - lda (SP), y ; reference the stack location and compute PC MSB & $80 + lda (SP), y and #$80 cmp #$80 @@ -281,6 +282,7 @@ pla tax ; stack -> X pla ; stack -> A + sta $fc ; override the default handler's restoration of A jmp (old_handler) @@ -384,8 +386,16 @@ first_task_start: lda #1 sta $7000 + lda #0 + sta $7001 first_task_continue: - inc $7000 + clc + lda $7000 + adc #1 + sta $7000 + lda $7001 + adc #0 + sta $7001 jmp first_task_continue @@ -400,8 +410,16 @@ second_task_start: lda #1 sta $7010 + lda #0 + sta $7011 second_task_continue: - inc $7010 + clc + lda $7010 + adc #1 + sta $7010 + lda $7011 + adc #0 + sta $7011 jmp second_task_continue @@ -418,11 +436,8 @@ * stx $7028 .invoke call third_task_delay, + * txa - .invoke pushA .invoke call remove_task, + -* .invoke pullA - tax - inx ; move to next offset +* inx ; move to next offset inx ; which is 2 locations away cpx #TASK_TABLE_LENGTH beq +