Path: news.cs.au.dk!Morten.Grouleff From: Morten Grouleff Newsgroups: comp.lang.beta Subject: Re: How to do low level stuff Date: 08 Jan 1999 08:59:39 +0100 Organization: Mjolner Informatics Lines: 61 Message-ID: References: <368B8A70.CF9934FF@thestar.ca> <36950D20.2FAD4D18@thestar.ca> NNTP-Posting-Host: fenris.mjolner.dk Mime-Version: 1.0 (generated by tm-edit 7.106) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: xinwen.cs.au.dk 915782426 5920 255.255.255.255 (8 Jan 1999 08:00:26 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 8 Jan 1999 08:00:26 GMT X-Newsreader: Gnus v5.5/Emacs 19.34 Xref: news.cs.au.dk comp.lang.beta:11770 Karl Waclawek writes: [...] > I thought BETA did not make specific assumptions about the size and > the byte ordering of the basic types. From what your code shows, > however, it seems that one can assume that Char is stored in one Byte > and that Integer is stored in 4 Bytes. My Pascal code really relies on > the fact that a LongWord consists of 4 bytes ordered in a specific > way. As far as your code goes, I think the semantics are right, but it > relies on the byte ordering too (as well as bit shifting semantics). > I also think that the CRC algorithm dependens on the byte ordering, > but I don't know for sure. No, not really. You can read the shift as (CRC div (2^24)), which doesn't rely on any specific byte ordering. The only difference is that you can control the sign of the result when using shifts, whereas with the div operation the sign depends on the type. (In the next release of the Mjolner System, there are both signed and unsigned integers.) There is nothing in the CRC algorithm that depends on how integers are laid out in memory (Often called Little Endian vs. Big Endian). [...] > > Two questions: > > 1) About CRCType: (# R: [4]@Char #): > Why can one not declare a type that is a repetition? > Like this, for example: CRCType: [4]Char; I can't answer that. > 2) Char is currently compatible with integer operations and assignments. > I am not sure where I read that, but it appears that that will not remain > a part of the language. Is that true or am I just confused? No, Chars and Integers will remain, and so will assignment among them as far as I know. Maybe you are confusing it with assignment of integers to booleans. The compiler allows that for now, but warns that it may stop doing so. > From what I can see, with the ability to treat a Char simply as a Byte > and the new bit processing operators (that can be applied to it) a lot > of low level functionality is gained. The efficiency remains to be > tested. If the example above works right, then I will try to use it to > calculate the CRC for a large file and compare it with my Delphi > version, both, for correctness and performance. Btw, my example was > not a good demonstration for the need for bit-shifting, since it does > really need it. I am sure, however, that there are such examples. ^ ^ NOT (Right?) Agreed. The CRC example is not easy to do without the %Bxor though. Regards, -- ** Morten Grouleff: ** ** Earthworm Jim PC: ** ** Mjølner Informatics: **