From df950c6f63f5f23ee72e4621723b2bd7f9f9ee58 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Sun, 26 Jan 2020 10:52:26 -0500 Subject: [PATCH] Fix arithmetic instruction specs Originally, arithmetic instructions were in the form of REG2 = REG1 (OP) REG2 but then I started storing the result in REG1 (both in implementation, and later defs of the arth instructions). So I'm updating it to match what was actually in my head. Signed-off-by: Alek Ratzloff --- vm.md | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/vm.md b/vm.md index cefe248..9f28924 100644 --- a/vm.md +++ b/vm.md @@ -43,32 +43,32 @@ CPU flags are addressed by bit index, going from right to left. ## Arithmetic -Arithmetic instructions store their result in the last register specified. +Arithmetic instructions store their result in the first register specified. * Add * **Params**: REG1, REG2 - * `REG2 = REG1 + REG2` + * `REG1 = REG1 + REG2` * Mul * **Params**: REG1, REG2 - * `REG2 = REG1 * REG2` + * `REG1 = REG1 * REG2` * Div * **Params**: REG1, REG2 - * `REG2 = REG1 / REG2` + * `REG1 = REG1 / REG2` * Mod * **Params**: REG1, REG2 - * `REG2 = REG1 % REG2` (exact semantics TBD) + * `REG1 = REG1 % REG2` (exact semantics TBD) * Neg * **Params**: REG1 * `REG1 = REG1 * -1` * And * **Params**: REG1, REG2 - * `REG2 = REG1 & REG2` + * `REG1 = REG1 & REG2` * Or * **Params**: REG1, REG2 - * `REG2 = REG1 | REG2` + * `REG1 = REG1 | REG2` * Xor * **Params**: REG1, REG2 - * `REG2 = REG1 ^ REG2` + * `REG1 = REG1 ^ REG2` * Shl * **Params**: REG1, REG2 * `REG1 = REG1 << REG2` @@ -124,9 +124,8 @@ Arithmetic instructions store their result in the last register specified. MEM[REG2] = REG1; ``` * StoreImm32 - * (hw = half word) - * **Params**: REG1, IMM_HW - * `REG1 = IMM_HW` + * **Params**: REG1, IMM_32 + * `REG1 = IMM_32` * MemCopy * **Params**: REG1, REG2 * `MEM[REG1] = MEM[REG2]`