From 5ce0eec69175339483fb23ee9ba6e888629b50bb Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Fri, 14 Sep 2018 03:48:52 -0400 Subject: [PATCH 1/2] Save 2 bytes each in push and pop stack `ADD` supports a direct operand, so why not use it? --- c8c.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/c8c.c b/c8c.c index 6da9b8c..17d8887 100644 --- a/c8c.c +++ b/c8c.c @@ -542,15 +542,13 @@ static void gfpush() { print("\tLD F,VE"); print("\tLD [I],VE"); - print("\tLD VF,0x03"); - print("\tADD VE,VF"); + print("\tADD VE,0x03"); } // Generate frame pop. static void gfpop() { - print("\tLD VF,0x03"); - print("\tSUB VE,VF"); + print("\tSUB VE,0x03"); print("\tLD VF,V%1X", v); print("\tLD F,VE"); print("\tLD VE,[I]"); From f2bd7a8b396281cf6bdfbefe45be707a1fe72bfc Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Mon, 17 Sep 2018 04:55:49 -0400 Subject: [PATCH 2/2] Use ADD instead of SUB SUB doesn't allow direct operands, but ADD does. --- c8c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c8c.c b/c8c.c index 17d8887..c35d340 100644 --- a/c8c.c +++ b/c8c.c @@ -548,7 +548,7 @@ static void gfpush() // Generate frame pop. static void gfpop() { - print("\tSUB VE,0x03"); + print("\tADD VE,0xFD ; SUB VE, 0x03"); print("\tLD VF,V%1X", v); print("\tLD F,VE"); print("\tLD VE,[I]");