mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
@@ -168,12 +168,12 @@ void macro_ShiftCurrentArgs(int32_t count)
|
|||||||
{
|
{
|
||||||
if (!macroArgs) {
|
if (!macroArgs) {
|
||||||
error("Cannot shift macro arguments outside of a macro\n");
|
error("Cannot shift macro arguments outside of a macro\n");
|
||||||
} else if (count < 0) {
|
|
||||||
error("Cannot shift arguments by negative amount %" PRId32 "\n", count);
|
|
||||||
} else if (macroArgs->shift < macroArgs->nbArgs) {
|
} else if (macroArgs->shift < macroArgs->nbArgs) {
|
||||||
macroArgs->shift += count;
|
macroArgs->shift += count;
|
||||||
if (macroArgs->shift > macroArgs->nbArgs)
|
if (macroArgs->shift > macroArgs->nbArgs)
|
||||||
macroArgs->shift = macroArgs->nbArgs;
|
macroArgs->shift = macroArgs->nbArgs;
|
||||||
|
else if (macroArgs->shift < 0)
|
||||||
|
macroArgs->shift = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1487,6 +1487,7 @@ This is the only way of accessing the value of arguments from 10 to 256.
|
|||||||
.Pp
|
.Pp
|
||||||
.Ic SHIFT
|
.Ic SHIFT
|
||||||
can optionally be given an integer parameter, and will apply the above shifting that number of times.
|
can optionally be given an integer parameter, and will apply the above shifting that number of times.
|
||||||
|
A negative parameter will shift the arguments in reverse.
|
||||||
.Ss Printing things during assembly
|
.Ss Printing things during assembly
|
||||||
The
|
The
|
||||||
.Ic PRINT
|
.Ic PRINT
|
||||||
|
|||||||
@@ -1,4 +1,16 @@
|
|||||||
|
reverse: MACRO
|
||||||
|
for i, _NARG
|
||||||
|
i = _NARG - i - 1
|
||||||
|
shift i
|
||||||
|
println \1
|
||||||
|
shift -i
|
||||||
|
endr
|
||||||
|
ENDM
|
||||||
|
|
||||||
|
reverse $1, $2, $3
|
||||||
|
|
||||||
m: MACRO
|
m: MACRO
|
||||||
|
shift 2
|
||||||
shift -3
|
shift -3
|
||||||
ENDM
|
ENDM
|
||||||
m
|
m
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
ERROR: shift-negative.asm(4) -> shift-negative.asm::m(2):
|
|
||||||
Cannot shift arguments by negative amount -3
|
|
||||||
error: Assembly aborted (1 errors)!
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
$3
|
||||||
|
$2
|
||||||
|
$1
|
||||||
|
|||||||
Reference in New Issue
Block a user