Compare commits

..

No commits in common. '2820ff4559ab29afbd2c948149dc1eadf1632cf2' and '5cff8e25955dcc8e417e8be83a6746d2d42e7ff6' have entirely different histories.

2
.gitignore vendored

@ -1,2 +1,2 @@
.*.sw* .sw*
main main

@ -34,12 +34,7 @@
: +! dup >r swap r> @ + swap ! ; : +! dup >r swap r> @ + swap ! ;
: allot dp +! ; : allot dp +! ;
: , here ! cell allot ; : , here ! cell allot ;
: ['] ' [ ' literal , ] ; immediate
: 1+ 1 + ; : 1+ 1 + ;
: 1- 1 - ; : 1- 1 - ;
: if ['] _jmp0 , here 0 , ; immediate
: then here swap ! ; immediate
: else ['] _jmp , here 0 , swap here swap ! ; immediate

@ -282,16 +282,6 @@ struct forth
auto f_semic = [](auto) { *fth.here++ = 0; fth.compiling = false; }; auto f_semic = [](auto) { *fth.here++ = 0; fth.compiling = false; };
auto f_comm = [](auto) { fth.sourcei = npos; }; auto f_comm = [](auto) { fth.sourcei = npos; };
auto f_cell = [](auto) { fth.push(sizeof(cell)); }; auto f_cell = [](auto) { fth.push(sizeof(cell)); };
auto f_jmp = [](auto) {
auto ptr = ++fth.ip;
fth.ip = *reinterpret_cast<func **>(ptr) - 1;
};
auto f_jmp0 = [](auto) {
auto ptr = ++fth.ip;
if (fth.pop() == 0)
fth.ip = *reinterpret_cast<func **>(ptr) - 1;
};
constexpr static word w_dict {"_d", f_dict}; constexpr static word w_dict {"_d", f_dict};
constexpr static word w_add {"+", f_add, &w_dict}; constexpr static word w_add {"+", f_add, &w_dict};
@ -318,10 +308,8 @@ struct forth
constexpr static word w_semic {";", f_semic, &w_colon, word_base::immediate}; constexpr static word w_semic {";", f_semic, &w_colon, word_base::immediate};
constexpr static word w_comm {"\\", f_comm, &w_semic, word_base::immediate}; constexpr static word w_comm {"\\", f_comm, &w_semic, word_base::immediate};
constexpr static word w_cell {"cell", f_cell, &w_comm}; constexpr static word w_cell {"cell", f_cell, &w_comm};
constexpr static word w_jmp {"_jmp", f_jmp, &w_cell};
constexpr static word w_jmp0 {"_jmp0", f_jmp0, &w_jmp};
fth.latest = &w_jmp0; fth.latest = &w_cell;
fth.end = end_value; fth.end = end_value;
} }

Loading…
Cancel
Save