So, my goal is the write a subroutine that when called hangs until the user has entered a string terminated by <return>
, which it then returns(probably by writing it to an address specified by the user).
My problem lies in how i best get individual characters from the keyboard. As I see it there are 3 ways:
Listen for interrupts from the keyboard and get the character in response to those. This would mean that the logic performed by
getline
would be in the interrupt handler, which seem to cause some problems. i.e. how do you return fromgetline
in response to a press on the<return>
key? You don't have the return address handy when in the interrupt handler. Also the pattern of putting too much specific logic in the interrupt handler seems to me... wrong... even though I'm very inexperienced in low level coding.Just keep pulling the keyboard for key presses.
Implementing the old 1.1 behavior with the interrupt handler, by loading all characters pressed into a circular buffer(possibly of length 1).
Some more perspective on these options would be nice.
when you call your
getline
it should setup the interrupt handler so it adds the typed keys to buffer and updates a indexthen start a busy loop until the end of the buffer has a new line and disable the interrupts from the keyboard
and the interrupt handler adds the typed key to the buffer until it is full and adds 1 to the counter, this can be put in a interrupt handler itself but you'll need to reactivate interrupts while in the busy loop