Skip to content

Instantly share code, notes, and snippets.

@hUwUtao
Created July 1, 2023 15:38
Show Gist options
  • Save hUwUtao/2d8dc51b8f56c1858b891bd2e23a84a5 to your computer and use it in GitHub Desktop.
Save hUwUtao/2d8dc51b8f56c1858b891bd2e23a84a5 to your computer and use it in GitHub Desktop.
pseudocode language with custom runtime machine (prototype) version 2

no scalar, no flow control (abstract thing), only pseudo code

welcome to hell. there is no recursive

memory management

the memory is a table with fixed size

# 0 1 2 3 4 5 6 7 f
00 0 1 0 1 0 1 0 1 x
01 0 1 0 1 0 1 0 1 x
02 0 1 0 1 0 1 0 1

where f byte indicate the start of a alloc

so that we allocated an i8/u8 value and an i16/u16 value

an allocation

"buffer"

nothing to relate atm

the program have full control over the "buffer". a buffer is a pointer to a value start (it actually dont care if it point to f = 0). on a normal processing unit, a buffer stored inside the processing unit. a buffer (pointer) size n byte, so the maximum memory allocate-able to the program up to 2^n cell, or 2^n byte

memory management #2

given a data structure

// assume that int is i32 (4 byte) (i dont remember tho)
// and char is 1 byte
struct dog {
  int age;
  // 2 chars who knows ;)
  char[2] gender;
}
// we knew that the whole struct sums up to 6 byte
// anyway this is c, abt pseudo codestyle later

and it will allocate 6 byte (and ignore everything else)

0a x
0a
0a
0a
0b
0b
00 x // reserve for next allocation

so if the static type size not match the allocation size, it just panic

thats all about "machine" memory capable to run this language.

language design

the whole language build on codebase clean-ability

heres the example

// fizzbuzz.superseriousextensionnamethatveryshort
i8 i = 0
   c = 0
i8[8] buf = ""

reduce i += 1 until i <= 100 // please dont write this in production if yes (this is cp cheat lol)
  // we dont have a string lib yet
  buf = 0 // wtf this wipe the alloc data
  c = 0
  i % 3 == 0
    buf = "Fizz\0\0\0\0" // actually "Fizz" is enough
  i % 5 == 0
    buf ^= "\0\0\0\0Buzz"
  reduce c += 1 until c < sizeof(buf)
    buf[c] && putc buf[c]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment