DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦92d2f8da7⟧ TextFile

    Length: 5248 (0x1480)
    Types: TextFile
    Notes: R1k Text-file segment

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« 
        └─⟦3830b737a⟧ 
            └─⟦this⟧ 

TextFile

-- raw_dump
--
-- This file provides two procedures, raw_dump_w_addr and raw_dump, both
-- print out a dump of memory:
--
-----------------------
-- procedure raw_dump_w_addr(
--              addr:   system.address;
--              count:  integer;
--              p_addr: unsigned_types.unsigned_integer)
--
-- Raw_dump_w_addr displays both the value and ascii interpretation of
-- "count" bytes starting at "addr".  The display is 16 bytes per line
-- and each line is preceded by an address, which starts out as the value
-- of p_addr and is incremented by 16 for each successive line.  Here is
-- some example output, preceded by "--":
--
--  AAABBB: 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 "abcdefghijklmnop"
--  AAABCB: 71 72 73 74 75 76 77 78 79 7A 41 42 43 44 45 46 "qrstuvwxyzABCDEF"
--
-- There is an example test program at the bottom of this file that
-- calls both of these subprograms.
-----------------------
-- procedure raw_dump(addr: system.address; count: integer)
--
-- Raw_dump prints count bytes starting at addr.  See the comment
-- at the end of the file for a couple of example calls on raw_dump.
--
with hex;
with system; use system;
with text_io;
with unchecked_conversion;
with unsigned_types;
procedure raw_dump_w_addr(
			addr:   system.address;
			count:  integer;
			p_addr: unsigned_types.unsigned_integer)
is
	-- number of hex digits in an integer
	HEX_DIGITS: constant := integer'size / 4;

	left_to_do: integer := count;

	type byte is range 0..16#ff#;
	for byte'size use 8;

	type memline_rep is array (0..15) of byte;
	memline: memline_rep;
	mp: integer := 0;

	-- "char_star" is a reference to C, where the following two declarations
	-- would probably have been:
	--
	--   char *byte_ptr;
	--
	type char_star is access byte;
	byte_ptr: char_star;

	byte_val: integer;
	ptr_val: unsigned_types.unsigned_integer;

	pr_addr: unsigned_types.unsigned_integer := p_addr;

	val_count: integer := 0;

	line: string(1..80);
	lp: integer;

	procedure finish_line is
	begin
		if mp < 16 then
			for i in 1..(16-mp) * 3 loop
				line(lp) := ' ';
				lp := lp + 1;
			end loop;
		end if;

		line(lp) := '"';
		lp := lp + 1;

		for i in 0..(mp-1) loop
			if integer(memline(i)) >= character'pos(' ') and
			   integer(memline(i)) <= character'pos('~')
			then
				line(lp) := character'val(memline(i));
			else
				line(lp) := '.';
			end if;
			lp := lp + 1;
		end loop;

		line(lp) := '"';
	end finish_line;

	function addr_to_ptr is new unchecked_conversion(
				source => system.address,
				target => char_star);

	use unsigned_types;
	function ptr_to_uint is new unchecked_conversion(
				source => char_star,
				target => unsigned_integer);

	function uint_to_ptr is new unchecked_conversion(
				source => unsigned_integer,
				target => char_star);

begin
	byte_ptr := addr_to_ptr(addr);
	while left_to_do > 0 loop
		val_count := 16;
		if val_count > left_to_do then
			val_count := left_to_do;
		end if;
		left_to_do := left_to_do - val_count;

		line(1..HEX_DIGITS) := hex.unsigned_to_hex(pr_addr, HEX_DIGITS);
		pr_addr := pr_addr + unsigned_integer(val_count);

		line(HEX_DIGITS+1) := ':';
		line(HEX_DIGITS+2) := ' ';
		lp := HEX_DIGITS+3;

		mp := 0;
		for ii in 1 .. val_count loop
			byte_val := integer(byte_ptr.all);
			memline(mp) := byte_ptr.all;
			mp := mp + 1;

			ptr_val := ptr_to_uint(byte_ptr);
			ptr_val := ptr_val + 1;
			byte_ptr := uint_to_ptr(ptr_val);

			line(lp..lp+1) := hex.integer_to_hex(byte_val, 2, '0');
			line(lp+2) := ' ';
			lp := lp + 3;
		end loop;

		finish_line;
		text_io.put_line(line(1..lp));
	end loop;
end;

with raw_dump_w_addr;
with unchecked_conversion;
with system;
with unsigned_types;
procedure raw_dump(addr: system.address; count: integer) is
	function a_to_u is new unchecked_conversion(
				source => system.address,
				target => unsigned_types.unsigned_integer);
begin
	raw_dump_w_addr(addr, count, a_to_u(addr));
end;

-- The following test program calls both raw_dump and raw_dump_w_addr
-- and provides the listing shown on a machine with big-endian byte
-- order (Sun3, Sun4, HP300).  On a little-endian machine, some of
-- the bytes will be reversed (VAX, PS/2, Symmetry, DECstation 3100)
--
-- Note that the last 3 lines should be the same on any machine!
--
-- EFFFC20: 11 00 EE FF 33 22 CC DD 55 44 AA BB 77 66 88 99 "....3"..UD..wf.."
--    3788: 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 "abcdefghijklmnop"
--    3798: 71 72 73 74 75 76 77 78 79 7A 41 42 43 44 45 46 "qrstuvwxyzABCDEF"
--    37A8: 31 32 33 34 35                                  "12345"
--  AAABBB: 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 "abcdefghijklmnop"
--  AAABCB: 71 72 73 74 75 76 77 78 79 7A 41 42 43 44 45 46 "qrstuvwxyzABCDEF"
--  AAABDB: 31 32 33 34 35                                  "12345"
-- 
--with raw_dump;
--with raw_dump_w_addr;
--with unsigned_types;
--procedure test is
--	type int4 is array(1..4) of integer;
--	mem: int4 := (16#1100eeff#, 16#3322ccdd#, 16#5544aabb#, 16#77668899#);
--	ccc: constant string := "abcdefghijklmnopqrstuvwxyzABCDEF12345";
--begin
--	raw_dump(mem(1)'address, 16);
--	raw_dump(ccc'address, ccc'last);
--
--	raw_dump_w_addr(ccc'address, ccc'last,
--			unsigned_types.unsigned_integer(16#aaabbb#));
--end