[comp.sys.transputer] 3L C & the poison constant!

rando@skipper.dfrf.nasa.gov (Randy Brumbaugh) (11/07/90)

I feel I have had more than my fair share of problems with the
3L C compiler (IMHO).  Now this . . .

The 3L compiler/ assembler doesn't like the constant 0x20800000.
Yes! That's right!  It turns out that this is a very important 
constant for my application.  Here is the input:

func() { asm { ldc 0x20800000; } }

This will produce an error message about an undefined forward
reference. However, either of the following (very similar)
functions will compile:

func() { asm { ldc 0x30800000; } }

func() { asm { ldc 0x10400000; } }

Thinking it was the hex expression it didn't like, I tried good ol'
base 10:

func() { asm { ldc 545259520; } }

Same problem; same error.  Then I thought I had a way to fool the
compiler:  literal bytes of machine code.  (It was VERY important
that I load this constant - it is an address for a memory
mapped i/o register ).

func() { asm { byte 0x22, 0x20, 0x28, 0x20, 0x20, 0x20, 0x20, 0x40;}}

But the compiler caught this and barfed again!  It only seems
to happen in asm statements -- the C compiler can use the constant.
So?  If anybody has an explanation for this that is even close to
rational, I'd really like to hear it!  Or - if the error doesn't 
happen on your system!  I have V 2.0 of the compiler, which I admit 
is one rev out, but this behavior is way out!

If you care, I did fool the compiler and load the constant like this:

func() {
  asm { ldc 0x10400000;
        ldc 2;
        shl; } }

I also figured I could use Norton Utils and patch the .bin file.  These
methods will work while I scrape money together for a Logical Systems
C compiler.

Randy Brumbaugh
rando@skipper.dfrf.nasa.gov

rando@skipper.dfrf.nasa.gov (Randy Brumbaugh) (11/07/90)

I meant "ldc 1" NOT "ldc 2" in the code at the end of
the original posting.
I expect I'll get enough interesting replies without this 
little mistake.

Sorry.

galuska@udel.edu (Scott Galuska) (11/08/90)

In article <671@skipper.dfrf.nasa.gov> rando@skipper.dfrf.nasa.gov (Randy Brumbaugh) writes:
>I feel I have had more than my fair share of problems with the
>3L C compiler (IMHO).  Now this . . .

>The 3L compiler/ assembler doesn't like the constant 0x20800000.
>Yes! That's right!  It turns out that this is a very important 
>constant for my application.  Here is the input:

>func() { asm { ldc 0x20800000; } }

>This will produce an error message about an undefined forward
>reference. However, either of the following (very similar)
>functions will compile:

Welcome to the club!  I had a very similar problem- for me, it choked on

ldc 32;  /* decimal */

And I tried also to fool it- I used hex, octal, binary.  didn't like any of 
'em!  

What I eventually did was to assign the value to a variable outside of the asm
section and then use the variable.  That worked.

>rational, I'd really like to hear it!  Or - if the error doesn't 
>happen on your system!  I have V 2.0 of the compiler, which I admit 
>is one rev out, but this behavior is way out!

This alos happened to me in V2.0.  When I upgraded to V2.1, the error went 
away.  I also tried yours on V2.1- it compiled just fine.



--
Scott Galuska
Dept. of Computer & Info. Science                   
Univ of Delaware                                    
galuska@dewey.udel.edu