From 3eae9abada7793a4878b43a43b23bc92935e7656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 13 Nov 2021 21:02:28 +0100 Subject: [PATCH] add nip --- src/fh_builtins.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/fh_builtins.c b/src/fh_builtins.c index def0065..e6fc865 100644 --- a/src/fh_builtins.c +++ b/src/fh_builtins.c @@ -306,6 +306,17 @@ static enum fh_error w_dupe(struct fh_thread_s *fh, const struct fh_word_s *w) return FH_OK; } +static enum fh_error w_nip(struct fh_thread_s *fh, const struct fh_word_s *w) +{ + (void) w; + enum fh_error rv; + uint32_t a = 0, discard = 0; + TRY(ds_pop(fh, &a)); + TRY(ds_pop(fh, &discard)); + TRY(ds_push(fh, a)); + return FH_OK; +} + static enum fh_error w_question_dupe(struct fh_thread_s *fh, const struct fh_word_s *w) { (void) w; @@ -752,6 +763,8 @@ enum fh_error register_builtin_words(struct fh_thread_s *fh) {"decimal", wp_setbase, 0, 10}, {"hex", wp_setbase, 0, 16}, {"base", wp_const, 0, MAGICADDR_BASE}, + {"false", wp_const, 0, 0}, + {"true", wp_const, 0, 0xFFFFFFFF}, {"depth", w_depth, 0, 0}, {"+", w_plus, 0, 0}, {"-", w_minus, 0, 0}, @@ -781,6 +794,7 @@ enum fh_error register_builtin_words(struct fh_thread_s *fh) /* Stack manip */ {"drop", w_drop, 0, 0}, {"dup", w_dupe, 0, 0}, + {"nip", w_nip, 0, 0}, {"?dup", w_question_dupe, 0, 0}, {"over", w_over, 0, 0}, {"swap", w_swap, 0, 0},