|
|
|
/**
|
|
|
|
* Forth stack operations
|
|
|
|
*
|
|
|
|
* Created on 2021/11/13.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FORTH_FH_STACK_H
|
|
|
|
#define FORTH_FH_STACK_H
|
|
|
|
|
|
|
|
enum fh_error ds_roll(struct fh_thread_s *fh, int n);
|
|
|
|
|
|
|
|
/** Peek n-th element of data stack */
|
|
|
|
enum fh_error ds_peek_n(struct fh_thread_s *fh, uint32_t *out, int n);
|
|
|
|
/** Peek n-th element of return stack */
|
|
|
|
enum fh_error rs_peek_n(struct fh_thread_s *fh, uint32_t *out, int n);
|
|
|
|
/** Peek n-th element of control stack */
|
|
|
|
enum fh_error cs_peek_n(struct fh_thread_s *fh, uint32_t *out, int n);
|
|
|
|
|
|
|
|
/** Peek top of data stack */
|
|
|
|
static inline enum fh_error ds_peek(struct fh_thread_s *fh, uint32_t *out)
|
|
|
|
{
|
|
|
|
return ds_peek_n(fh, out, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Peek top of return stack */
|
|
|
|
static inline enum fh_error rs_peek(struct fh_thread_s *fh, uint32_t *out)
|
|
|
|
{
|
|
|
|
return rs_peek_n(fh, out, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Peek top of control stack */
|
|
|
|
static inline enum fh_error cs_peek(struct fh_thread_s *fh, uint32_t *out)
|
|
|
|
{
|
|
|
|
return cs_peek_n(fh, out, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
enum fh_error ds_pop(struct fh_thread_s *fh, uint32_t *out);
|
|
|
|
enum fh_error rs_pop(struct fh_thread_s *fh, uint32_t *out);
|
|
|
|
enum fh_error cs_pop(struct fh_thread_s *fh, uint32_t *out);
|
|
|
|
|
|
|
|
enum fh_error ds_push(struct fh_thread_s *fh, uint32_t in);
|
|
|
|
enum fh_error rs_push(struct fh_thread_s *fh, uint32_t in);
|
|
|
|
enum fh_error cs_push(struct fh_thread_s *fh, uint32_t in);
|
|
|
|
|
|
|
|
#endif //FORTH_FH_STACK_H
|