Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
ICounter, enhanced newline. (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
kspalaiologos authored Nov 21, 2019
1 parent f77fedd commit 4af2a06
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bfpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
16 changes: 16 additions & 0 deletions test/counter.asm
Original file line number Diff line number Diff line change
@@ -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
Empty file added test/counter.in
Empty file.
1 change: 1 addition & 0 deletions test/counter.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0123
4 changes: 2 additions & 2 deletions test/preprocessor_newline.asm
Original file line number Diff line number Diff line change
@@ -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
ret

0 comments on commit 4af2a06

Please sign in to comment.