From 001b95d12a9d89d4f084ce1155c0685b76089b8a Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Tue, 11 Feb 2020 11:25:22 +0100 Subject: [PATCH] Add SHIFT with numeric argument Fixes #442. --- src/asm/asmy.y | 6 ++++++ test/asm/arg-shift.asm | 21 +++++++++++++++++++++ test/asm/arg-shift.err | 0 test/asm/arg-shift.out | 2 ++ 4 files changed, 29 insertions(+) create mode 100644 test/asm/arg-shift.asm create mode 100644 test/asm/arg-shift.err create mode 100644 test/asm/arg-shift.out diff --git a/src/asm/asmy.y b/src/asm/asmy.y index 9df5a5ed..04ba580d 100644 --- a/src/asm/asmy.y +++ b/src/asm/asmy.y @@ -777,6 +777,12 @@ warn : T_POP_WARN string { warning(WARNING_USER, "%s", $2); } ; shift : T_POP_SHIFT { sym_ShiftCurrentMacroArgs(); } + | T_POP_SHIFT uconst + { + int32_t i = $2; + while (i--) + sym_ShiftCurrentMacroArgs(); + } ; load : T_POP_LOAD string comma sectiontype sectorg sectattrs diff --git a/test/asm/arg-shift.asm b/test/asm/arg-shift.asm new file mode 100644 index 00000000..fddf9ab4 --- /dev/null +++ b/test/asm/arg-shift.asm @@ -0,0 +1,21 @@ +print_all: MACRO + REPT _NARG + PRINTT " \1" + SHIFT + ENDR + PRINTT "\n" +ENDM + +print_some: MACRO + PRINTT "\1" + SHIFT 5 + PRINTT "\2\6\9" + SHIFT 17 + SHIFT + PRINTT "\3\9" +ENDM + + + print_all This test, probably, passes\,, but who knows, ? + + print_some R,e,d,n,e,x,G,a,m,e,B,o,y,D,e,v,e,l,o,p,e,m,e,n,t,S,y,s,t,e,m,\n diff --git a/test/asm/arg-shift.err b/test/asm/arg-shift.err new file mode 100644 index 00000000..e69de29b diff --git a/test/asm/arg-shift.out b/test/asm/arg-shift.out new file mode 100644 index 00000000..0c998383 --- /dev/null +++ b/test/asm/arg-shift.out @@ -0,0 +1,2 @@ + This test probably passes, but who knows ? +RGBDS