Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

IMCC, PASM and constants/macros

9 views
Skip to first unread message

Clinton A. Pierce

unread,
May 26, 2003, 6:55:55 PM5/26/03
to perl6-i...@perl.org
I'm having a really awful bootstrapping problem here. I've got the core of
BASIC producing *documented* valid IMCC, but I can't test it because I'm
stumped as to how to roll the portions that need to be in PASM.

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?


Will Coleda

unread,
May 26, 2003, 11:57:42 PM5/26/03
to Clinton A. Pierce, perl6-i...@perl.org
Perhaps "macros only work in assembler mode" is the issue?

http://www.mail-archive.com/perl6-i...@perl.org/msg14107.html

Regards.

Leopold Toetsch

unread,
May 27, 2003, 2:18:08 AM5/27/03
to Clinton A. Pierce, perl6-i...@perl.org
Clinton A. Pierce <cli...@geeksalad.org> wrote:

> 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

Clinton A. Pierce

unread,
May 27, 2003, 8:01:51 AM5/27/03
to Will Coleda, perl6-i...@perl.org
At 11:57 PM 5/26/2003 -0400, Will Coleda wrote:
>Perhaps "macros only work in assembler mode" is the issue?
>
>http://www.mail-archive.com/perl6-i...@perl.org/msg14107.html
>
>Regards.

It was, but I was looking for the "why" of it. Leo answered that ("IMCC
has .const") so I'm all set now.


Bryan C. Warnock

unread,
May 27, 2003, 5:45:18 PM5/27/03
to Clinton A. Pierce, perl6-i...@perl.org

Is there is reason not to s/\.constant/.const/g for consistency's sake?

--
Bryan C. Warnock
bwarnock@(gtemail.net|raba.com)

Leopold Toetsch

unread,
May 28, 2003, 2:23:22 AM5/28/03
to Bryan C. Warnock, perl6-i...@perl.org
Bryan C. Warnock <bwar...@raba.com> wrote:

> 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

Clinton A. Pierce

unread,
May 28, 2003, 11:13:45 AM5/28/03
to Bryan C. Warnock, perl6-i...@perl.org
At 05:45 PM 5/27/2003 -0400, you wrote:
>On Tue, 2003-05-27 at 08:01, Clinton A. Pierce wrote:
> > At 11:57 PM 5/26/2003 -0400, Will Coleda wrote:
> > >Perhaps "macros only work in assembler mode" is the issue?
> > >
> > >http://www.mail-archive.com/perl6-i...@perl.org/msg14107.html
> > >
> > >Regards.
> >
> > 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?

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

Clinton A. Pierce

unread,
May 28, 2003, 11:21:01 AM5/28/03
to Bryan C. Warnock, perl6-i...@perl.org
At 11:13 AM 5/28/2003 -0400, Clinton A. Pierce wrote:
># These are vastly simplified, but give you the idea

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. :)


Leopold Toetsch

unread,
May 28, 2003, 12:43:52 PM5/28/03
to Clinton A. Pierce, perl6-i...@perl.org
Clinton A. Pierce <cli...@geeksalad.org> wrote:

> 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

Bryan C. Warnock

unread,
May 28, 2003, 9:35:55 PM5/28/03
to Clinton A. Pierce, perl6-i...@perl.org
On Wed, 2003-05-28 at 11:13, Clinton A. Pierce wrote:
> >
> >Is there is reason not to s/\.constant/.const/g for consistency's sake?
>
> And actually, on further consideration, .const isn't what I want
> either.

Which doesn't invalidate my question. :-)

0 new messages