Memory can now be explicitly "zeroed" with any byte pattern (but the default is still zero); note that memory blocks are still always zero-initialized when first created
This commit is contained in:
parent
97de321daa
commit
3b88e4c53c
5 changed files with 18 additions and 10 deletions
|
|
@ -664,13 +664,14 @@ BusPDP11.prototype.cleanMemory = function(addr, size)
|
|||
};
|
||||
|
||||
/**
|
||||
* zeroMemory(addr, size)
|
||||
* zeroMemory(addr, size, pattern)
|
||||
*
|
||||
* @this {BusPDP11}
|
||||
* @param {number} addr
|
||||
* @param {number} size
|
||||
* @param {number} [pattern]
|
||||
*/
|
||||
BusPDP11.prototype.zeroMemory = function(addr, size)
|
||||
BusPDP11.prototype.zeroMemory = function(addr, size, pattern)
|
||||
{
|
||||
var off = addr & this.nBlockLimit;
|
||||
var iBlock = addr >>> this.nBlockShift;
|
||||
|
|
@ -682,7 +683,7 @@ BusPDP11.prototype.zeroMemory = function(addr, size)
|
|||
if (i >= 0) block = this.aIOPrevBlocks[i];
|
||||
}
|
||||
}
|
||||
if (block) block.zero(off, size);
|
||||
if (block) block.zero(off, size, pattern);
|
||||
size -= this.nBlockSize;
|
||||
iBlock++;
|
||||
off = 0;
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ MemoryPDP11.prototype = {
|
|||
return false;
|
||||
},
|
||||
/**
|
||||
* zero(off, len)
|
||||
* zero(off, len, pattern)
|
||||
*
|
||||
* Zeros the block. Supporting off and len parameters is probably overkill, and makes more
|
||||
* work in the non-TYPEDARRAY, non-BYTEARRAY case, but that's not the typical case. The other
|
||||
|
|
@ -394,19 +394,21 @@ MemoryPDP11.prototype = {
|
|||
* @this {MemoryPDP11}
|
||||
* @param {number} [off] (optional starting byte offset within block)
|
||||
* @param {number} [len] (optional maximum number of bytes; default is the entire block)
|
||||
* @param {number} [pattern]
|
||||
*/
|
||||
zero: function(off, len) {
|
||||
zero: function(off, len, pattern) {
|
||||
var i;
|
||||
off = off || 0;
|
||||
pattern &= 0xff;
|
||||
/*
|
||||
* NOTE: If len happens to be larger than the block, that's OK, because we also bounds-check the index.
|
||||
*/
|
||||
if (len === undefined) len = this.size;
|
||||
Component.assert(off >= 0 && off < this.size);
|
||||
if ((TYPEDARRAYS || BYTEARRAYS) && this.ab) {
|
||||
for (i = off; len-- && i < this.ab.length; i++) this.ab[i] = 0;
|
||||
for (i = off; len-- && i < this.ab.length; i++) this.ab[i] = pattern;
|
||||
} else {
|
||||
for (i = off; len-- && i < this.size; i++) this.writeByteDirect(off, 0, this.addr + off);
|
||||
for (i = off; len-- && i < this.size; i++) this.writeByteDirect(off, pattern, this.addr + off);
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -239,7 +239,12 @@ RAMPDP11.prototype.initRAM = function()
|
|||
RAMPDP11.prototype.reset = function()
|
||||
{
|
||||
if (this.fAllocated) {
|
||||
this.bus.zeroMemory(this.addrRAM, this.sizeRAM);
|
||||
/*
|
||||
* TODO: Add a configuration parameter for selecting the byte pattern on reset?
|
||||
* Note that when memory blocks are originally created, they are currently always
|
||||
* zero-initialized, so this would only affect resets.
|
||||
*/
|
||||
this.bus.zeroMemory(this.addrRAM, this.sizeRAM, 0);
|
||||
if (this.abInit) {
|
||||
this.loadImage(this.abInit, this.addrLoad, this.addrExec, this.addrRAM, true);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue