diff --git a/Instruction-Set.md b/Instruction-Set.md index 0177bc3..728646d 100644 --- a/Instruction-Set.md +++ b/Instruction-Set.md @@ -202,6 +202,7 @@ The carry flag (CF) is set equal to the last bit shifted out of the left end. #### Pseudo code ```py destination = destination << count +#NOTE: be aware of the difference between a logical and an arithmetic shift ``` ### SHR @@ -221,6 +222,7 @@ destination = destination << count #### Pseudo code ```py destination = destination >> count +#NOTE: be aware of the difference between a logical and an arithmetic shift ``` ### HWI @@ -827,7 +829,7 @@ if count == 1: | mnemonic | opcode | operands | carry | zero | sign | overflow | break | | -------- | ------ | -------- | ----- | ---- | ---- | -------- | ----- | | `RCR destination, count` | `0x28` | `destination` : `mem` / `reg` | `X` | `-` | `-` | `X` | `-` | -| | | `count` : `mem` / `reg`, `imm` | +| | | `count` : `mem` / `reg` / `imm` | #### Description `RCR` shifts the bits of the `destination` operand to the right by the @@ -867,6 +869,27 @@ if count == 1: OVERFLOW_FLAG = (old_sign_bit != new_sign_bit) ``` +### SAR +#### Details +| mnemonic | opcode | operands | carry | zero | sign | overflow | break | +| -------- | ------ | -------- | ----- | ---- | ---- | -------- | ----- | +| `SAR destination, count` | `0x29` | `destination` : `mem` / `reg` | `X` | `X` | `X` | `X` | `-` | +| | | `count` : `mem` / `reg`/ `imm` | +#### Description +The `SAR` (Shift Arithmetic Right) instruction shifts the bits of the destination operand downward (toward the least significant bit) by the number of bit positions specified in the second operand (count). +As bits are transferred out of the right (low-order) end of the destination, bits equal to the original sign bit are shifted into the left (high-order) end, thereby preserving the sign bit. The carry flag (CF) is set equal to the last bit shifted out of the right end. + +If the count operand is not an immediate 1, the overflow flag (OF) is undefined; otherwise SAR resets OF to zero. +> TODO: Not sure if this part is implemented, should check source code + +> TODO: Plain english? (now copy pasta from the [manual](http://www.ousob.com/ng/iapx86/ng215f0.php)) + +### Pseudo code +```py +destination = destination <<< count +#NOTE: be aware of the difference between a logical and an arithmetic shift +``` + ### INC #### Details | mnemonic | opcode | operands | carry | zero | sign | overflow | break | @@ -879,6 +902,7 @@ if count == 1: ```py destination = destination + 1 ``` + ### DEC #### Details | mnemonic | opcode | operands | carry | zero | sign | overflow | break |