From 85435db24b0d0e74c1c1ae5d3d8d376e1811c2f6 Mon Sep 17 00:00:00 2001 From: Nicholas Mosier Date: Thu, 16 Jan 2020 17:24:35 -0500 Subject: [PATCH] initalcommit --- .gitignore | 1 + cgen.cpp | 5 ++-- demo/constants.c | 3 +++ demo/constants.z80 | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 demo/constants.c create mode 100644 demo/constants.z80 diff --git a/.gitignore b/.gitignore index 823a2a5..838e196 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ cgen-main* *.z80 *.s *.8xp +!demo/* \ No newline at end of file diff --git a/cgen.cpp b/cgen.cpp index d307c3b..03f27b6 100644 --- a/cgen.cpp +++ b/cgen.cpp @@ -795,9 +795,10 @@ namespace zc { block->instrs().push_back(new MultInstruction(&rv_bc)); block->instrs().push_back(new LoadInstruction(&rv_a, &rv_c)); break; - case word_size: + case word_size: abort(); case long_size: - abort(); + emit_crt("__imulu", block); + break; } break; diff --git a/demo/constants.c b/demo/constants.c new file mode 100644 index 0000000..7087754 --- /dev/null +++ b/demo/constants.c @@ -0,0 +1,3 @@ +int main(int argc, char **argv) { + return 1 * 2 + 3 / 4 - 1 % 6 & 8; +} diff --git a/demo/constants.z80 b/demo/constants.z80 new file mode 100644 index 0000000..8f54571 --- /dev/null +++ b/demo/constants.z80 @@ -0,0 +1,59 @@ +#include "ti84pce.inc" + +_indcall .equ __indcall + +.org userMem - 2 +.db tExtTok, tAsm84CeCmp + +_start: + ld hl, 25 + push hl + call _main + pop de + ld iy,flags + ret + +#include "crt.z80" + +_main: + push ix + ld ix,0 + add ix,sp + ld sp,ix + ld hl,8 + push hl + ld hl,6 + push hl + ld hl,1 + pop bc + call __idivu + push bc + pop hl + push hl + ld hl,4 + push hl + ld hl,3 + pop bc + call __idivu + push hl + ld hl,2 + push hl + ld hl,1 + pop de + call __imulu + pop de + add hl,de + pop de + or a,a + sbc hl,de + pop bc + call __iand + jp __frameunset_main + jp __LABEL__0 +__LABEL__0: + jp __frameunset_main +__frameunset_main: + lea ix,ix+0 + ld sp,ix + pop ix + ret