mirror of
https://github.com/remko/waforth
synced 2024-12-27 09:59:29 +01:00
Implement S>D
This commit is contained in:
parent
92e3588a6e
commit
186ab96276
3 changed files with 33 additions and 0 deletions
|
@ -1145,6 +1145,14 @@
|
||||||
(call $ALIGN))
|
(call $ALIGN))
|
||||||
(!def_word "S\"" "$Sq" !fImmediate)
|
(!def_word "S\"" "$Sq" !fImmediate)
|
||||||
|
|
||||||
|
;; 6.1.2170
|
||||||
|
(func $s-to-d
|
||||||
|
(local $btos i32)
|
||||||
|
(i64.store (tee_local $btos (i32.sub (get_global $tos) (i32.const 4)))
|
||||||
|
(i64.extend_s/i32 (i32.load (get_local $btos))))
|
||||||
|
(set_global $tos (i32.add (get_global $tos) (i32.const 4))))
|
||||||
|
(!def_word "S>D" "$s-to-d")
|
||||||
|
|
||||||
;; 6.1.2216
|
;; 6.1.2216
|
||||||
(func $SOURCE
|
(func $SOURCE
|
||||||
(call $push (i32.const !inputBufferBase))
|
(call $push (i32.const !inputBufferBase))
|
||||||
|
|
|
@ -270,5 +270,16 @@ T{ 1 ABS -> 1 }T
|
||||||
T{ -1 ABS -> 1 }T
|
T{ -1 ABS -> 1 }T
|
||||||
T{ MIN-INT ABS -> MID-UINT+1 }T
|
T{ MIN-INT ABS -> MID-UINT+1 }T
|
||||||
|
|
||||||
|
\\ ------------------------------------------------------------------------
|
||||||
|
TESTING MULTIPLY: S>D * M* UM*
|
||||||
|
|
||||||
|
T{ 0 S>D -> 0 0 }T
|
||||||
|
T{ 1 S>D -> 1 0 }T
|
||||||
|
T{ 2 S>D -> 2 0 }T
|
||||||
|
T{ -1 S>D -> -1 -1 }T
|
||||||
|
T{ -2 S>D -> -2 -1 }T
|
||||||
|
T{ MIN-INT S>D -> MIN-INT -1 }T
|
||||||
|
T{ MAX-INT S>D -> MAX-INT 0 }T
|
||||||
|
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1350,6 +1350,20 @@ function loadTests(wasmModule, arrayToBase64) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("S>D", () => {
|
||||||
|
it("should work with positive number", () => {
|
||||||
|
run("2 S>D");
|
||||||
|
expect(stack[0]).to.eql(2);
|
||||||
|
expect(stack[1]).to.eql(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should work with negative number", () => {
|
||||||
|
run("-2 S>D");
|
||||||
|
expect(stack[0]).to.eql(-2);
|
||||||
|
expect(stack[1]).to.eql(-1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("system", () => {
|
describe("system", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
core.loadPrelude();
|
core.loadPrelude();
|
||||||
|
|
Loading…
Reference in a new issue