2
* $Id: stack.h,v 1.4 2003/12/01 07:35:54 troth Exp $
4
****************************************************************************
6
* simulavr - A simulator for the Atmel AVR family of microcontrollers.
7
* Copyright (C) 2001, 2002, 2003 Theodore A. Roth
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
****************************************************************************
29
/****************************************************************************\
31
* Stack(AvrClass) Definition.
33
* This is a virtual class for higher level stack implementations and as such
34
* should not be used directly.
36
\****************************************************************************/
38
typedef struct _Stack Stack;
40
typedef uint32_t (*StackFP_Pop) (Stack *stack, int bytes);
41
typedef void (*StackFP_Push) (Stack *stack, int bytes, uint32_t val);
56
extern Stack *stack_new (StackFP_Pop pop, StackFP_Push push);
57
extern void stack_construct (Stack *stack, StackFP_Pop pop,
59
extern void stack_destroy (void *stack);
61
extern uint32_t stack_pop (Stack *stack, int bytes);
62
extern void stack_push (Stack *stack, int bytes, uint32_t val);
64
/****************************************************************************\
66
* HWStack(Stack) Definition.
68
\****************************************************************************/
70
typedef struct _Hardware_Stack HWStack;
72
struct _Hardware_Stack
76
uint32_t *stack; /* an array used as the stack */
79
extern HWStack *hwstack_new (int depth);
80
extern void hwstack_construct (HWStack *stack, int depth);
81
extern void hwstack_destroy (void *stack);
83
/****************************************************************************\
85
* MemStack(Stack) Definition.
87
\****************************************************************************/
89
typedef struct _Memory_Stack MemStack;
91
enum _stack_point_constants
93
STACK_POINTER_BASE = 0x5d,
94
STACK_POINTER_SIZE = 2,
96
SPL_ADDR = STACK_POINTER_BASE,
97
SPH_ADDR = STACK_POINTER_BASE + 1,
99
SPL_IO_REG = SPL_ADDR - IO_REG_ADDR_BEGIN,
100
SPH_IO_REG = SPH_ADDR - IO_REG_ADDR_BEGIN,
106
Memory *mem; /* Memory were the stack will live */
107
VDevice *SP; /* Virtual Device for the stack pointer */
110
extern MemStack *memstack_new (Memory *mem);
111
extern void memstack_construct (MemStack *stack, Memory *mem);
112
extern void memstack_destroy (void *stack);
114
#endif /* SIM_STACK_H */