tinyvm/include/tvm/tvm_stack.h
Joseph Kogut ca87b3c5e9 Refactor with a consistent coding style
This commit refactors the project using a single, consistent coding
style, derived from the Linux Kernel Coding Style, available here:

https://www.kernel.org/doc/Documentation/CodingStyle

This includes, but is not limited to:
* Removal of typedefs, especially for structs
* Limiting lines to a reasonable length, 80 characters, mostly
* K&R style braces
* Removal of CamelCase
2016-08-28 20:31:12 -07:00

29 lines
715 B
C

#ifndef TVM_STACK_H_
#define TVM_STACK_H_
#define MIN_STACK_SIZE (2 * 1024 * 1024) /* 2 MB */
#include "tvm_memory.h"
/* Initialize our stack by setting the base pointer and stack pointer */
static inline void tvm_stack_create(struct tvm_mem *mem, size_t size)
{
mem->registers[0x7].i32_ptr =
((int32_t *)mem->mem_space) + (size / sizeof(int32_t));
mem->registers[0x6].i32_ptr = mem->registers[0x7].i32_ptr;
}
static inline void tvm_stack_push(struct tvm_mem *mem, int *item)
{
mem->registers[0x6].i32_ptr -= 1;
*mem->registers[0x6].i32_ptr = *item;
}
static inline void tvm_stack_pop(struct tvm_mem *mem, int *dest)
{
*dest = *mem->registers[0x6].i32_ptr;
mem->registers[0x6].i32_ptr += 1;
}
#endif