From 4a809ff04e570a1e00f0c2ba0321dd75badb5dae Mon Sep 17 00:00:00 2001 From: z80 Date: Fri, 18 Oct 2024 20:36:29 -0400 Subject: [PATCH] add some example huff files --- examples/add_two.huff | 10 ++++++++++ examples/add_two_consts.huff | 10 ++++++++++ examples/dummy.huff | 2 ++ examples/dummy2.huff | 2 ++ huffparser.rkt => src/huffparser.rkt | 0 lexer.rkt => src/lexer.rkt | 0 puff.rkt => src/puff.rkt | 0 7 files changed, 24 insertions(+) create mode 100644 examples/add_two.huff create mode 100644 examples/add_two_consts.huff create mode 100644 examples/dummy.huff create mode 100644 examples/dummy2.huff rename huffparser.rkt => src/huffparser.rkt (100%) rename lexer.rkt => src/lexer.rkt (100%) rename puff.rkt => src/puff.rkt (100%) diff --git a/examples/add_two.huff b/examples/add_two.huff new file mode 100644 index 0000000..8c2af80 --- /dev/null +++ b/examples/add_two.huff @@ -0,0 +1,10 @@ +#include "./dummy.huff" + +#define macro MAIN() = takes(0) returns(0) { + 0x00 calldataload // [number1] // load first 32 bytes onto the stack - number 1 + 0x20 calldataload // [number2] // load second 32 bytes onto the stack - number 2 + add // [number1+number2] // add number 1 and 2 and put the result onto the stack + + 0x00 mstore // place [number1 + number2] in memory + 0x20 0x00 return // return the result +} diff --git a/examples/add_two_consts.huff b/examples/add_two_consts.huff new file mode 100644 index 0000000..71e0841 --- /dev/null +++ b/examples/add_two_consts.huff @@ -0,0 +1,10 @@ +#include "./dummy.huff" + +#define macro MAIN() = takes(0) returns(0) { + [NAME] // load first const + [NAME2] // load second const + add // [number1+number2] // add number 1 and 2 and put the result onto the stack + + 0x00 mstore // place [number1 + number2] in memory + 0x20 0x00 return // return the result +} diff --git a/examples/dummy.huff b/examples/dummy.huff new file mode 100644 index 0000000..497e5a2 --- /dev/null +++ b/examples/dummy.huff @@ -0,0 +1,2 @@ +#include "./dummy2.huff" +#define constant NAME = 0x1234 diff --git a/examples/dummy2.huff b/examples/dummy2.huff new file mode 100644 index 0000000..ce7adba --- /dev/null +++ b/examples/dummy2.huff @@ -0,0 +1,2 @@ +#include "./included/rel.huff" +#define constant NAME2 = 0x1234 diff --git a/huffparser.rkt b/src/huffparser.rkt similarity index 100% rename from huffparser.rkt rename to src/huffparser.rkt diff --git a/lexer.rkt b/src/lexer.rkt similarity index 100% rename from lexer.rkt rename to src/lexer.rkt diff --git a/puff.rkt b/src/puff.rkt similarity index 100% rename from puff.rkt rename to src/puff.rkt