Implement the following instructions:
* `RotateLeft` (`RL`)
* `RotateRight` (`RR`)
* `RotateLeftByte` (`RLB`)
* `RotateRightByte` (`RRB`)
* `ShiftLeft` (`SL`)
* `ShiftRight` (`SR`)
* `ShiftLeftByte` (`SLB`)
* `ShiftRightByte` (`SRB`)
* `ArithmeticShiftRight` (`ASR`)
DB48X adds counted variants of the above, that shift by an amount other than one
or eight.
* `RotateLeftCount` (`RLC`), rotating left several bits
* `RotateRightCount` (`RRC`), rotating right several bits
* `ShiftLeftCount` (`SLC`), shift left several bits
* `ShiftRightCount` (`SRC`), shift right several bits
* `ArithmeticShiftRightCount` (`ASRC`), arithmetic shift right several bits
Also slight rework of the `BasesMenu`.
Fixes: #622
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `Min` and `Max` functions compare two elements.
For arrays, they perform an element-by-element comparison.
For lists, they perform a a lexicographic order comparison.
Fixes: #603
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `IP` command return the integer part.
The `FP` command return the fractional part.
Fixes: #601
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `OBJ→` explodes an object into its sub-components. The various
sub-components are placed on the stack, and if necessary, information about the
size is places on the first level of the stack.
* Complex numbers are split into real and imaginary part (for rectangular form)
or modulus and argument (for polar form). The latter is an extension compared
to classical RPL, which always represent complex numbers in rectangular form.
* Unit objects are split into the value and unit expression. This is a deviation
from standard RPL, which places a unit object on the first level of the stack.
* Lists, programs and expressions are split into their individual components,
and the number of components is placed on the first level of the stack. For
programs, this is an extension of standard RPL. For expressions, this is a
deviation: HP calculators instead place only the top level object and
the arity.
* Arrays and vectors are split into their individual components, and the number
of elements is placed as a list on the first level of the stack. The dimension
list has one element for vectors, and two for matrices. If a given matrix is
not rectangular, then the command reports an `Invalid dimension` error.
* Fractions are split into numerator and denominator. This is a deviation from
the HP50G, which treats fractions as algebraic expressions.
* Text is evaluated as if it had been executed on the command line, in a way
similar to the `STR→` command.
Fixes: #596
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Implement the `Compile` command, which evaluates a text as if
it was on the command line.
Fixes: #590
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Implement the RPL `case` statement, including a `case...when`
extension to traditional RPL.
The `case` statement can be used to select one case among many.
Inside a `case`, there is a list of conditions, each followed by
`then` or `when`. Code following `then` or `when` is executed when the
condition is met.
* A condition preceding `then` is a boolean condition, similar to the
condition in an `if` statement.
* A condition preceding `when` is a value that must match the current
value on the stack exactly.
For example, the following tests the sign of `X`:
```
X
case
dup 0 < then "Neg" end
dup 0 > then "Pos" end
"Zero"
end
```
The `when` syntax is useful to test exact values, for example, you can
check return the spelling of the ten digits with:
```
X
case
0 when "zero" end
1 when "one" end
2 when "two" end
3 when "three" end
4 when "four" end
5 when "five" end
6 when "size" end
7 when "seven" end
8 when "eight" end
9 when "nine" end
end
```
Fixes: #374
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Thanks to the RPL-stack evaluation loop, it is relatively easy to
implement debugging capabilities without impacting the performance of
the main evaluation loop significantly.
This commit implements the `Debug`, `SingleStep`, `MultipleSteps`,
`StepOver`, `StepOut`, `Halt`, `Continue` and `Kill` commands.
Fixes: #552
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add the `ShowBuiltinUnits` and `HideBuiltinUnits` commands to show or
hide built-in units when a units file is loaded.
Fixes: #542
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Copied the various commands from the HP50G's advanced reference manual,
and split them between implemented and not-implemented parts.
Copied the various entries in the `ids.tbl` file to build a section about
commands that only exist in DB48X.
Applied to magic Emacs-fu to add markdown links everywhere.
Fixes: #530
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>