From 8da55212737b5c7bfb252b76316f20d0578ed6c4 Mon Sep 17 00:00:00 2001 From: apio Date: Wed, 7 Dec 2022 14:48:24 +0100 Subject: [PATCH] Add a Stack convenience class --- luna/include/luna/Stack.h | 23 +++++++++++++++++++++++ luna/src/Stack.cpp | 10 ++++++++++ 2 files changed, 33 insertions(+) create mode 100644 luna/include/luna/Stack.h create mode 100644 luna/src/Stack.cpp diff --git a/luna/include/luna/Stack.h b/luna/include/luna/Stack.h new file mode 100644 index 00000000..7870402c --- /dev/null +++ b/luna/include/luna/Stack.h @@ -0,0 +1,23 @@ +#pragma once +#include + +struct Stack +{ + Stack(u64 base, usize bytes); + + u64 bottom() + { + return m_base; + } + + u64 top(); + + usize bytes() + { + return m_bytes; + } + + private: + u64 m_base; + usize m_bytes; +}; \ No newline at end of file diff --git a/luna/src/Stack.cpp b/luna/src/Stack.cpp new file mode 100644 index 00000000..0c53e6f3 --- /dev/null +++ b/luna/src/Stack.cpp @@ -0,0 +1,10 @@ +#include + +Stack::Stack(u64 base, usize bytes) : m_base(base), m_bytes(bytes) +{ +} + +u64 Stack::top() +{ + return (m_base + m_bytes) - sizeof(void*); +} \ No newline at end of file