-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack.h
47 lines (39 loc) · 2.28 KB
/
stack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/********************************************************************************
* stack.h: Contains function declarations and macro definition for
* implementation of 1 kB stack (1024 x 1 byte = 1024 byte).
********************************************************************************/
#ifndef STACK_H_
#define STACK_H_
/* Include directives: */
#include "cpu.h"
/* Macro definitions: */
#define STACK_ADDRESS_WIDTH 100 /* 1024 unique addresses on the stack. */
#define STACK_DATA_WIDTH 32 /* 32 bit storage capacity per address. */
/********************************************************************************
* stack_reset: Clears content on the entire stack and sets the stack pointer
* to the top of the stack.
********************************************************************************/
void stack_reset(void);
/********************************************************************************
* stack_push: Pushes 8 bit value to the stack, unless the stack is full.
* Success code 0 is returned after successful push, otherwise
* error code 1 is returned if the stack is already full.
*
* - value: 8 bit value to push to the stack.
********************************************************************************/
int stack_push(const uint32_t value);
/********************************************************************************
* stack_pop: Returns 8 bit value popped from the stack. If the stack is empty,
* the value 0x00 is returned.
********************************************************************************/
uint32_t stack_pop(void);
/********************************************************************************
* stack_pointer: Returns the 16 bit address of the stack pointer.
********************************************************************************/
uint16_t stack_pointer(void);
/********************************************************************************
* stack_last_added_value: Returns the last added value to the stack. If the
* stack is empty, the value 0x00 is returned.
********************************************************************************/
uint32_t stack_last_added_value(void);
#endif /* STACK_H_ */