2 * tag: stack and stack access functions
4 * Copyright (C) 2003 Patrick Mauritz, Stefan Reinauer
6 * See the file "COPYING" for further information about
7 * the copyright and warranty status of this work.
13 #define dstacksize 512
15 extern cell dstack
[dstacksize
];
17 #define rstacksize 512
19 extern cell rstack
[rstacksize
];
21 extern int dbgrstackcnt
;
23 //typedef struct opaque_xt *xt_t;
24 //typedef struct opaque_ihandle *ihandle_t;
25 //typedef struct opaque_phandle *phandle_t;
28 typedef ucell ihandle_t
;
29 typedef ucell phandle_t
;
34 static inline void PUSH(ucell value
) {
35 dstack
[++dstackcnt
] = (value
);
37 static inline void PUSH_xt( xt_t xt
) { PUSH( (ucell
)xt
); }
38 static inline void PUSH_ih( ihandle_t ih
) { PUSH( (ucell
)ih
); }
39 static inline void PUSH_ph( phandle_t ph
) { PUSH( (ucell
)ph
); }
41 static inline ucell
POP(void) {
42 return (ucell
) dstack
[dstackcnt
--];
44 static inline xt_t
POP_xt( void ) { return (xt_t
)POP(); }
45 static inline ihandle_t
POP_ih( void ) { return (ihandle_t
)POP(); }
46 static inline phandle_t
POP_ph( void ) { return (phandle_t
)POP(); }
48 static inline void DROP(void) {
52 static inline void DDROP(void) {
56 static inline void DPUSH(ducell value
) {
57 #ifdef NEED_FAKE_INT128_T
58 dstack
[++dstackcnt
] = (cell
) value
.lo
;
59 dstack
[++dstackcnt
] = (cell
) value
.hi
;
61 dstack
[++dstackcnt
] = (cell
) value
;
62 dstack
[++dstackcnt
] = (cell
) (value
>> bitspercell
);
66 static inline ducell
DPOP(void) {
67 #ifdef NEED_FAKE_INT128_T
69 du
.hi
= (ucell
) dstack
[dstackcnt
--];
70 du
.lo
= (ucell
) dstack
[dstackcnt
--];
74 du
= ((ducell
)(ucell
) dstack
[dstackcnt
--]) << bitspercell
;
75 du
|= (ucell
) dstack
[dstackcnt
--];
80 static inline ucell
GETTOS(void) {
81 return dstack
[dstackcnt
];
84 #define GETITEM(number) (dstack[dstackcnt - number])
85 static inline void PUSHR(ucell value
) {
86 rstack
[++rstackcnt
] = (value
);
89 static inline ucell
POPR(void) {
90 return (ucell
) rstack
[rstackcnt
--];
92 static inline ucell
GETTORS(void) {
93 return rstack
[rstackcnt
];
97 #if defined(DEBUG_DSTACK) || defined(FCOMPILER)
98 void printdstack(void);
100 #if defined(DEBUG_RSTACK) || defined(FCOMPILER)
101 void printrstack(void);