--- Have a look at http://home.t-online.de/home/a.h.zinn Send your answer and comments to mailto:a.h.zinn{([at]})nowhere.xy-----Ursprüngliche Nachricht----- Von: robert.d.campbell{([at]})nowhere.xy[mailto:robert.d.campbell{([at]})nowhere.xyGesendet: Mittwoch, 26. Juni 2002 11:22 An: skulski{([at]})nowhere.xyCc: blackbox{([at]})nowhere.xyBetreff: Re: Unsigned in Component Pascal > I have advanced a little bit concerning bit manipulation and >unsigned assignments. As a practical example, today I accomplished >a mundane task of packing two bytes from a byte buffer into >a 32-bit integer. Something, which in C is perhaps as simple as > > intVar = bhi<<8 + blo; > >The following code fragment is a bit more complex because the sign >bits get in the way and have to be cut. I wonder if such manipulations >are the most efficient way of packing/unpacking data. In any case, >I did not have to use SYSTEM to accomplish this. > > VAR setHi,setLo: SET; (*bit field variables (hi,lo byte)*) > > FOR i := 0 TO len-1 DO > (*Pack two consequtive bytes into an integer. MSB is first.*) > (*Cutting with bit masks avoids sign extension*) > setHi := BITS(ASH(buffer[2*i],8)) * {8..15}; > setLo := BITS( buffer[2*i+1]) * {0..7}; > histogram.bin [i] := ORD(setHi + setLo); > END; Maybe the following (untested) arithmetical approach seems more familiar: PROCEDURE BytePack (b0, b1 : BYTE) : INTEGER; VAR a, b : INTEGER; BEGIN a := b0 MOD 256; b := b1 MOD 256; RETURN ASH (b, 8) + a END BytePack; Would the 'inlined' version ROCEDURE BytePack (b0, b1 : BYTE) : INTEGER; BEGIN RETURN ASH (b1 MOD 256, 8) + (b0 MOD 256) END BytePack; use INTEGERS internally, and work the same? Robert Campbell -------------------------------------------- To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to: blackbox-request{([at]})nowhere.xyTo 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.xyCurrent 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 -------------------------------------------- To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to: blackbox-request{([at]})nowhere.xyTo 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.xyCurrent 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-2041250013_-_- Content-type: application/rtf Content-transfer-encoding: base64 Content-Disposition: attachment; filename="rtf-body.rtf" e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz d2lzc1xmY2hhcnNldDAgQXJpYWw7fQ0Ke1xmMVxmbW9kZXJuIENvdXJpZXIgTmV3O30NCntcZjJc Zm5pbFxmY2hhcnNldDIgU3ltYm9sO30NCntcZjNcZm1vZGVyblxmY2hhcnNldDAgQ291cmllciBO ZXc7fX0NCntcY29sb3J0YmxccmVkMFxncmVlbjBcYmx1ZTA7XHJlZDBcZ3JlZW4wXGJsdWUyNTU7 fQ0KXHVjMVxwYXJkXHBsYWluXGRlZnRhYjM2MCBcZjBcZnMyMCBEZWFyIFJvYmVydCwgZGVhciBX b2p0ZWssIFxwYXINClxwYXINCnlvdSBmaW5kIHNvbWUgb3RoZXIgc29sdXRpb24gYXQgc3Vic3lz dGVtIE9wYWwgaW4gdGhlIG1vZHVsZSBVdGlsIFxwYXINCmF0IENQQyBodHRwOi8vaG9tZS50LW9u bGluZS5kZS9ob21lL2EuaC56aW5uI09wYWwgXHBhcg0KXHBhcg0KSGVyZSBhcmUgb25lIGV4YW1w bGU6XHBhcg0KXHBhcg0KXHRhYiBUWVBFXHBhcg0KXHRhYiBcdGFi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GNvbnRhaW5pbmcgdGhlIHdvcmQgImhlbHAi IHRvIHRoZSBhYm92ZSBhZGRyZXNzLlxwYXINClxwYXINClNlbmQgYW55IHByb2JsZW0gcmVwb3J0 cyBvciBxdWVzdGlvbnMgcmVsYXRlZCB0byB0aGlzIGVtYWlsIGxpc3QgdG8gdGhlIGxpc3Qgb3du ZXIgYXRccGFyDQogICBvd25lci1ibGFja2JveEBvYmVyb24uY2hccGFyDQpccGFyDQpDdXJyZW50 IHBvc3RpbmcgcG9saWN5OlxwYXINClxwYXINCmEpIFRvIHBvc3QgeW91IHNob3VsZCB1c2UgdGhl IHNhbWUgYWRkcmVzcyBieSB3aGljaCB5b3UgYXJlIHN1YnNjcmliZWQgdG8gdGhlIG1haWxpbmcg bGlzdC4gVGhhdCB3YXksIHRoZSBsaXN0IHNlcnZlciB3aWxsIHJlY29nbml6ZSB5b3UgYXMgc3Vi c2NyaWJlciBhbmQgZm9yd2FyZCB5b3VyIHBvc3RpbmcgaW1tZWRpYXRlbHksIHdpdGhvdXQgY3Jl YXRpbmcgYW55IG92ZXJoZWFkLlxwYXINClxwYXINCmIpIElmLCBmb3Igc29tZSByZWFzb24sIHlv dSBjYW5ub3QgcG9zdCBmcm9tIHRoZSBhZGRyZXNzLCBieSB3aGljaCB5b3UgYXJlIHN1YnNjcmli ZWQsIHlvdXIgbWVzc2FnZSB3aWxsIGJlIG1vZGVyYXRlZCB0byBhdm9pZCBzcGFtLiBQbGVhc2Ug dW5kZXJzdGFuZCB0aGF0IG1vZGVyYXRpb24gd2lsbCBvZnRlbiBjYXVzZSBzb21lIGRlbGF5LCBp biBwYXJ0aWN1bGFyIG92ZXIgd2Vla2VuZHMgb3IgaG9seWRheXN9fQDT2wjvCQ= ----boundary-LibPST-iamunique-2041250013_-_---Received on Wed Jun 26 2002 - 12:02:08 UTC
This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:29:40 UTC