Compare commits

...

2 Commits

Author SHA1 Message Date
Clyne 3fe10655e9
execute 2 weeks ago
Clyne 3226cb7a69
begin double-cell words 2 weeks ago

@ -72,3 +72,4 @@
: ( begin [char] ) key = until ; immediate : ( begin [char] ) key = until ; immediate
: execute [ here 3 cells + ] literal ! [ ' _jmp , 0 , ] ;

@ -221,6 +221,14 @@ constexpr auto initialize()
, S{"+" }, [](auto) { fthp->top() += fthp->pop(); }, 0 , S{"+" }, [](auto) { fthp->top() += fthp->pop(); }, 0
, S{"-" }, [](auto) { fthp->top() -= fthp->pop(); }, 0 , S{"-" }, [](auto) { fthp->top() -= fthp->pop(); }, 0
, S{"*" }, [](auto) { fthp->top() *= fthp->pop(); }, 0 , S{"*" }, [](auto) { fthp->top() *= fthp->pop(); }, 0
, S{"M*" }, [](auto) {
dcell a = fthp->pop();
a *= fthp->pop();
fthp->push(a, a >> 8 * sizeof(cell)); }, 0
, S{"UM*" }, [](auto) {
daddr a = std::bit_cast<addr>(fthp->pop());
a *= std::bit_cast<addr>(fthp->pop());
fthp->push(a, a >> 8 * sizeof(addr)); }, 0
, S{"/" }, [](auto) { fthp->top() /= fthp->pop(); }, 0 , S{"/" }, [](auto) { fthp->top() /= fthp->pop(); }, 0
, S{"MOD" }, [](auto) { fthp->top() %= fthp->pop(); }, 0 , S{"MOD" }, [](auto) { fthp->top() %= fthp->pop(); }, 0
, S{"AND" }, [](auto) { fthp->top() &= fthp->pop(); }, 0 , S{"AND" }, [](auto) { fthp->top() &= fthp->pop(); }, 0
@ -322,6 +330,7 @@ constexpr auto initialize()
, S{"CHAR+" }, S{"1 +" }, 0 , S{"CHAR+" }, S{"1 +" }, 0
, S{"-ROT" }, S{"ROT ROT"}, 0 , S{"-ROT" }, S{"ROT ROT"}, 0
, S{"2DROP" }, S{"DROP DROP"}, 0 , S{"2DROP" }, S{"DROP DROP"}, 0
, S{"S>D" }, S{"DUP 0<"}, 0
, S{"0<" }, S{"0 <"}, 0 , S{"0<" }, S{"0 <"}, 0
, S{"0<>" }, S{"0 <>"}, 0 , S{"0<>" }, S{"0 <>"}, 0
, S{"<>" }, S{"= 0="}, 0 , S{"<>" }, S{"= 0="}, 0

@ -29,6 +29,26 @@ using cell = std::intptr_t;
using addr = std::uintptr_t; using addr = std::uintptr_t;
using func = void (*)(const void *); using func = void (*)(const void *);
#if UINTPTR_MAX == 0xFFFF
using dcell = std::int32_t;
#elif UINTPTR_MAX == 0xFFFFFFFF
using dcell = std::int64_t;
#elif UINTPTR_MAX == 0xFFFFFFFFFFFFFFFF
using dcell = __int128;
#else
#error "Cannot figure out size of double-cell integer"
#endif
#if UINTPTR_MAX == 0xFFFF
using daddr = std::uint32_t;
#elif UINTPTR_MAX == 0xFFFFFFFF
using daddr = std::uint64_t;
#elif UINTPTR_MAX == 0xFFFFFFFFFFFFFFFF
using daddr = __uint128;
#else
#error "Cannot figure out size of double-address integer"
#endif
struct word_base; struct word_base;
template<typename T> template<typename T>

Loading…
Cancel
Save