about summary refs log tree commit diff stats
path: root/mu_instructions
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-05-08 21:16:23 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-05-08 21:49:50 -0700
commitf9f419af71a89740448a54f765b89d20e5519d58 (patch)
tree562a7dc06c99b1676a24209613e38965025831e9 /mu_instructions
parentdf68e6eddcdd4b7c595a5ae4c0cffd5df5a664db (diff)
downloadmu-f9f419af71a89740448a54f765b89d20e5519d58.tar.gz
support checking overflow flag everywhere
Diffstat (limited to 'mu_instructions')
-rw-r--r--mu_instructions25
1 files changed, 25 insertions, 0 deletions
diff --git a/mu_instructions b/mu_instructions
index 10d00f10..7a458660 100644
--- a/mu_instructions
+++ b/mu_instructions
@@ -293,6 +293,31 @@ Similar float variants like `break-if-float<` are aliases for the corresponding
 `addr` equivalents. The x86 instruction set stupidly has floating-point
 operations only update a subset of flags.
 
+Four sets of conditional jumps are useful for detecting overflow.
+
+break-if-carry                    => "0f 82/jump-if-carry break/disp32"
+break-if-carry label              => "0f 82/jump-if-carry " label "/disp32"
+loop-if-carry                     => "0f 82/jump-if-carry break/disp32"
+loop-if-carry label               => "0f 82/jump-if-carry " label "/disp32"
+
+break-if-not-carry                => "0f 83/jump-if-not-carry break/disp32"
+break-if-not-carry label          => "0f 83/jump-if-not-carry " label "/disp32"
+loop-if-not-carry                 => "0f 83/jump-if-not-carry break/disp32"
+loop-if-not-carry label           => "0f 83/jump-if-not-carry " label "/disp32"
+
+break-if-overflow                 => "0f 80/jump-if-overflow break/disp32"
+break-if-overflow label           => "0f 80/jump-if-overflow " label ":break/disp32"
+loop-if-overflow                  => "0f 80/jump-if-overflow loop/disp32"
+loop-if-overflow label            => "0f 80/jump-if-overflow " label ":loop/disp32"
+
+break-if-not-overflow             => "0f 81/jump-if-not-overflow break/disp32"
+break-if-not-overflow label       => "0f 81/jump-if-not-overflow " label ":break/disp32"
+loop-if-not-overflow              => "0f 81/jump-if-not-overflow loop/disp32"
+loop-if-not-overflow label        => "0f 81/jump-if-not-overflow " label ":loop/disp32"
+
+All this relies on a convention that every `{}` block is delimited by labels
+ending in `:loop` and `:break`.
+
 ## Returns
 
 The `return` instruction cleans up variable declarations just like an unconditional