----boundary-LibPST-iamunique-1211733416_-_-
Content-type: text/plain
Bernard:
thank you for the message. You have neatly separated the problem
into two parts: one is making calculations, the other is making
assignments to variables. I am less concerned about calculations,
because as you said one can always use a larger variable. Well,
almost always, because the 64-bit is a limit. Also, the bit extension
kicks in, and this is making extra bits, which can make life
interesting. Let's leave this aside.
My more immediate concern is how to make assignments of bit patterns
such as 0ABH to a variable of a given bit width. These variables are
directly mapped onto C-style DLL variables like UCHAR or USHORT.
I have spent considerable time reading C-headers and trying to match
these to variable types CP is giving me. The interesting part is
C structures and pointers to C structures.
Unless I am missing some part of the BlackBox docu, it seems to me
they have basically left this whole topic away. There is a page
about DLLs, but practical details are scarce.
In the past, every compiler vendow would have documented the bit
layout of their variables. This would make interfacing between
say Fortran and C doable. The BB documentatin does not say much
how their variables are laid out in memory. This becomes a critical
issue once I want to talk to an embedded 8051 microcontroller.
I wish OuS provided more down-to-the earth documentation.
They devoted parts of their docu discussing merits and demerits
of CP versus Java, as if anybody was reading this (did you?).
They did not tell much how to assign bit patterns to variables.
Oh, well.
Wojtek Skulski skulski{([at]})nowhere.xy
On Mon, 17 Jun 2002, Treutwein Bernhard wrote:
> Hi Wojtek,
>
> afaik, this is not (yet) a FAQ.
>
> I guess that leaving out unsigned arithmetic was a deliberate
> decision, although I also sometimes miss them.
>
> The times of necessity to use variables, which are as small
> as possible, seems to have vanished (except for embedded
> systems).
>
> Let me ask: Do you really need the aritmetic on BYTE ?
>
> If you do not need it, this might be a solution:
>
> MODULE PrivTest;
> PROCEDURE TEST;
> VAR test:SHORTCHAR;
> BEGIN
> test := 0ABX (*number too large*)
> END TEST;
> END PrivTest.
>
> If you need them, I fear you'll have to use another
> variable and do some conversion:
>
> MODULE PrivTest;
> PROCEDURE TEST*;
> VAR test:SHORTCHAR; number : SHORTINT;
> BEGIN
> test := 0ABX (*number too large*);
> number := ORD(test);
> HALT(0)
> END TEST;
> END PrivTest.TEST
>
> For arithmetic (?) with BYTE a word of caution:
>
> VAR b : BYTE;
> FOR b := MIN(BYTE) TO MAX(BYTE) DO SomeThing END;
>
> is an endless loop, since overflow is silently wrapped
> (this is absolutely correct, given the definition of
> the FOR loop in terms of a WHILE loop.
>
> VAR s : SHORTINT;
> FOR s := MIN(BYTE) TO MAX(BYTE) DO SomeThing END;
>
> works as expected.
>
>
> > -----Original Message-----
> > From: Wojtek Skulski [mailto:skulski{([at]})nowhere.xy> > Sent: Monday, June 17, 2002 5:43 AM
> > To: BlackBox
> > Cc: Wojtek Skulski
> > Subject: Unsigned in Component Pascal
> >
> >
> >
> > Hi:
> >
> > this must be a FAQ, but let me ask. How can I treat
> > a CP varaiable as an unsigned number, such that I can
> > easily converse with C libraries?
> >
> > Specifically, the following does not compile with a message
> > "number too large", even though it would fit as an unsigned
> > bit pattern in the BYTE variable.
> >
> > Any idea how to make it compile without violating the "CP spirit"
> > in some major way?
> >
> > MODULE TestTest;
> > PROCEDURE TEST;
> > VAR test:BYTE;
> > BEGIN
> > test := 0ABH (*number too large*)
> > END TEST;
> > END TestTest.
> >
> > As a side remark, lack of unsigned numerics in CP looks
> > like a major pain to me. I did not realize this until started
> > interfacing CP to Windows DLL's.
> >
> >
> > Wojtek Skulski skulski{([at]})nowhere.xy> >
> >
> > --------------------------------------------
> >
> > To unsubscribe from this mailing list, send a message
> > containing the word "unsubscribe" to:
> > blackbox-request{([at]})nowhere.xy> >
> > To get a list of valid e-mail commands and instructions on
> > their usage, send a message containing the word "help" to the
> > above address.
> >
> > Send any problem reports or questions related to this email
> > list to the list owner at
> > owner-blackbox{([at]})nowhere.xy> >
> > Current posting policy:
> >
> > a) To post you should use the same address by which you are
> > subscribed to the mailing list. That way, the list server
> > will recognize you as subscriber and forward your posting
> > immediately, without creating any overhead.
> >
> > b) If, for some reason, you cannot post from the address, by
> > which you are subscribed, your message will be moderated to
> > avoid spam. Please understand that moderation will often
> > cause some delay, in particular over weekends or holydays.
> >
>
----boundary-LibPST-iamunique-1211733416_-_-
Content-type: application/rtf
Content-transfer-encoding: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