mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Introduce command PRINTI to print integers
PRINTV prints integers in hexadecimal, PRINTI prints them in signed
decimal. For example:
PRINTT "Error at line "
PRINTI __LINE__
PRINTT "\n"
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
@@ -791,17 +791,20 @@ These three instructions type text and values to stdout. Useful for debugging
|
|||||||
<div class="Bd" style="margin-left: 5.00ex;">
|
<div class="Bd" style="margin-left: 5.00ex;">
|
||||||
<pre class="Li">
|
<pre class="Li">
|
||||||
PRINTT "I'm the greatest programmer in the whole wide world\n"
|
PRINTT "I'm the greatest programmer in the whole wide world\n"
|
||||||
PRINTV (2+3)/5
|
PRINTI (2 + 3) / 5
|
||||||
PRINTF MUL(3.14,3987.0)
|
PRINTV $FF00 + $F0
|
||||||
|
PRINTF MUL(3.14, 3987.0)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<dl class="Bl-inset">
|
<dl class="Bl-inset">
|
||||||
<dt class="It-inset"><a class="selflink" href="#PRINTT"><b class="Ic" title="Ic" id="PRINTT">PRINTT</b></a></dt>
|
<dt class="It-inset"><a class="selflink" href="#PRINTT"><b class="Ic" title="Ic" id="PRINTT">PRINTT</b></a></dt>
|
||||||
<dd class="It-inset">prints out a string.</dd>
|
<dd class="It-inset">prints out a string.</dd>
|
||||||
<dt class="It-inset"><a class="selflink" href="#PRINTV"><b class="Ic" title="Ic" id="PRINTV">PRINTV</b></a></dt>
|
<dt class="It-inset"><a class="selflink" href="#PRINTV"><b class="Ic" title="Ic" id="PRINTV">PRINTV</b></a></dt>
|
||||||
<dd class="It-inset">prints out an integer value or, as in the example, the
|
<dd class="It-inset">prints out an integer value in hexadecimal or, as in the
|
||||||
result of a calculation. Unsurprisingly, you can also print out a constant
|
example, the result of a calculation. Unsurprisingly, you can also print
|
||||||
symbols value.</dd>
|
out a constant symbols value.</dd>
|
||||||
|
<dt class="It-inset"><a class="selflink" href="#PRINTI"><b class="Ic" title="Ic" id="PRINTI">PRINTI</b></a></dt>
|
||||||
|
<dd class="It-inset">prints out a signed integer value.</dd>
|
||||||
<dt class="It-inset"><a class="selflink" href="#PRINTF"><b class="Ic" title="Ic" id="PRINTF">PRINTF</b></a></dt>
|
<dt class="It-inset"><a class="selflink" href="#PRINTF"><b class="Ic" title="Ic" id="PRINTF">PRINTF</b></a></dt>
|
||||||
<dd class="It-inset">prints out a fixed point value.</dd>
|
<dd class="It-inset">prints out a fixed point value.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -1377,6 +1380,8 @@ The options that OPT can modify are currently: <b class="Sy" title="Sy">b</b>,
|
|||||||
<dd class="It-inset"></dd>
|
<dd class="It-inset"></dd>
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#PRINTF">PRINTF</a></dt>
|
<dt class="It-inset"><a class="Sx" title="Sx" href="#PRINTF">PRINTF</a></dt>
|
||||||
<dd class="It-inset"></dd>
|
<dd class="It-inset"></dd>
|
||||||
|
<dt class="It-inset"><a class="Sx" title="Sx" href="#PRINTI">PRINTI</a></dt>
|
||||||
|
<dd class="It-inset"></dd>
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#PRINTT">PRINTT</a></dt>
|
<dt class="It-inset"><a class="Sx" title="Sx" href="#PRINTT">PRINTT</a></dt>
|
||||||
<dd class="It-inset"></dd>
|
<dd class="It-inset"></dd>
|
||||||
<dt class="It-inset"><a class="Sx" title="Sx" href="#PRINTV">PRINTV</a></dt>
|
<dt class="It-inset"><a class="Sx" title="Sx" href="#PRINTV">PRINTV</a></dt>
|
||||||
|
|||||||
@@ -504,7 +504,7 @@ static void updateUnion(void)
|
|||||||
%token <tzSym> T_POP_SET
|
%token <tzSym> T_POP_SET
|
||||||
%token <tzSym> T_POP_EQUS
|
%token <tzSym> T_POP_EQUS
|
||||||
|
|
||||||
%token T_POP_INCLUDE T_POP_PRINTF T_POP_PRINTT T_POP_PRINTV
|
%token T_POP_INCLUDE T_POP_PRINTF T_POP_PRINTT T_POP_PRINTV T_POP_PRINTI
|
||||||
%token T_POP_IF T_POP_ELIF T_POP_ELSE T_POP_ENDC
|
%token T_POP_IF T_POP_ELIF T_POP_ELSE T_POP_ENDC
|
||||||
%token T_POP_IMPORT T_POP_EXPORT T_POP_GLOBAL
|
%token T_POP_IMPORT T_POP_EXPORT T_POP_GLOBAL
|
||||||
%token T_POP_DB T_POP_DS T_POP_DW T_POP_DL
|
%token T_POP_DB T_POP_DS T_POP_DW T_POP_DL
|
||||||
@@ -648,6 +648,7 @@ simple_pseudoop : include
|
|||||||
| printf
|
| printf
|
||||||
| printt
|
| printt
|
||||||
| printv
|
| printv
|
||||||
|
| printi
|
||||||
| if
|
| if
|
||||||
| elif
|
| elif
|
||||||
| else
|
| else
|
||||||
@@ -933,6 +934,13 @@ printv : T_POP_PRINTV const
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
printi : T_POP_PRINTI const
|
||||||
|
{
|
||||||
|
if (nPass == 1)
|
||||||
|
printf("%d", $2);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
printf : T_POP_PRINTF const
|
printf : T_POP_PRINTF const
|
||||||
{
|
{
|
||||||
if (nPass == 1)
|
if (nPass == 1)
|
||||||
|
|||||||
@@ -368,6 +368,7 @@ const struct sLexInitString lexer_strings[] = {
|
|||||||
|
|
||||||
{"include", T_POP_INCLUDE},
|
{"include", T_POP_INCLUDE},
|
||||||
{"printt", T_POP_PRINTT},
|
{"printt", T_POP_PRINTT},
|
||||||
|
{"printi", T_POP_PRINTI},
|
||||||
{"printv", T_POP_PRINTV},
|
{"printv", T_POP_PRINTV},
|
||||||
{"printf", T_POP_PRINTF},
|
{"printf", T_POP_PRINTF},
|
||||||
{"export", T_POP_EXPORT},
|
{"export", T_POP_EXPORT},
|
||||||
|
|||||||
@@ -660,16 +660,19 @@ some important information.
|
|||||||
.Pp
|
.Pp
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
PRINTT \[dq]I'm the greatest programmer in the whole wide world\[rs]n\[dq]
|
PRINTT \[dq]I'm the greatest programmer in the whole wide world\[rs]n\[dq]
|
||||||
PRINTV (2+3)/5
|
PRINTI (2 + 3) / 5
|
||||||
PRINTF MUL(3.14,3987.0)
|
PRINTV $FF00 + $F0
|
||||||
|
PRINTF MUL(3.14, 3987.0)
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -inset
|
.Bl -inset
|
||||||
.It Ic PRINTT
|
.It Ic PRINTT
|
||||||
prints out a string.
|
prints out a string.
|
||||||
.It Ic PRINTV
|
.It Ic PRINTV
|
||||||
prints out an integer value or, as in the example, the result of a calculation.
|
prints out an integer value in hexadecimal or, as in the example, the result of
|
||||||
Unsurprisingly, you can also print out a constant symbols value.
|
a calculation. Unsurprisingly, you can also print out a constant symbols value.
|
||||||
|
.It Ic PRINTI
|
||||||
|
prints out a signed integer value.
|
||||||
.It Ic PRINTF
|
.It Ic PRINTF
|
||||||
prints out a fixed point value.
|
prints out a fixed point value.
|
||||||
.El
|
.El
|
||||||
@@ -1068,6 +1071,7 @@ machine.
|
|||||||
.It Sx POPO
|
.It Sx POPO
|
||||||
.It Sx POPS
|
.It Sx POPS
|
||||||
.It Sx PRINTF
|
.It Sx PRINTF
|
||||||
|
.It Sx PRINTI
|
||||||
.It Sx PRINTT
|
.It Sx PRINTT
|
||||||
.It Sx PRINTV
|
.It Sx PRINTV
|
||||||
.It Sx PURGE
|
.It Sx PURGE
|
||||||
|
|||||||
Reference in New Issue
Block a user