From a076a10fe931964fdf09da8bc54b3c7b88aef8cd Mon Sep 17 00:00:00 2001 From: Andrew Scheidecker Date: Thu, 24 Sep 2015 08:12:23 -0400 Subject: [PATCH 1/2] Replaced explicit truncation with a comment about implicit truncation --- ml-proto/src/spec/memory.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ml-proto/src/spec/memory.ml b/ml-proto/src/spec/memory.ml index 16181ec418..0dfbe20b1c 100644 --- a/ml-proto/src/spec/memory.ml +++ b/ml-proto/src/spec/memory.ml @@ -91,7 +91,8 @@ let load64 mem a = Int64.logor (Int64.of_int32 (load32 mem a)) (Int64.shift_left (Int64.of_int32 (load32 mem (a+4))) 32) let store8 mem a bits = - !mem.{a} <- Int32.to_int (Int32.logand bits (Int32.of_int 255)) + (* Store "bits" at byte index a; this implicitly truncates all but the lowest 8 bits of "bits". *) + !mem.{a} <- Int32.to_int bits let store16 mem a bits = store8 mem (a+0) bits; From 2312e239a31ff7dd66848526cca2d2d6169be73a Mon Sep 17 00:00:00 2001 From: Andrew Scheidecker Date: Thu, 24 Sep 2015 11:41:53 -0400 Subject: [PATCH 2/2] Changed comment to be more explicit than "truncate" --- ml-proto/src/spec/memory.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ml-proto/src/spec/memory.ml b/ml-proto/src/spec/memory.ml index 0dfbe20b1c..3543c9571f 100644 --- a/ml-proto/src/spec/memory.ml +++ b/ml-proto/src/spec/memory.ml @@ -91,7 +91,7 @@ let load64 mem a = Int64.logor (Int64.of_int32 (load32 mem a)) (Int64.shift_left (Int64.of_int32 (load32 mem (a+4))) 32) let store8 mem a bits = - (* Store "bits" at byte index a; this implicitly truncates all but the lowest 8 bits of "bits". *) + (* Store the lowest 8 bits of "bits" at byte index a, discarding the rest. *) !mem.{a} <- Int32.to_int bits let store16 mem a bits =