floobydust wrote:
My BIOS supports an interrupt service routine to service the UART, which is IRQ driven for transmit and receive, plus a 100ms jiffy clock based on the timer. It also handles a "send break" to the UART via interrupt. As a result, I'm guessing that EhBasic can likely hose up the stack. Is there any easy way to prevent this?
EhBASIC will trash any bytes left on the stack by the monitor. So you cannot use RTS from EhBASIC to exit back to your monitor. You should adjust EhBASIC's stack floor protection at LAB_1212. Just add the maximum number of bytes you expect interrupts to occupy on the stack. However, you would need a lot of nested FOR, GOSUB or DO statements before the stack is in danger of wrapping arround.
Code:
; check room on stack for A bytes
; stack too deep? do OM error
LAB_1212
; *** patch - adjust stack floor protection for background interrupts
; *** add
CLC ; prep ADC
ADC #16 ; stack pointer lower limit before interrupts
; *** end patch
STA TempB ; save result in temp byte
TSX ; copy stack
CPX TempB ; compare new "limit" with stack
BCC LAB_OMER ; if stack < limit do "Out of memory" error then warm start
RTS
floobydust wrote:
I've added some code to the Monitor to launch EhBasic, but in general I call LAB_COLD to init EhBasic. Currently I'm not setting up the IRQ/NMI vectors for EhBasic... but I'm also not using the IRQ/NMI functions. Do you have to set them up for some functioning code if the functions are never used in a program??
You must make sure that the I/O and load/save vectors are copied before jumping to LAB_COLD. NmiBase and IrqBase are initialized with $00 by LAB_COLD and must stay that way if you are not using interrupts in EhBASIC. Those two locations cannot be used for other purposes even when you're not using any interrupt related BASIC commands.
floobydust wrote:
I also want to have an EhBasic command to exit back to the Monitor as well, but one thing at a time.
You could use CALL <addr.> for now where addr. is your monitor's start address. Just make sure to discard the stack (SP=$FF) in your monitor. After that you should be able to jump to LAB_WARM to get back into EhBASIC.