// just a small extract from what we have been doing manifest { kb_buffer = 0, kb_start = 1, kb_end = 2, kb_num = 3, kb_max = 4, kb_lines = 5, sizeof_kbthing = 6, user_kbthing_VA = 0x1F0 } let init_kb(kba, kbb, size) be { kba ! kb_buffer := kbb; kba ! kb_start := 0; kba ! kb_end := 0; kba ! kb_num := 0; kba ! kb_max := size * 4 - 1; kba ! kb_lines := 0 } static { os_kbthing = vec(sizeof_kbthing), kbthing = 0 } let kbbadd(c) be { if kbthing ! kb_num >= kbthing ! kb_max then resultis 0; byte kbthing ! kb_end of kbthing ! kb_buffer := c; if c = '\n' then kbthing ! kb_lines +:= 1; kbthing ! kb_num +:= 1; kbthing ! kb_end +:= 1; if kbthing ! kb_end > kbthing ! kb_max then kbthing ! kb_end := 0; resultis 1 } let kbbremove() be { let c; if kbthing ! kb_lines = 0 then resultis 0; c := byte kbthing ! kb_start of kbthing ! kb_buffer; kbthing ! kb_num -:= 1; kbthing ! kb_start +:= 1; if kbthing ! kb_start > kbthing ! kb_max then kbthing ! kb_start := 0; if c = '\n' then kbthing ! kb_lines -:= 1; resultis c } // this is what our user (or the iosb system) uses let minch() be { let c = 0; while true do { c := kbbremove(); if c <> 0 then resultis c; assembly { pause } } } // this is one of our interrupt handlers let handler kbint() be { let c; devctl(dc$termin, 1, @ c); test c = 'H'-64 then { if kbbunadd() then assembly { type 8 type ' ' type 8 } } else { if kbbadd(c) then assembly { type [] } } } // what could possibly go wrong?