s502 assembler
A very simple assembler for the 6502 line of processors written in C
|
very simple int stack More...
#include <istack.h>
Public Member Functions | |
istack_ptr | istack_new () |
create an empty istack More... | |
int | istack_empty (istack_ptr istack) |
check if the istack is empty or not More... | |
int | istack_push (istack_ptr istack, int val) |
push one element to the istack More... | |
int | istack_pop (istack_ptr istack) |
pop the top of the istack More... | |
int | istack_top (istack_ptr istack, int def) |
get the top element of the istack More... | |
void | istack_free (istack_ptr istack) |
free all memory associated with a istack More... | |
Data Fields | |
int | val |
stored value More... | |
struct _istack * | next |
pointer to next element or NULL More... | |
very simple int stack
Simple stack for storing integers
Implemented with a one-sentinel singly linked list
int istack_empty | ( | istack_ptr | istack | ) |
check if the istack is empty or not
istack | the istack to check |
Simple check of the emptiness of the stack.
Simply looks at the next pointer
Definition at line 26 of file istack.c.
Referenced by istack_free(), istack_pop(), and istack_top().
void istack_free | ( | istack_ptr | istack | ) |
free all memory associated with a istack
istack | istack pointer |
Destructor of istack.
Frees all memory, including head (sentinel) node.
Invalidates all references to any elements (including head), so they all should be NULLed!
Definition at line 59 of file istack.c.
Referenced by pass_one().
istack_ptr istack_new | ( | ) |
create an empty istack
Constructor for istack.
Returns head, which will be unchanged since it's a sentinel node.
Definition at line 15 of file istack.c.
Referenced by pass_one().
int istack_pop | ( | istack_ptr | istack | ) |
pop the top of the istack
istack | the istack to pop from |
Definition at line 44 of file istack.c.
Referenced by istack_free(), and pass_one().
int istack_push | ( | istack_ptr | istack, |
int | val | ||
) |
push one element to the istack
istack | istack to push to |
val | value to push |
Push one element on the stack.
Does not modify head pointer.
Definition at line 31 of file istack.c.
Referenced by pass_one().
int istack_top | ( | istack_ptr | istack, |
int | def | ||
) |
get the top element of the istack
istack | the istack to get the top of |
def | default value if the istack is empty |
def
Definition at line 53 of file istack.c.
Referenced by pass_one().
struct _istack* istack_el::next |
pointer to next element or NULL
Definition at line 20 of file istack.h.
Referenced by istack_empty(), istack_new(), istack_pop(), istack_push(), and istack_top().
int istack_el::val |