From bf3783ada071aeaee8f22bfc944fee8503768539 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 6 Nov 2020 22:47:57 -0800 Subject: 7203 --- html/mu_instructions.html | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'html') diff --git a/html/mu_instructions.html b/html/mu_instructions.html index 858e9d27..2403bdff 100644 --- a/html/mu_instructions.html +++ b/html/mu_instructions.html @@ -239,6 +239,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" @@ -298,6 +314,17 @@ Similar float variants like `break-if-float<` ar `addr` equivalents. The x86 instruction set stupidly has floating-point operations only update a subset of flags. +## Returns + +The `return` instruction cleans up variable declarations just like an unconditional +`jump` to end of function, but also emits a series of copies before the final +`jump`, copying each argument of `return` to the register appropriate to the +respective function output. This doesn't work if a function output register +contains a later `return` argument (e.g. if the registers for two outputs are +swapped in `return`), so you can't do that. + +return => "c3/return" + --- In the following instructions types are provided for clarity even if they must -- cgit 1.4.1-2-gfad0