diff --git a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java index 816d3a71c..be702dbbf 100644 --- a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java +++ b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java @@ -485,10 +485,12 @@ class AsmFragmentTemplateSynthesisRule { // Use unsigned ASM to synthesize signed ASM ( ...vbs... -> ...vbu... ) synths.add(new AsmFragmentTemplateSynthesisRule("(v.s..)_(eq|neq)_(v.s..)_then_(.*)", null, null, "$1_$2_$3_then_$4", null, mapSToU)); synths.add(new AsmFragmentTemplateSynthesisRule("(v.s..)=(v.s..)", null, null, "$1=$2", null, mapSToU)); - synths.add(new AsmFragmentTemplateSynthesisRule("(v.s..)=(v.s..)_(plus|band|bxor|bor)_(v.s..)", null, null, "$1=$2_$3_$4", null, mapSToU)); + synths.add(new AsmFragmentTemplateSynthesisRule("(v.s..)=(v.s..)_(band|bxor|bor)_(v.s..)", null, null, "$1=$2_$3_$4", null, mapSToU)); synths.add(new AsmFragmentTemplateSynthesisRule("(v.s..)=(p.s..)_derefidx_(vbu..)", null, null, "$1=$2_derefidx_$3", null, mapSToU)); synths.add(new AsmFragmentTemplateSynthesisRule("(v.s..)=_(inc|dec)_(v.s..)", null, null, "$1=_$2_$3", null, mapSToU)); synths.add(new AsmFragmentTemplateSynthesisRule("(vbuz.|vbuaa|vbuxx|vbuyy)=_(lo|hi)_vws(z.|c.)", null, null, "$1=_$2_vwu$3", null, mapSToU)); + synths.add(new AsmFragmentTemplateSynthesisRule("(vbs..)=(vbs..)_(plus)_(vbs..)", null, null, "$1=$2_$3_$4", null, mapSToU)); + synths.add(new AsmFragmentTemplateSynthesisRule("(vws..)=(vws..)_(plus)_(vws..)", null, null, "$1=$2_$3_$4", null, mapSToU)); // Use constant word ASM to synthesize unsigned constant byte ASM ( ...vb.c... -> vw.c... ) synths.add(new AsmFragmentTemplateSynthesisRule("(vwuz.)=(vwuz.)_(plus|minus|band|bxor|bor)_vb.c(.)", null, null, "$1=$2_$3_vwuc$4", null, null)); diff --git a/src/test/java/dk/camelot64/kickc/test/kc/division.kc b/src/test/java/dk/camelot64/kickc/test/kc/division.kc index 62192c287..2af055087 100644 --- a/src/test/java/dk/camelot64/kickc/test/kc/division.kc +++ b/src/test/java/dk/camelot64/kickc/test/kc/division.kc @@ -1,4 +1,6 @@ -// Binary division implementation +// Simple binary division implementation +// Follows the C99 standard by truncating toward zero on negative results. +// See http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf section 6.5.5 // Remainder after signed 8 bit division byte rem8u =0; diff --git a/src/test/java/dk/camelot64/kickc/test/ref/test-division.log b/src/test/java/dk/camelot64/kickc/test/ref/test-division.log index c8b979525..bab821b75 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/test-division.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/test-division.log @@ -161,7 +161,9 @@ Adding pre/post-modifier (byte*) char_cursor ← ++ (byte*) char_cursor Adding pre/post-modifier (byte*) print_cls::sc ← ++ (byte*) print_cls::sc Importing division.kc PARSING src/test/java/dk/camelot64/kickc/test/kc/division.kc -// Binary division implementation +// Simple binary division implementation +// Follows the C99 standard by truncating toward zero on negative results. +// See http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf section 6.5.5 // Remainder after signed 8 bit division byte rem8u =0;