mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
The compiler will use the following template for compiling expressions that involve comparisons: 00 push op1 01 push op2 02 je/jg/jl true_label 03 push_0 04 jmp done_label 05 true_label: 06 push_1 07 done_label: The jmp instruction type used for L02 depends on the AML opcode that is compiled. To conserve space, the ACPI spec only defines opcodes for the following comparison operations: equal, less, greater. All other comparisons are constructed by combining one of the above opcodes with a logical not opcode (e.g. greaterOrEqual = !(less)). The VM opcode exploits the fact the comparison expressions always push a 0/1 value on the stack and uses bitwise operations to emulate some additional logic opcodes: - logic not: 0/1 (on stack) XOR 1 - logic and: 0/1 (left expr on stack) AND 0/1 (right expr on stack) - logic or : 0/1 (left expr on stack) OR 0/1 (right expr on stack)