Hacker News new | past | comments | ask | show | jobs | submit login

From what I understand, you also wrote a mouse driver for it[0][1], OP?

[0]: https://www.youtube.com/watch?v=RlDi2Ncfb9Q

[1]: http://sininenankka.dy.fi/~sami/keymouse.zip




Yes. I wrote a special mouse driver that hooks to the keyboard interrupt and makes it possible to use the numpad keys as a "mouse". Sadly most DOS programs seem to replace the BIOS's keyboard interrupt handler with their own, so my driver does not work with them.


I have an idea of how to keep control of interrupts without needing all the complexity of V86 mode: relocate the IVT!

On 286 and above, the interrupt vectors always start at the address in the IDTR (interrupt descriptor table register), even in real mode. Intel did of course not document that :)

If you do this, you can handle any interrupts you want directly, or "reflect" them to the handler installed by the DOS program. A fast technique for doing this takes advantage of segment:offset alias addresses to use the CS register as a pointer to the old interrupt vector:

    reflect_int:
     ; come from our IVT with CS bits 10..2 = interrupt number
     ; flags, CS and IP on stack and will remain there
     sub  sp,2       ;reserve space for return segment
     push bx         ;will become return offset
     mov  bx,cs
     and  bh,3       ;clear high bits, BX now offset into IVT
     push bp
     push ds
     xor  bp,bp
     mov  ds,bp      ;DS:BX => vector
     lds  bx,[bx]    ;fetch vector
     mov  bp,sp
     mov  [bp+6],ds  ;store segment
     xchg [bp+4],bx  ;store offset / load old BX
     pop  ds
     pop  bp
     retf            ;return to actual handler




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: