Dstats equ 0403h ctask equ 06h cmask equ 07h putmap equ 0806h monitor equ 0812h trapadd equ 0400h astore equ 01eh in0 equ 0db00h switch equ 0402h window equ 0625h super equ 01h mask equ 0403h t1mask equ 021h t1pc equ 015h restor equ 0815h warm equ 0 ; Routine checks for the R10 trap during writes WR10: halt halt ld hl,sup1 ld (super),hl ld a,19h ld (mask),a ld (t1mask),a ld a,07h ld (window),a ld hl,T1 ld (t1pc),hl jp restor T1: ld (2000h),a jp warm sup1: ld hl,monitor ld (super),hl ld a,03 ld (window),a ld a,(stats) cp 0ffh jp nz,monitor jp restor ; Routine checks for r10 traps during reads rr10: halt halt ld hl,sup2 ld (super),hl ld a,19h ld (t1mask),a ld a,07h ld (window),a ld hl,t2 ld (t1pc),hl Š jp restor t2: ld a,(2000h) jp warm sup2: ld hl,monitor ld (super),hl ld a,03 ld (window),a ld a,(stats) cp 07fh jp nz,monitor jp restor xr10: halt halt ld hl,sup3 ld (super),hl ld a,19h ld (t1mask),a ld a,7 ld (window),a ld hl,t3 ld (t1pc),hl ld a,076h ld (2000h),a jp restor t3: jp 2000h jp warm sup3: ld hl,monitor ld (super),hl ld a,3 ld (window),a ld a,(stats) cp 07fh jp nz,monitor jp restor ; routine checks the stop trap stop: halt halt ld hl,sup4 ld (super),hl ld a,18h ld (t1mask),a ld hl,t4 jp restor t4: jp t4 jp warm sup4: ld hl,monitor ld (super),hl ld a,(stats) cp 0afh ld a,019h ld (t1mask),a Š jp nz,monitor jp restor ; routine checks the auxilliary trap trpaux: halt halt ld hl,sup5 ld (super),hl ld a,01bh ld (t1mask),a ld hl,t5 ld (t1pc),hl jp restor t5: jp test jp warm sup5: ld hl,monitor ld (super),hl ld a,(stats) cp 09fh ld a,019h ld (t1mask),a jp nz,monitor jp restor ; routine checks the halt trap halt: halt halt ld a,(stats) cp 0bbh jp nz,monitor ld hl,0 ld (t1pc),hl ld a,019h ld (t1mask),a jp restor ; Routine checks the interrupt trap tint: halt halt ld hl,sup6 ld (super),hl ld a,01dh ld (t1mask),a ld hl,t6 ld (t1pc),hl jp restor t6: jp t6 jp warm sup6: ld hl,monitor ld (super),hl ld a,(stats) Š cp 0b7h ld a,019h ld (t1mask),a jp nz,monitor jp restor ; routine checks the interrupt pending bit tintpend: halt halt ld hl,sup7 ld (super),hl ld a,01ah ld (t1mask),a ld hl,t7 ld (t1pc),hl jp restor t7: jp t7 jp warm sup7: ld hl,monitor ld (super),hl ld a,(stats) cp 0b7h jp nz,monitor ld a,(switch) bit 1,a jp nz,restor jp monitor ; checks the trap address register trapadd: halt halt ld hl,sup8 ld (super),hl ld a,059h ld (t1mask),a ld hl,5000h ld (t1pc),hl ld a,055h ld (astore),a ld hl,in0 ld (5000h),hl ld (0a000h),hl jp restor sup8: ld a,(trapadd) cp 055h jp nz,test8 ld hl,0a00h ld (t1pc),hl ld a,0aah ld (astore),a Š jp restor test8: cp 0aah ld hl,warm ld (t1pc),hl ld hl,monitor ld (super),hl ld a,019h ld (t1mask),a jp nz,monitor jp restor ; checks traps on illegal input operations input: halt halt ld hl,sup9 ld (super),hl ld a,059h ld (t1mask),a ld hl,t9 ld (t1pc),hl jp restor t9: in a,0 jp warm sup9: ld hl,monitor ld (super),hl ld a,(stats) cp 03ch ld a,019h ld (t1mask),a jp nz,monitor jp restor ; checks for traps on illegal output instructions output: halt halt ld hl,supA ld (super),hl ld a,059h ld (t1mask),a ld hl,tA ld (t1pc),hl jp restor tA: out (0),a jp warm supA: ld hl,monitor ld (super),hl ld a,(stats) cp 0bch ld a,019h ld (t1mask),a jp nz,monitor jp restor Š ; checks to see if xtnd z80 codes cause a halt trap ztrap: ld hl,tB ld (t1pc),hl jp restor tB: bit 6,(hl) jp warm halt ; checks for correct readonly protection rdonly: halt halt ld a,1 ld (window),a ld hl,tC ld (t1pc),hl jp restor tC: ld a,(2000h) jp warm ld (2000h),a jp warm supC: ld hl,monitor ld (super),hl ld a,3 ld (window),a ld a,(stats) cp 0beh jp nz,monitor jp restor ; check no access attribute trap noaccess: halt halt ld hl,supD ld (super),hl ld a,19 ld (t1mask),a ld a,0 ld (window),a ld hl,notest1 ld (t1pc),hl jp restor notest1: ld a,(2000h) jp warm notest2: ld (2000h),a jp warm Šnotest3: jp 2000h jp warm supD: ld a,(stats) cp 03eh jp nz,next ld hl,notest1 ld (t1pc),hl jp restor next: cp 0beh jp nz,next1 ld hl,notest2 ld (t1pc),hl ld hl,last ld (super),hl jp restor next1: ld a,3 ld (window),a ld hl,monitor ld (super),hl jp monitor last: ld a,(stats) cp 03eh ld a,3 ld (window),a ld hl,warm ld (t1pc),hl ld hl,monitor ld (super),hl jp nz,monitor jp restor ; Routine swaps to the next highest task... ; be sure to initialize the pc save areas ; before jumping to a new task!! swap: halt halt ld a,(ctask) cp 0fh jr nz,swap1 ld a,1 ld (ctask),a jp restor swap1: inc a ld (ctask),a jp restor ; fill the maps and pc save areas for all tasks filmap0: halt halt Š ld a,0 loop1: ld b,a ld c,3 loop0: call putmap inc a ld b,a bit 4,b jr nz,loop0 cp 0 jr nz,loop1 ld de,19h ld hl,t1pc ld b,0 ld a,(switch) and 0f8h ld c,1 loop2 ld (hl),b inc hl ld (hl),a add hl,de inc c bit 4,c jr z,loop2 ld a,19h ld hl,t1mask ld de,01ah ld c,-1 loop3 ld (hl),a add hl,de inc c bit 4,c jr z,loop3 ld a,1 ld (ctask),a ld hl,warm ld (t1pc),hl jp restor ; check exec only attribute trap xonly: halt halt ld hl,supE ld (super),hl ld a,2 ld (window),a ld hl,x1 ld (t1pc),hl jp restor x1: ld a,(2000h) jp warm x2: ld (2000h),a jp warm x3: jp 2000h Š supE: ld a,(stats) cp 03eh jp nz,xtest1 ld hl,x1 ld (t1pc),hl jp restor xtest1: cp 0beh jp nz,xtest2 ld hl,x2 ld (t1pc),hl jp restor xtest2: ld a,3 ld (window),a ld hl,monitor ld (super),hl jp monitor .phase 2000h halt halt ld a,3 ld (window),a ld hl,warm ld (t1pc),hl jp restor