//
// Wrapper for FindPkg Alto microcode
// last edited September 18, 1980  12:32 PM
//
// Copyright Xerox Corporation 1980

external [ fRamImage ]	// (workarea, fixedram/-1, error) -> ramImage

external
[		// RWREG
	ReadConReg
	ReadInsReg
	RegWorkArea
	WriteInsReg
]

let fRamImage(workarea, fixedram, error) = valof
[	let RamImage = nil

	get "findpkg.ls"	// Sets RamImage

	if fixedram ge 0 then
	[ let v = vec 2
	  for i = 0 to fixedram-1 do
	  [ let p = RamImage+400b+2*i
	    WriteInsReg(i, p)
	    ReadInsReg(i, v)
	    if (v!0 ne p!0) % (v!1 ne p!1) then error("Can't write into RAM")
	  ]
	  RegWorkArea = workarea
	  for i = 1 to 377b do
	   if RamImage!i ne 0 then
	    if ReadConReg(i) ne RamImage!i then
	      error("Bad constant memory")
	]

	resultis RamImage
]