You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.6 KiB
C++

10 months ago
// sprit-forth: A portable subroutine-threaded Forth.
// Copyright (C) 2023 Clyne Sullivan <clyne@bitgloo.com>
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Library General Public License as published by
// the Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for
// more details.
//
// You should have received a copy of the GNU Library General Public License
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef STATE_HPP
#define STATE_HPP
#include "types.hpp"
constexpr Addr DS = 16;
constexpr Addr RS = 16;
constexpr Addr DIdxBase = 0;
constexpr Addr DIdxHere = 1;
constexpr Addr DIdxLatest = 2;
constexpr Addr DIdxState = 3;
constexpr Addr DIdxSource = 4;
constexpr Addr DIdxSrcLen = 5;
constexpr Addr DIdxInBuf = 6;
constexpr Addr DIdxBegin = DIdxInBuf + 80 * sizeof(char);
extern std::array<Cell, 2048> DICT;
extern Cell& HERE;
extern Cell& LATEST;
extern Cell& STATE;
extern Cell *SP;
extern Cell *RP;
extern FuncList IP;
inline void initialize(const auto& wordset)
{
LATEST = (Cell)wordset.latest;
HERE = (Cell)&DICT[DIdxBegin];
STATE = 0;
}
void executor(FuncList *list);
void execute1(Word *word);
Word *find(const char *s, int len);
#endif // STATE_HPP