From 220575dc4a70228438ed6f4a10324f5669277044 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Tue, 18 Sep 2018 16:21:53 -0700 Subject: 4549 - RIP transect --- transect/Readme | 6 ++++++ transect/compiler10 | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 transect/Readme (limited to 'transect') diff --git a/transect/Readme b/transect/Readme new file mode 100644 index 00000000..821ccde0 --- /dev/null +++ b/transect/Readme @@ -0,0 +1,6 @@ +Abortive series of attempts at building a bootstrappable low-level language. +Type-checked, but feasible to implement in some sort of notation for machine +code (like SubX). + +The latest version is in compiler10. But it doesn't account for checking +how programs allocate registers. diff --git a/transect/compiler10 b/transect/compiler10 index 37cf67ab..ce0e487a 100644 --- a/transect/compiler10 +++ b/transect/compiler10 @@ -132,6 +132,9 @@ Operands are always scalar. Variables on the stack or global segment are immutab - Variables on the stack are stored at addresses like *(EBP+n) - Global variables are stored at addresses like *disp32, where disp32 is a statically known constant + #define local(n) 1/mod 4/rm32/SIB 5/base/EBP 4/index/none 0/scale n/disp8 + #define disp32(N) 0/mod 5/rm32/include-disp32 N/disp32 + Since the language will not be orthogonal, compilation proceeds by pattern matching over a statement along with knowledge about the types of its operands, as well as where they're stored (register/stack/global). We now enumerate mappings for various categories of statements, based on the type and location of their operands. Many statements will end up encoding to the exact same x86 instructions. But the types differ, and they get type-checked differently along the way. -- cgit 1.4.1-2-gfad0