[Vm-dev] About SmalltalkImage>>calcEndianness

Guillermo Polito guillermopolito at gmail.com
Wed Mar 18 13:55:11 UTC 2015


Hi!

We are here with Stef looking at the calcEndianess method which introduces
a dependency to Form and BitBlt from SmalltalkImage.

bytes := #[0 0 0 0].  "(1 2 3 4) or (4 3 2 1)"
word := WordArray with: 16r01020304.
blt := (BitBlt toForm: (Form new hackBits: bytes))
sourceForm: (Form new hackBits: word).
blt combinationRule: Form over.  "store"
blt sourceY: 0; destY: 0; height: 1; width: 4.
blt sourceX: 0; destX: 0.
blt copyBits.  "paste the word into the bytes"
bytes first = 1 ifTrue: [^ #big].
bytes first = 4 ifTrue: [^ #little].
self error: 'Ted is confused'.

Is that code really useful? I mean, usually all machines are little endian
now, aren't they?

And in case big endianess comes back, shouldn't be easier and cheaper to do
it with just a primitive? It will be much less code than using BitBlt and
Form and some calculations, and simpler, and it looks like the
responsibility of the VM to know that...

Guille
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20150318/bbce3ba8/attachment.htm


More information about the Vm-dev mailing list