The runtime has some bits in it that are more easily hand-rolled in
IMCC-ish PASM. For example, I'm going to redo all of BASIC's standard
library of builtins and whatnot to use the Current Calling
Conventions. There are some parts of a BASIC runtime that need to exist as
long-lived globals (DATA's data, DIM values, screen positioning
information, etc..) that I've got stashed in a few PMC's.
I'd *like* to salvage my sanity and refer to these things with meaningful
names (DATAINDEX instead of P16) and at the same time use the IMCC goodness
to put the library together. But I can't mix IMCC and PASM in any
meaningful way if there are constant directives.
Is there a reason that .constant (which seems implemented in .macro) can be
used in .pasm files, but not .imc files? Can it be?
http://www.mail-archive.com/perl6-i...@perl.org/msg14107.html
Regards.
> Is there a reason that .constant (which seems implemented in .macro) can be
> used in .pasm files, but not .imc files? Can it be?
.constant is the old (untyped) PASM syntax. IMCC has .const:
.const int ID = 42
HTH
leo
It was, but I was looking for the "why" of it. Leo answered that ("IMCC
has .const") so I'm all set now.
Is there is reason not to s/\.constant/.const/g for consistency's sake?
--
Bryan C. Warnock
bwarnock@(gtemail.net|raba.com)
> Is there is reason not to s/\.constant/.const/g for consistency's sake?
The difference is, that PASM did define an untyped variant:
.constant FOO 42
PIR Syntax is:
.const int FOO = 42
I'm ok with tossing the PASM variant, its barely used (only in macro.t)
and changing assemble.pl should be easy.
leo
And actually, on further consideration, .const isn't what I want
either. What I really want is a #define directive for general-purpose
(simple) compile-time substitutions. For example, to refer to a Px
register that I'm going to need on-and-off through a program's life to
manage BASIC's internal stuff.
# These are vastly simplified, but give you the idea
.define BASICARR $P9999
.sub _DIMENSION # void DIMENSION(string array)
saveall
.param string array
new $P0, .PerlArray
BASICARR[array] = $P0
restoreall
.end
.sub _ARR_LOOKUP # string ARR_LOOKUP(string key)
saveall
.param string key
set $S0, BASICARR[key]
.return $S0
restoreall
.end
And of course, by "vastly simplified" I meant "completely wrong" because
the sample shown won't work because of the saveall and restoreall before
and after the array creation in _DIMENSION. But you still get the idea. :)
> And actually, on further consideration, .const isn't what I want
> either.
You are looking vor .sym/.local:
.local PerlHash BASICARR
.sub _main
BASICARR = new PerlHash
.arg "value"
.arg "x"
call _DIMENSION
.arg "x"
call _ARR_LOOKUP
.local string res
.result res
print res
end
.end
.sub _DIMENSION # void DIMENSION(string array)
saveall
.param string key
.param string value
BASICARR[key] = value
restoreall
ret
.end
.sub _ARR_LOOKUP # string ARR_LOOKUP(string key)
saveall
.param string key
$S0 = BASICARR[key]
.return $S0
restoreall
ret
.end
This is similar to yours, except, I used a PerlHash (you seem to like
store/retrieve strings).
This works with this patch to imcc (identifiers where not considered as
array/hash keys):
--- ../parrot/languages/imcc/pbc.c Wed May 14 17:37:08 2003
+++ languages/imcc/pbc.c Wed May 28 18:36:34 2003
@@ -615,6 +615,7 @@
if (r->reg)
r = r->reg;
switch (r->type) {
+ case VTIDENTIFIER: /* P[S0] */
case VTPASM: /* P[S0] */
case VTREG: /* P[S0] */
if (r->set == 'I')
leo
Which doesn't invalidate my question. :-)