News for hackers. Stuff that matters.
Re:Building a Modern Computer from First Principles by angersock on Sunday June 16, 2013 @09:57PM (#5890987)
If I'm not mistaken, the keyboard should raise high an interrupt pin on the CPU, which should cause an interrupt service routine to be called.

That routine should then mask lower-priority interrupts, poll the appropriate region of memory (assuming memory-mapped IO) for the byte or bytes held down, push those onto the buffer for key inputs or into the STDIN equivalent, unmask lower-priorty interrupts, and return.

It is then up to the user program to read in from the buffer and do the needful.

Re:Building a Modern Computer from First Principles by kragen on Monday June 17, 2013 @04:46AM (#5892115)
The Hack CPU doesn't have interrupts, IIRC.
Re:Building a Modern Computer from First Principles by angersock on Monday June 17, 2013 @05:27AM (#5892196)
I was actually working on implementing a simple little VM library in C as a fun exercise, and deciding how to handle interrupts was where I got caught up.
Re:Building a Modern Computer from First Principles by kragen on Monday June 17, 2013 @06:50AM (#5892420)
Most VMs don't have interrupts. As a less-complex alternative, you might consider implementing an I/O thread, something rarely done in hardware because an extra CPU is a lot more hardware than an interrupt mechanism.

One interesting exception is the Unix VM, whose interrupts are called "signals".