From ae4058add3c2002b90f171a1ace40bf21118103e Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 7 Dec 2023 21:48:47 -0800 Subject: halt until exception when waiting for keyboard This reduces CPU consumption from 180% to 2% when running Qemu. Many thanks to Fabian of https://copy.sh for this suggestion. --- 102keyboard.subx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/102keyboard.subx b/102keyboard.subx index 39788075..f963baa2 100644 --- a/102keyboard.subx +++ b/102keyboard.subx @@ -24,6 +24,8 @@ read-key: # kbd: (addr keyboard) -> result/eax: byte 89/<- %ebp 4/r32/esp # . save registers 51/push-ecx + # wait for an interrupt to save power on Qemu + f4/hlt # result = 0 b8/copy-to-eax 0/imm32 # ecx = keyboard -- cgit 1.4.1-2-gfad0