Quote:
Could you please post your complete minmon.asm and tell me which EhBASIC you are using, mine, Lee's or yours (additional modifications)?
Umm, urr, my "minimon.asm" is 6,000 lines of code (including 3,000 for TinyBasic). I'm trying to evolve it into a multi-tasking kernel. There's very few lines of code required to support EhBASIC though.
I'm using Lee's version of EhBASIC, with a minor modification in startup to set the V_INPT and V_OUTP vectors.
I included the V_INPT and V_OUTP routines in the basic.asm file.
The following is the ISR.
* It could still be a processor bug.
Code:
strStartQue:
db 1,0,0,0,2,0,0,0,3,1,0,0,4,0,0,0
;------------------------------------------------------------------------------
; 100 Hz interrupt
; - takes care of "flashing" the cursor
; - switching tasks
;------------------------------------------------------------------------------
;
p100Hz:
; Handle every other interrupt because 100Hz interrupts may be too fast.
pha
lda IRQFlag
ina
sta IRQFlag
ror
bcc p100Hz11
pla
rti
p100Hz11:
cld ; clear extended precision mode
; save off regs on the stack
phx
phy
push r4
push r5
push r6
push r7
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
ldx TaskNo
and r2,r2,#$FF
tsa ; save off the stack pointer
sta TCB_SPSave,x
tsr sp8,r1 ; and the eight bit mode stack pointer
sta TCB_SP8Save,x
; support EhBASIC's IRQ functionality
; code derived from minimon.asm
lda #3 ; Timer is IRQ #3
sta IrqSource ; stuff a byte indicating the IRQ source for PEEK()
lb r1,IrqBase ; get the IRQ flag byte
ora #$20 ; set IRQ pending bit
sb r1,IrqBase
inc TEXTSCR+83 ; update IRQ live indicator on screen
stz 0xFFDCFFFC ; clear interrupt
; flash the cursor
lda CursorFlash ; test if we want a flashing cursor
beq p100Hz1a
jsr CalcScreenLoc ; compute cursor location in memory
tay
lda $10000,y ; get color code $10000 higher in memory
ldx IRQFlag ; get counter
and r2,r2,#$0F ; limit to low order nybble
and #$F0 ; prepare to or in new value, mask off foreground color
or r1,r1,r2 ; set new foreground color for cursor
sta $10000,y ; store the color code back to memory
p100Hz1a
; Check the timeout list to see if there are items ready to be removed from
; the list. Also decrement the timeout of the item at the head of the list.
p100Hz15:
ldx TimeoutList
bmi p100Hz12 ; are there any entries in the timeout list ?
lda TCB_Timeout,x
bne p100Hz14 ; has this entry timed out ?
txa
jsr RemoveFromTimeoutList
jsr AddTaskToReadyList
bra p100Hz15 ; go back and see if there's another task to be removed
p100Hz14:
dea ; decrement the entries timeout
sta TCB_Timeout,x
p100Hz12:
; Search the ready queues for a ready task.
; The search is occasionally started at a lower priority queue in order
; to prevent starvation of lower priority tasks. This is managed by
; using a tick count as an index to a string containing the start que.
ld r6,#5 ; number of queues to search
ldy IRQFlag ; use the IRQFlag as a buffer index
lsr r3,r3,#1 ; the LSB is always the same
and r3,r3,#$0F ; counts from 0 to 15
lb r3,strStartQue,y ; get the queue to start search at
p100Hz2:
lda HeadRdy0,y
bmi p100Hz1
; Move the head of the ready queue to the tail
ldx TailRdy0,y
sta TCB_NxtRdy,x
sta TailRdy0,y
lda HeadRdy0,y
tax
lda TCB_NxtRdy,x
php
ld r4,#-1
st r4,TCB_NxtRdy,x
plp
bpl p100Hz4
; here there is no next ready task
; so we just stay with the same task
lda HeadRdy0,y
p100Hz4:
sta HeadRdy0,y
sta TaskNo
bra p100Hz3
p100Hz1:
iny
cpy #5
bne p100Hz5
ldy #0
p100Hz5
dec r6
bne p100Hz2
; here there were no tasks ready
stz TaskNo ; select BIOS task
p100Hz3:
p100Hz10
ldx TaskNo
and r2,r2,#$FF
lda TCB_SP8Save,x ; get back eight bit stack pointer
trs r1,sp8
ldx TCB_SPSave,x ; get back stack pointer
txs
; restore registers
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop r7
pop r6
pop r5
pop r4
ply
plx
pla
rti
;------------------------------------------------------------------------------
; 1000 Hz interrupt
; This IRQ must be fast.
; Increments the millisecond counter
;------------------------------------------------------------------------------
;
p1000Hz:
stz 0xFFDCFFFD ; acknowledge interrupt
inc Milliseconds ; increment milliseconds count
rti