UninterpretedBytes.st
changeset 22161 d941d4d4246e
parent 22102 a1ffa53d31c7
child 22215 10bdeb2e5021
--- a/UninterpretedBytes.st	Thu Aug 03 16:45:38 2017 +0200
+++ b/UninterpretedBytes.st	Fri Aug 04 11:32:32 2017 +0200
@@ -488,7 +488,7 @@
 doubleWordAt:index
     "return the 4-bytes starting at index as an (unsigned) Integer.
      The index is a smalltalk index (i.e. 1-based).
-     The value is retrieved in the machines natural byte order."
+     The value is retrieved in the machine's natural byte order."
 
     ^ self unsignedInt32At:index MSB:IsBigEndian
 
@@ -499,7 +499,8 @@
      (b doubleWordAt:1) printStringRadix:16
     "
 
-    "Modified: / 5.3.1998 / 14:57:35 / stefan"
+    "Modified: / 05-03-1998 / 14:57:35 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:15:29 / cg"
 !
 
 doubleWordAt:index MSB:msb
@@ -524,7 +525,7 @@
      The index is a smalltalk index (i.e. 1-based).
      The value should be in the range 0 to 16rFFFFFFFF
      (for negative values, the stored value is not defined).
-     The value is stored in the machines natural byte order."
+     The value is stored in the machine's natural byte order."
 
    ^ self unsignedInt32At:byteIndex put:anInteger MSB:IsBigEndian
 
@@ -535,7 +536,8 @@
      b inspect
     "
 
-    "Modified: / 5.3.1998 / 14:57:48 / stefan"
+    "Modified: / 05-03-1998 / 14:57:48 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:15:38 / cg"
 !
 
 doubleWordAt:byteIndex put:anInteger MSB:msb
@@ -611,7 +613,7 @@
 int16At:byteIndex
     "return the 2-bytes starting at index as a signed Integer.
      The index is a smalltalk index (i.e. 1-based).
-     The value is retrieved in the machines natural byte order.
+     The value is retrieved in the machine's natural byte order.
      This may be worth a primitive."
 
     ^ self signedInt16At:byteIndex
@@ -623,7 +625,8 @@
      b signedWordAt:1
     "
 
-    "Modified: 1.7.1996 / 21:14:38 / cg"
+    "Modified: / 01-07-1996 / 21:14:38 / cg"
+    "Modified (comment): / 04-08-2017 / 11:15:48 / cg"
 !
 
 int16At:byteIndex MSB:msb
@@ -689,7 +692,7 @@
 longAt:index
     "return the 4-bytes starting at index as a signed Integer.
      The index is a smalltalk index (i.e. 1-based).
-     The value is retrieved in the machines natural byte order,
+     The value is retrieved in the machine's natural byte order,
      therefore, this should only be used for byte-data which is
      only used inside this machine.
      To setup data packets which are to be sent to other machines,
@@ -705,8 +708,9 @@
      (b longAt:1)
     "
 
-    "Modified: / 1.7.1996 / 21:11:28 / cg"
-    "Modified: / 5.3.1998 / 12:06:28 / stefan"
+    "Modified: / 01-07-1996 / 21:11:28 / cg"
+    "Modified: / 05-03-1998 / 12:06:28 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:15:58 / cg"
 !
 
 longAt:index bigEndian:msb
@@ -759,7 +763,7 @@
 longLongAt:index
     "return the 8-bytes starting at index as a signed Integer.
      The index is a smalltalk index (i.e. 1-based).
-     The value is retrieved in the machineƄs natural byte order.
+     The value is retrieved in the machine's natural byte order.
      This may be worth a primitive."
 
     ^ self signedInt64At:index MSB:IsBigEndian
@@ -771,9 +775,9 @@
      (b longLongAt:1)
     "
 
-    "Modified: / 1.7.1996 / 21:11:28 / cg"
-    "Created: / 5.3.1998 / 14:40:05 / stefan"
-    "Modified: / 5.3.1998 / 14:58:32 / stefan"
+    "Modified: / 01-07-1996 / 21:11:28 / cg"
+    "Created: / 05-03-1998 / 14:40:05 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:16:06 / cg"
 !
 
 longLongAt:index bigEndian:msb
@@ -799,9 +803,12 @@
 longLongAt:byteIndex put:anInteger
     "store a signed longLong (64bit) integer.
      The index is a smalltalk index (i.e. 1-based).
+     The value is stored in the machine's natural byte order.
      Same as #signedQuadWordAt:put: - for ST80 compatibility."
 
     ^ self signedInt64At:byteIndex put:anInteger MSB:IsBigEndian
+
+    "Modified (comment): / 04-08-2017 / 11:16:36 / cg"
 !
 
 longLongAt:byteIndex put:anInteger bigEndian:msb
@@ -851,7 +858,7 @@
 shortAt:index
     "return the 2-bytes starting at index as a signed Integer.
      The index is a smalltalk index (i.e. 1-based).
-     The value is retrieved in the machines natural byte order.
+     The value is retrieved in the machine's natural byte order.
      This may be worth a primitive.
      This is the ST80 equivalent of #signedWordAt:"
 
@@ -864,9 +871,10 @@
      b shortAt:1
     "
 
-    "Modified: / 1.7.1996 / 21:14:38 / cg"
-    "Created: / 5.3.1998 / 10:59:57 / stefan"
-    "Modified: / 5.3.1998 / 23:39:38 / stefan"
+    "Modified: / 01-07-1996 / 21:14:38 / cg"
+    "Created: / 05-03-1998 / 10:59:57 / stefan"
+    "Modified: / 05-03-1998 / 23:39:38 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:16:20 / cg"
 !
 
 shortAt:index bigEndian:msb
@@ -893,7 +901,7 @@
     "set the 2-bytes starting at index from the signed Integer value.
      The index is a smalltalk index (i.e. 1-based).
      The stored value must be in the range -32768 .. +32676.
-     The value is stored in the machines natural byteorder.
+     The value is stored in the machine's natural byteorder.
      This may be worth a primitive.
      This is the ST80 equivalent of #signedWordAt:put:"
 
@@ -908,8 +916,9 @@
      b inspect
     "
 
-    "Modified: / 1.7.1996 / 21:12:07 / cg"
-    "Created: / 5.3.1998 / 11:02:05 / stefan"
+    "Modified: / 01-07-1996 / 21:12:07 / cg"
+    "Created: / 05-03-1998 / 11:02:05 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:16:46 / cg"
 !
 
 shortAt:index put:value bigEndian:bigEndian
@@ -936,7 +945,7 @@
 signedDoubleWordAt:index
     "return the 4-bytes starting at index as a signed Integer.
      The index is a smalltalk index (i.e. 1-based).
-     The value is retrieved in the machines natural byte order.
+     The value is retrieved in the machine's natural byte order.
      This may be worth a primitive."
 
     ^ self signedInt32At:index MSB:IsBigEndian
@@ -954,7 +963,8 @@
      (b doubleWordAt:1)
     "
 
-    "Modified: 1.7.1996 / 21:11:28 / cg"
+    "Modified: / 01-07-1996 / 21:11:28 / cg"
+    "Modified (comment): / 04-08-2017 / 11:16:52 / cg"
 !
 
 signedDoubleWordAt:index MSB:msb
@@ -977,7 +987,7 @@
 signedDoubleWordAt:index put:value
     "set the 4-bytes starting at index from the signed Integer value.
      The index is a smalltalk index (i.e. 1-based).
-     The value is stored in the machines natural byte order.
+     The value is stored in the machine's natural byte order.
      This may be worth a primitive."
 
     ^ self signedInt32At:index put:value MSB:IsBigEndian
@@ -989,7 +999,8 @@
      (b doubleWordAt:1) printStringRadix:16
     "
 
-    "Modified: 1.7.1996 / 21:11:39 / cg"
+    "Modified: / 01-07-1996 / 21:11:39 / cg"
+    "Modified (comment): / 04-08-2017 / 11:16:56 / cg"
 !
 
 signedDoubleWordAt:index put:value MSB:msb
@@ -1047,7 +1058,7 @@
 signedWordAt:index
     "return the 2-bytes starting at index as a signed Integer.
      The index is a smalltalk index (i.e. 1-based).
-     The value is retrieved in the machines natural byte order.
+     The value is retrieved in the machine's natural byte order.
      This may be worth a primitive."
 
     ^ (self unsignedInt16At:index MSB:IsBigEndian) signExtendedShortValue
@@ -1059,7 +1070,8 @@
      b signedWordAt:1
     "
 
-    "Modified: 1.7.1996 / 21:14:38 / cg"
+    "Modified: / 01-07-1996 / 21:14:38 / cg"
+    "Modified (comment): / 04-08-2017 / 11:17:02 / cg"
 !
 
 signedWordAt:index MSB:msb
@@ -1170,7 +1182,7 @@
      The index is a smalltalk index (i.e. 1-based).
      The value should be in the range 0 to 16rFFFFFFFF
      (for negative values, the stored value is not defined).
-     The value is stored in the machines natural byte order.
+     The value is stored in the machine's natural byte order.
      Subclasses may redefine this for better performance.
      Same as doubleWordAt:put: for protocol completeness"
 
@@ -1183,8 +1195,9 @@
      b inspect
     "
 
-    "Created: / 5.3.1998 / 11:57:44 / stefan"
-    "Modified: / 5.3.1998 / 14:58:59 / stefan"
+    "Created: / 05-03-1998 / 11:57:44 / stefan"
+    "Modified: / 05-03-1998 / 14:58:59 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:17:11 / cg"
 !
 
 unsignedLongAt:index put:aNumber bigEndian:msb
@@ -1231,12 +1244,12 @@
     "set the 8-bytes starting at index from the (unsigned) Integer value.
      The index is a smalltalk index (i.e. 1-based).
      The value must be in the range 0 to 16rFFFFFFFFFFFFFFFF.
-     The value is stored in natural byte order."
+     The value is stored in the machine's natural byte order."
 
     ^ self unsignedInt64At:index put:anInteger MSB:IsBigEndian
 
-    "Created: / 5.3.1998 / 14:44:00 / stefan"
-    "Modified: / 5.3.1998 / 15:02:32 / stefan"
+    "Created: / 05-03-1998 / 14:44:00 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:17:23 / cg"
 !
 
 unsignedLongLongAt:index put:anInteger bigEndian:msb
@@ -1260,15 +1273,16 @@
 unsignedShortAt:index
     "return the 2-bytes starting at index as an (unsigned) Integer.
      The index is a smalltalk index (i.e. 1-based).
-     The value is retrieved in the machines natural byte order
+     The value is retrieved in the machine's natural byte order
      Subclasses may redefine this for better performance.
      This is the ST80 equivalent of #wordAt:"
 
 
     ^ self unsignedInt16At:index MSB:IsBigEndian
 
-    "Created: / 5.3.1998 / 11:38:25 / stefan"
-    "Modified: / 5.3.1998 / 14:59:25 / stefan"
+    "Created: / 05-03-1998 / 11:38:25 / stefan"
+    "Modified: / 05-03-1998 / 14:59:25 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:17:28 / cg"
 !
 
 unsignedShortAt:index bigEndian:msb
@@ -1288,7 +1302,7 @@
     "set the 2-bytes starting at index from the (unsigned) Integer value.
      The index is a smalltalk index (i.e. 1-based).
      The stored value must be in the range 0 .. 16rFFFF.
-     The value is stored in the machines natural byteorder."
+     The value is stored in the machine's natural byteorder."
 
     ^ self unsignedInt16At:index put:value
 
@@ -1300,8 +1314,9 @@
      b inspect
     "
 
-    "Created: / 5.3.1998 / 11:54:52 / stefan"
-    "Modified: / 5.3.1998 / 14:59:38 / stefan"
+    "Created: / 05-03-1998 / 11:54:52 / stefan"
+    "Modified: / 05-03-1998 / 14:59:38 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:17:31 / cg"
 !
 
 unsignedShortAt:index put:value bigEndian:msb
@@ -1330,12 +1345,13 @@
 wordAt:index
     "return the 2-bytes starting at index as an (unsigned) Integer.
      The index is a smalltalk index (i.e. 1-based).
-     The value is retrieved in the machines natural byte order
+     The value is retrieved in the machine's natural byte order
      Subclasses may redefine this for better performance."
 
     ^ self unsignedInt16At:index MSB:IsBigEndian
 
-    "Modified: / 5.3.1998 / 14:59:51 / stefan"
+    "Modified: / 05-03-1998 / 14:59:51 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:17:35 / cg"
 !
 
 wordAt:index MSB:msb
@@ -1357,7 +1373,7 @@
     "set the 2-bytes starting at index from the (unsigned) Integer value.
      The index is a smalltalk index (i.e. 1-based).
      The stored value must be in the range 0 .. 16rFFFF.
-     The value is stored in the machines natural byteorder.
+     The value is stored in the machine's natural byteorder.
      Question: should it accept signed values ? (see ByteArray>>signedWordAt:put:)"
 
     ^ self unsignedInt16At:index put:value MSB:IsBigEndian
@@ -1370,7 +1386,8 @@
      b inspect
     "
 
-    "Modified: / 5.3.1998 / 15:00:03 / stefan"
+    "Modified: / 05-03-1998 / 15:00:03 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:17:39 / cg"
 !
 
 wordAt:index put:value MSB:msb
@@ -1397,15 +1414,16 @@
 
 wordAtWordIndex:int16Index
     "return the unsigned short (uint16) at index, anInteger.
-     Fetching in the machines natural byte order.
+     Fetching in the machine's natural byte order.
      Indices are 1-based and scaled as appropriate to allow
      accessing the memory as an array of word entries.
      (i.e. indices are 1, 2, ...)"
 
     ^ self unsignedInt16At:int16Index MSB:IsBigEndian
 
-    "Created: / 21.1.1998 / 17:48:26 / cg"
-    "Modified: / 5.3.1998 / 15:00:16 / stefan"
+    "Created: / 21-01-1998 / 17:48:26 / cg"
+    "Modified: / 05-03-1998 / 15:00:16 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:17:43 / cg"
 !
 
 wordAtWordIndex:int16Index MSB:msb
@@ -1490,13 +1508,132 @@
     "
 ! !
 
+!UninterpretedBytes methodsFor:'accessing-128bit ints'!
+
+signedInt128At:index MSB:msb
+    "return the 16-bytes starting at index as a signed Integer.
+     The index is a smalltalk index (i.e. 1-based).
+     The value is retrieved in the given byte order.
+     This may be worth a primitive."
+
+    |w|
+
+    w := self unsignedInt128At:index MSB:msb.
+    (w > (16r7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) ifTrue:[
+        ^ w - (16r100000000000000000000000000000000)
+    ].
+    ^ w
+
+    "
+     |b|
+     b := ByteArray new:16.
+     b unsignedInt128At:1 put:16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF MSB:true.
+     (b signedInt128At:1 MSB:true)
+    "
+
+    "Created: / 04-08-2017 / 11:27:31 / cg"
+!
+
+signedInt128At:byteIndex put:anInteger MSB:msb
+    "store a signed 128bit integer.
+     The index is a smalltalk index (i.e. 1-based)."
+
+    |v|
+
+    v := anInteger.
+    anInteger < 0 ifTrue:[
+        v := v + 16r100000000000000000000000000000000
+    ].
+    self unsignedInt128At:byteIndex put:v MSB:msb.
+    ^ anInteger
+
+    "
+     |b|
+     b := ByteArray new:16.
+     b signedInt128At:1 put:-1 MSB:true.
+     (b unsignedInt128At:1 MSB:true)
+    "
+
+    "Created: / 04-08-2017 / 11:08:59 / cg"
+!
+
+unsignedInt128At:byteIndex MSB:msb
+    "return the 16-bytes starting at index as an unsigned integer.
+     The index is a smalltalk index (i.e. 1-based).
+     Depending on msb, the value is retrieved MSB or LSB-first."
+
+    |l
+     bIdx  "{ Class: SmallInteger }"
+     delta "{ Class: SmallInteger }"|
+
+    l := LargeInteger basicNew numberOfDigits:16.
+    msb ifTrue:[
+        bIdx := byteIndex + 15.
+        delta := -1
+    ] ifFalse:[
+        bIdx := byteIndex.
+        delta := 1
+    ].
+    1 to:16 do:[:i |
+        l digitAt:i put:(self byteAt:bIdx).
+        bIdx := bIdx + delta
+    ].
+    ^ l compressed
+
+    "
+     |b|
+
+     b := ByteArray withAll:#(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16).
+     (b unsignedInt128At:1 MSB:false) printStringRadix:16
+    "
+
+    "Created: / 04-08-2017 / 11:12:22 / cg"
+!
+
+unsignedInt128At:byteIndex put:anInteger MSB:msb
+    "set the 18-bytes starting at index from the (unsigned) Integer value.
+     The index is a smalltalk index (i.e. 1-based).
+     The value must be in the range 0 to 16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.
+     Depending on msb, the value is stored MSB-first or LSB-first."
+
+    |bIdx  "{ Class: SmallInteger }"
+     delta "{ Class: SmallInteger }"|
+
+    ((anInteger < 0) 
+     or:[anInteger > 16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF]) ifTrue:[
+        ^ self elementBoundsError:anInteger
+    ].
+
+    msb ifTrue:[
+        bIdx := byteIndex + 15.
+        delta := -1
+    ] ifFalse:[
+        bIdx := byteIndex.
+        delta := 1
+    ].
+    1 to:16 do:[:i |
+        self byteAt:bIdx put:(anInteger digitAt:i).
+        bIdx := bIdx + delta.
+    ].
+    ^ anInteger
+
+    "
+     |b|
+     b := ByteArray new:16.
+     b unsignedInt128At:1 put:16r100F0E0D0C0B0A090807060504030201 MSB:false.
+     b inspect
+    "
+
+    "Created: / 04-08-2017 / 11:11:02 / cg"
+! !
+
 !UninterpretedBytes methodsFor:'accessing-arbitrary-long ints'!
 
 nativeIntAt:index
     "return the 4- or 8-bytes (depending on the native integer/pointer size) 
      starting at index as a signed Integer.
      The index is a smalltalk index (i.e. 1-based).
-     The value is retrieved in the machines natural byte order,
+     The value is retrieved in the machine's natural byte order,
      therefore, this should only be used for byte-data which is
      only used inside this machine."
 
@@ -1550,6 +1687,8 @@
      b nativeIntAt:1 put:SmallInteger maxVal.
      b nativeIntAt:1
     "
+
+    "Modified (comment): / 04-08-2017 / 11:18:01 / cg"
 !
 
 nativeIntAt:index put:value
@@ -1669,7 +1808,7 @@
 unsignedIntegerAt:index length:len bigEndian:bigEndian
     "return the n-byte unsigned integer starting at index.
      With n=1, this returns the single byte's value,
-     n=2, an unsigned short, n=4 an unsigned int etc.
+     n=2, an unsigned short, n=4 an unsigned int32 etc.
      Useful to extract arbitrary long integers"
 
     |val
@@ -1697,12 +1836,14 @@
      (b unsignedIntegerAt:2 length:4 bigEndian:false).
      (b unsignedIntegerAt:2 length:4 bigEndian:true).
     "
+
+    "Modified (comment): / 04-08-2017 / 11:14:21 / cg"
 !
 
 unsignedIntegerAt:index put:newValue length:len bigEndian:bigEndian
     "store the n-byte unsigned integer starting at index.
      With n=1, this stores a single byte's value,
-     n=2, an unsigned short, n=4 an unsigned int etc.
+     n=2, an unsigned short, n=4 an unsigned int32 etc.
      Useful to replace arbitrary long integers"
 
     |val
@@ -1731,6 +1872,8 @@
      (b unsignedIntegerAt:2 put:16r11223344 length:3 bigEndian:false). b.
      (b unsignedIntegerAt:2 put:16r11223344 length:3 bigEndian:true). b.
     "
+
+    "Modified (comment): / 04-08-2017 / 11:14:32 / cg"
 ! !
 
 !UninterpretedBytes methodsFor:'accessing-bytes'!
@@ -2443,7 +2586,7 @@
 signedInt64At:index
     "return the 8-bytes starting at index as a signed Integer.
      The index is a smalltalk index (i.e. 1-based).
-     The value is retrieved in the machines natural byte order.
+     The value is retrieved in the machine's natural byte order.
      This may be worth a primitive."
 
     |w|
@@ -2456,14 +2599,14 @@
 
     "
      |b|
-     b := ByteArray new:4.
-     b unsignedInt64At:1 put:16rFFFFFFFFFFFFFFFF.
-     (b signedInt64At:1)
-    "
-
-    "Modified: / 1.7.1996 / 21:11:28 / cg"
-    "Created: / 5.3.1998 / 14:40:05 / stefan"
-    "Modified: / 5.3.1998 / 14:58:32 / stefan"
+     b := ByteArray new:8.
+     b unsignedInt64At:1 put:16rFFFFFFFFFFFFFFFF MSB:true.
+     (b signedInt64At:1 MSB:true)
+    "
+
+    "Modified: / 01-07-1996 / 21:11:28 / cg"
+    "Created: / 05-03-1998 / 14:40:05 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:29:37 / cg"
 !
 
 signedInt64At:index MSB:msb
@@ -2482,22 +2625,26 @@
 
     "
      |b|
-     b := ByteArray new:4.
-     b unsignedLongLongAt:1 put:16rFFFFFFFFFFFFFFFF.
-     (b longLongAt:1 msb:true)
-    "
-
-    "Modified: / 5.3.1998 / 12:06:28 / stefan"
-    "Created: / 5.3.1998 / 14:40:54 / stefan"
-    "Modified: / 9.5.1998 / 01:10:59 / cg"
+     b := ByteArray new:8.
+     b unsignedInt64At:1 put:16rFFFFFFFFFFFFFFFF MSB:true.
+     (b signedInt64At:1 MSB:true)
+    "
+
+    "Modified: / 05-03-1998 / 12:06:28 / stefan"
+    "Created: / 05-03-1998 / 14:40:54 / stefan"
+    "Modified: / 09-05-1998 / 01:10:59 / cg"
+    "Modified (comment): / 04-08-2017 / 11:29:59 / cg"
 !
 
 signedInt64At:byteIndex put:anInteger 
     "store a signed longLong (64bit) integer.
      The index is a smalltalk index (i.e. 1-based).
+     The value is stored in the machine's natural byte order.
      Same as #signedQuadWordAt:put: - for ST80 compatibility."
 
     ^ self signedInt64At:byteIndex put:anInteger MSB:(UninterpretedBytes isBigEndian)
+
+    "Modified (comment): / 04-08-2017 / 11:19:09 / cg"
 !
 
 signedInt64At:byteIndex put:anInteger MSB:msb
@@ -2553,6 +2700,7 @@
 unsignedInt64At:byteIndex
     "return the 8-bytes starting at index in the machine's native
      byteorder as an unsigned integer.
+     The value is retrieved in the machine's natural byte order.
      The index is a smalltalk index (i.e. 1-based)"
 
    ^ self unsignedInt64At:byteIndex MSB:(UninterpretedBytes isBigEndian)
@@ -2561,11 +2709,12 @@
      |b|
 
      b := ByteArray withAll:#(1 2 3 4 5 6 7 8).
-     (b unsignedLongLongAt:1 bigEndian:false) printStringRadix:16
-    "
-
-    "Modified: / 5.11.1996 / 14:06:21 / cg"
-    "Modified: / 5.3.1998 / 14:04:44 / stefan"
+     (b unsignedInt64At:1) printStringRadix:16
+    "
+
+    "Modified: / 05-11-1996 / 14:06:21 / cg"
+    "Modified: / 05-03-1998 / 14:04:44 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:19:21 / cg"
 !
 
 unsignedInt64At:byteIndex MSB:msb
@@ -2595,11 +2744,19 @@
      |b|
 
      b := ByteArray withAll:#(1 2 3 4 5 6 7 8).
-     (b unsignedLongLongAt:1 bigEndian:false) printStringRadix:16
-    "
-
-    "Modified: / 5.11.1996 / 14:06:21 / cg"
-    "Modified: / 5.3.1998 / 14:04:44 / stefan"
+     (b unsignedInt64At:1 MSB:false) printStringRadix:16
+    "
+    
+    "
+     |b|
+     b := ByteArray new:8.
+     b signedInt64At:1 put:-1 MSB:true.
+     (b unsignedInt64At:1 MSB:true)
+    "
+
+    "Modified: / 05-11-1996 / 14:06:21 / cg"
+    "Modified: / 05-03-1998 / 14:04:44 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:30:34 / cg"
 !
 
 unsignedInt64At:byteIndex put:anInteger 
@@ -2652,11 +2809,12 @@
     "
      |b|
      b := ByteArray new:8.
-     b unsignedLongLongAt:1 put:16r0807060504030201 bigEndian:false.
+     b unsignedInt64At:1 put:16r0807060504030201 MSB:false.
      b inspect
     "
 
-    "Created: / 5.3.1998 / 14:06:02 / stefan"
+    "Created: / 05-03-1998 / 14:06:02 / stefan"
+    "Modified (comment): / 04-08-2017 / 11:13:59 / cg"
 !
 
 unsignedInt64AtLSB:byteIndex
@@ -4131,23 +4289,32 @@
 !UninterpretedBytes methodsFor:'converting'!
 
 asExternalBytes
-    |sz bytes|
-
-    sz := self byteSize.
-    bytes := ExternalBytes unprotectedNew:sz.
-    bytes replaceBytesFrom:1 to:sz with:self startingAt:1.
-    ^ bytes
+    "in earlier times, this use to return protected memory 
+     (i.e. it would not be garbage collected, and the user had to free it manually).
+     This was changed to now return garbage collected memory."
+
+    ^ self asExternalBytesUnprotected.
+
+"/    |sz bytes|
+"/
+"/    sz := self byteSize.
+"/    bytes := ExternalBytes new:sz.
+"/    bytes replaceBytesFrom:1 to:sz with:self startingAt:1.
+"/    ^ bytes
 
     "
       #[1 2 3 4 5 6 7] asExternalBytes
       'Hello World' asExternalBytes
       'Hello World' asUnicodeString asExternalBytes
     "
+
+    "Modified (comment): / 04-08-2017 / 11:25:00 / cg"
 !
 
 asExternalBytesUnprotected
-    "Like asExternalBytes, but does not register the bytes so
-     bytes are GARBAGE-COLLECTED."
+    "Like asExternalBytes, but does not protect the bytes from the collector,
+     so the bytes are GARBAGE-COLLECTED 
+     (i.e. free is called when the smalltalk object is no longer referenced)."
 
     |bytes sz|
 
@@ -4164,6 +4331,7 @@
 
     "Created: / 05-06-2012 / 14:11:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 30-11-2013 / 11:42:21 / cg"
+    "Modified (comment): / 04-08-2017 / 11:22:58 / cg"
 !
 
 asSingleByteString