about summary refs log tree commit diff stats
path: root/mu_instructions
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-31 20:38:11 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-31 20:38:11 -0700
commitc3964ff60af5992fe14c2dd1933c3e880b20835f (patch)
tree102a79a681b62c738f2df7f13dc0676430ecd576 /mu_instructions
parent84a77452245bed7e75940d37e6ca80694878b06d (diff)
downloadmu-c3964ff60af5992fe14c2dd1933c3e880b20835f.tar.gz
7150
Diffstat (limited to 'mu_instructions')
-rw-r--r--mu_instructions16
1 files changed, 16 insertions, 0 deletions
diff --git a/mu_instructions b/mu_instructions
index f0e66917..bece4fc1 100644
--- a/mu_instructions
+++ b/mu_instructions
@@ -215,6 +215,22 @@ Comparisons must always start with a register:
 compare var1/xreg1, var2/xreg2    => "0f 2f/compare %" xreg2 " " xreg1 "/x32"
 compare var1/xreg1, var2          => "0f 2f/compare *(ebp+" var2.stack-offset ") " xreg1 "/x32"
 
+## Blocks
+
+In themselves, blocks generate no instructions. However, if a block contains
+variable declarations, they must be cleaned up when the block ends.
+
+Clean up var on the stack         => "81 0/subop/add %esp " size-of(var) "/imm32"
+Clean up var/reg                  => "8f 0/subop/pop %" reg
+
+Clean up var/xreg                 => "f3 0f 10/-> *esp " xreg "/x32"
+                                     "81 0/subop/add %esp 4/imm32"
+
+## Jumps
+
+Besides having to clean up any variable declarations (see above) between
+themselves and their target, jumps translate like this:
+
 break                             => "e9/jump break/disp32"
 break label                       => "e9/jump " label ":break/disp32"
 loop                              => "e9/jump loop/disp32"