From 4af2a063b33e892178e656630d518e6d3801d04e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A0=CE=B1=CE=BB=CE=B1=CE=B9=CE=BF=CE=BB=CF=8C=CE=B3?= =?UTF-8?q?=CE=BF=CF=82?= Date: Thu, 21 Nov 2019 21:03:03 +0100 Subject: [PATCH] ICounter, enhanced newline. (#29) --- bfpp | 4 ++-- test/counter.asm | 16 ++++++++++++++++ test/counter.in | 0 test/counter.out | 1 + test/preprocessor_newline.asm | 4 ++-- 5 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 test/counter.asm create mode 100644 test/counter.in create mode 100644 test/counter.out diff --git a/bfpp b/bfpp index 12cf705f..ac154d98 100644 --- a/bfpp +++ b/bfpp @@ -2,6 +2,6 @@ set -o pipefail -{ cat <<<"#define NEWLINE ÿ" ; cat "$1" | sed -e "1!b" -e '/#/d' ; } | gcc -E -I. -Ilib - -o "$1.i" -perl -pe "s/\xFF/\x0A/g;" < "$1.i" | /bin/labels.pl | sed '/^#/ d' > "$1.p" +{ cat <<<"#define __NEWLINE__ ÿ"$'\n'"#define __ICOUNTER__ þ"$'\n'"" ; cat "$1" | sed -e "1!b" -e '/#/d' ; } | gcc -E -I. -Ilib - -o "$1.i" +perl -pe "s/\xFF/\x0A/g;" < "$1.i" | perl -pe 's/\xFE/$x++/ge;' | /bin/labels.pl | sed '/^#/ d' > "$1.p" rm -f "$1.i" diff --git a/test/counter.asm b/test/counter.asm new file mode 100644 index 00000000..257e891e --- /dev/null +++ b/test/counter.asm @@ -0,0 +1,16 @@ +#!/bin/bfmake + +mov r1, __ICOUNTER__ ; 0 +mov r2, __ICOUNTER__ ; 1 +mov r3, __ICOUNTER__ ; 2 +mov r4, __ICOUNTER__ ; 3 + +add r1, .0 +add r2, .0 +add r3, .0 +add r4, .0 + +out r1 +out r2 +out r3 +out r4 diff --git a/test/counter.in b/test/counter.in new file mode 100644 index 00000000..e69de29b diff --git a/test/counter.out b/test/counter.out new file mode 100644 index 00000000..6da806d7 --- /dev/null +++ b/test/counter.out @@ -0,0 +1 @@ +0123 \ No newline at end of file diff --git a/test/preprocessor_newline.asm b/test/preprocessor_newline.asm index 19c52f5d..71fd9258 100644 --- a/test/preprocessor_newline.asm +++ b/test/preprocessor_newline.asm @@ -1,7 +1,7 @@ #!/bin/bfmake -#define call(L, R) psh %L##R NEWLINE jmp %L NEWLINE @L##R +#define call(L, R) psh %L##R __NEWLINE__ jmp %L __NEWLINE__ @L##R call(label, 1) end @label out .1 -ret \ No newline at end of file +ret