module: dood author: jonathan bachrach Copyright: Original Code is Copyright (c) 1995-2004 Functional Objects, Inc. All rights reserved. License: Functional Objects Library Public License Version 1.0 Dual-license: GNU Lesser General Public License Warranty: Distributed WITHOUT WARRANTY OF ANY KIND define inline method dood-compute-instance-size (dood :: , object == ) => (address ::
) 1 + 1 + 1 // 64 bits end method; define inline function encode-machine-word-bytes (b1 :: , b2 :: , b3 :: , b4 :: , b5 :: , b6 :: , b7 :: , b8 :: ) => (res :: ) machine-word-logior (machine-word-logior (machine-word-logior (machine-word-shift-left-with-overflow(b1, 56), machine-word-shift-left-with-overflow(b2, 48)), machine-word-logior (machine-word-shift-left-with-overflow(b3, 40), machine-word-shift-left-with-overflow(b4, 32))), machine-word-logior (machine-word-logior (machine-word-shift-left-with-overflow(b5, 24), machine-word-shift-left-with-overflow(b6, 16)), machine-word-logior (machine-word-shift-left-with-overflow(b7, 8), b8))) end function; define inline function dood-read-machine-word (dood :: ) => (res :: ) dood-format("READING WORD @ %d", dood-position(dood)); let (b1, b2, b3, b4, b5, b6, b7, b8) = read-8-aligned-bytes(dood-stream(dood)); // let b1 :: = read-element(dood); // let b2 :: = read-element(dood); // let b3 :: = read-element(dood); // let b4 :: = read-element(dood); // let b5 :: = read-element(dood); // let b6 :: = read-element(dood); // let b7 :: = read-element(dood); // let b8 :: = read-element(dood); let value :: = encode-machine-word-bytes (as(, b1), as(, b2), as(, b3), as(, b4), as(, b5), as(, b6), as(, b7), as(, b8)); value end function; define inline function dood-read-machine-word-at (dood :: , address ::
) => (res :: ) dood-position(dood) := address; dood-read-machine-word(dood); end function; define inline function decode-machine-word-bytes (value :: ) => (b1 :: , b2 :: , b3 :: , b4 :: , b5 :: , b6 :: , b7 :: , b8 :: ) let mask = as(, 255); let b1 = machine-word-logand(machine-word-shift-right(value, 56), mask); let b2 = machine-word-logand(machine-word-shift-right(value, 48), mask); let b3 = machine-word-logand(machine-word-shift-right(value, 40), mask); let b4 = machine-word-logand(machine-word-shift-right(value, 32), mask); let b5 = machine-word-logand(machine-word-shift-right(value, 24), mask); let b6 = machine-word-logand(machine-word-shift-right(value, 16), mask); let b7 = machine-word-logand(machine-word-shift-right(value, 8), mask); let b8 = machine-word-logand(value, mask); values(b1, b2, b3, b4, b5, b6, b7, b8); end function; define inline function dood-write-machine-word (dood :: , value :: ) let (b1, b2, b3, b4, b5, b6, b7, b8) = decode-machine-word-bytes(value); dood-format("WRITING %d @ %d [%d, %d, %d, %d, %d %d %d %d]\n", value, dood-position(dood), b1, b2, b3, b4, b5, b6, b7, b8); write-8-aligned-bytes (dood-stream(dood), as(, b1), as(, b2), as(, b3), as(, b4), as(, b5), as(, b6), as(, b7), as(, b8)); // write-element(dood, as(, b1)); // write-element(dood, as(, b2)); // write-element(dood, as(, b3)); // write-element(dood, as(, b4)); // write-element(dood, as(, b5)); // write-element(dood, as(, b6)); // write-element(dood, as(, b7)); // write-element(dood, as(, b8)); end function; define inline function dood-write-machine-word-at (dood :: , value :: , address ::
) dood-position(dood) := address; dood-write-machine-word(dood, value); end function; // eof