Author: wmb Date: 2008-09-30 22:18:05 +0200 (Tue, 30 Sep 2008) New Revision: 948
Modified: cpu/x86/interrup.fth Log: Added "halt" and "?halt" words to save power on x86 systems. Also helps when running under an emulator by yielding the host CPU.
Modified: cpu/x86/interrup.fth =================================================================== --- cpu/x86/interrup.fth 2008-09-30 20:15:44 UTC (rev 947) +++ cpu/x86/interrup.fth 2008-09-30 20:18:05 UTC (rev 948) @@ -20,6 +20,25 @@ h# 200 # bx test 0<> if ax dec then \ Test interrupt flag bit ax push c; + +\ Unconditional halt - stops instruction execution until an interrupt. +\ If interrupts are disabled, this could hang forever. +code halt hlt c; + +\ Safe halt that is a no-op if interrupts are disabled +code ?halt ( -- ) + pushf ax pop + h# 200 # ax test 0<> if hlt then +c; + +\ You can install this in "key" to lower the idle power or to make +\ the system use fewer CPU cycles when running on an emulator. + +: halting-key ( -- ) + begin key? 0= while ?halt repeat + (key +; + \ LICENSE_BEGIN \ Copyright (c) 2006 FirmWorks \