Interrupts
One way to add interrupts is for the interpreter to check each time it is called. This slows things down and imposes a condition. No process should "block" the interpreter.
An example of a blocking sunroutine is "getchar". It waits until a character arrives before returning. A better way is for the subrountine to fail and then to retry.
To set up interrupts I need to add:
- a interrupt read register (at address 0xFF seems a nice place), call it "REGI".
- a system variable to hold the value read, call it "INTR".
- a system variable to hold an interrupt mask call it "MASK".
- a system variable to hold the Interrupt Service Routine address, call it "ISR".
The best place to put these system variables in the CPU MODEL area:
You may also notice I have abandoned the "i8080 lite" CPU Model, the model is now more like a stack CPU with a Return Pointer (RP) and a Data Pointer (DP). Next will likely be a Top Of (data) Stack, "TOS". If you have not worked it out I am considering a micro-forth style operating system.
Okay, here is the interpertrer code:
All it does is read the interrupts and if anything is high (active) it calls the ISR subroutine to work it out. Initially the MASK is set all on (0xFF) but the ISR is diabled, it just calls _INTERP (okay I just saw the coding error where I called INTERP rather than _INTERP!).
The next bit of work is to look at "getchar" and "putchar", and some sort of terminal (hardware) interface.
AlanX
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.