From d8c55982a780b3288073be8c054abd93530b9605 Mon Sep 17 00:00:00 2001 From: rhjr Date: Mon, 25 Nov 2024 21:44:29 +0100 Subject: [PATCH] Added: codebase constructs, types and keywords --- build.bat | 4 ++- docs/{ => appendix}/8086-manual.pdf | Bin docs/tasks | 14 ++++++++ src/eightysix.c | 23 ++++++++++++ src/eightysix.h | 53 ++++++++++++++++++++++++++++ src/main.c | 5 --- src/win32_platform.c | 8 +++++ src/win32_platform.h | 9 +++++ start.bat | 2 +- 9 files changed, 111 insertions(+), 7 deletions(-) rename docs/{ => appendix}/8086-manual.pdf (100%) create mode 100644 docs/tasks create mode 100644 src/eightysix.c create mode 100644 src/eightysix.h delete mode 100644 src/main.c create mode 100644 src/win32_platform.c create mode 100644 src/win32_platform.h diff --git a/build.bat b/build.bat index 618af27..3f135f8 100644 --- a/build.bat +++ b/build.bat @@ -6,6 +6,8 @@ if not exist ".\build" mkdir ".\build" pushd .\build -cl ..\src\main.c /Feapp.exe /nologo +set links= kernel32.lib + +cl ..\src\eightysix.c /Feeightysix.exe /nologo /link %links% popd .\build diff --git a/docs/8086-manual.pdf b/docs/appendix/8086-manual.pdf similarity index 100% rename from docs/8086-manual.pdf rename to docs/appendix/8086-manual.pdf diff --git a/docs/tasks b/docs/tasks new file mode 100644 index 0000000..e511749 --- /dev/null +++ b/docs/tasks @@ -0,0 +1,14 @@ + +Tasks + - [ ] finish the 'simple' arena implementation. + - [ ] arena_alloc + - [ ] arena_release + - [ ] String8 implementation + - [ ] String8Node and String8List. + - [ ] push node + - [ ] list join + - [ ] Convert cstring to String8. + - [ ] Convert String8 to cstring. + - [ ] Read/Write to file. + - [ ] Create CLI output. + - [ ] Testcases? diff --git a/src/eightysix.c b/src/eightysix.c new file mode 100644 index 0000000..18a8036 --- /dev/null +++ b/src/eightysix.c @@ -0,0 +1,23 @@ +j +//= rhjr: [h] + +#include "eightysix.h" +#include "win32_platform.h" + +//= rhjr: [c] + +#include "win32_platform.c" + +u8 backing_buffer[2048]; + +int +main(void) +{ + Arena arena = {0}; + arena.backing_buffer = &backing_buffer[0]; + arena.offset = 0; + arena.size = 2048; + + + return 0; +} diff --git a/src/eightysix.h b/src/eightysix.h new file mode 100644 index 0000000..6f23ff5 --- /dev/null +++ b/src/eightysix.h @@ -0,0 +1,53 @@ +#ifndef EIGHTYSIX_CORE_H +#define EIGHTYSIX_CORE_H + +#include +#include + +//= rhjr: types + +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; + +typedef int8_t i8; +typedef int16_t i16; +typedef int32_t i32; +typedef int64_t i64; + +typedef uint8_t b8; +typedef uint16_t b16; +typedef uint32_t b32; +typedef uint64_t b64; + +#define internal static +#define global static + +typedef struct String8 +{ + u8* contents; + i32 length; +} +String8; + +//= rhjr: allocator + +typedef struct Arena +{ + u8 *backing_buffer; + i32 offset; + i32 size; +} +Arena; + +//= rhjr: instructions. +// Intel 8086 manual, pg. 4-22 + +typedef enum InstrOpcode +{ + InstrOpcode_MOV = 0x22 // 0010 0010 +} +InstrOpcode; + +#endif // EIGHTYSIX_CORE_H diff --git a/src/main.c b/src/main.c deleted file mode 100644 index 77bc677..0000000 --- a/src/main.c +++ /dev/null @@ -1,5 +0,0 @@ -int -main(void) -{ - return 0; -} diff --git a/src/win32_platform.c b/src/win32_platform.c new file mode 100644 index 0000000..7aa2186 --- /dev/null +++ b/src/win32_platform.c @@ -0,0 +1,8 @@ + +String8 * +platform_write_file() +{ + String8 *result; + + return result; +} diff --git a/src/win32_platform.h b/src/win32_platform.h new file mode 100644 index 0000000..02d301d --- /dev/null +++ b/src/win32_platform.h @@ -0,0 +1,9 @@ +#ifndef WIN32_PLATFORM_H +#define WIN32_PLATFORM_H + +#define WIN32_LEAN_AND_MEAN +#include + +internal String8 * platform_write_file(Arena *arena); + +#endif // WIN32_PLATFORM_H diff --git a/start.bat b/start.bat index 0585435..3a72ce9 100644 --- a/start.bat +++ b/start.bat @@ -4,6 +4,6 @@ pushd "%~dp0" pushd build -.\app.exe +.\eightysix.exe popd