#wcc

Wren 💜 (fae/fem/she/they)

Today I’ve been working on getting the wcc executable to be as small as possible, including size optimizations, binary stripping, compiling statically, using my own stdlib, using defines to turn some features off. So far I’ve made it all the way down to just 36K! That’s small enough to fit into the uxn varvara system’s memory. Of course that’s x86 instructions, and varvara compilation might be bigger, but it might just work! #wcc

Wren 💜 (fae/fem/she/they)

I added local variables so now I can compile code like this: #wcc

format ELF64

public main

extrn printf
main:
  push rbp ; prelude
  mov rbp, rsp
  push 0 ; push_int
  ; define_local 0
  lea rax, [rbp-0*8] ; push_local_variable
  push rax
  push 1 ; push_int
...
int printf(char const *fmt, ...);

int main(void) {
	int a;
	a = 1;
	printf("Hello, World! %d\n", a);

	return 0;
}

Wren 💜 (fae/fem/she/they)

oh, I forgot to attach the assembly in my last post, here it is!

format ELF64

public main

extrn printf
main:
  push rbp ; STACK_FRAME
  mov rbp, rsp
  push printf ; PUSH_GLOBAL_LABEL
  push _str_0 ; PUSH_STRING "Hello, World!\n"
  pop rdi ; CALL 1
  pop r11
...

Wren 💜 (fae/fem/she/they)

I wrote a small C compiler called wcc! It’s not much at the moment, but it’s capable of compiling a small hello world program and I think it’s already super neat :) I attached the generated assembly (which can be compiled with FASM and linked with the c standard library) because I think the generated code is very interesting. The IR is [stack-based](https://en…