Class: Memory

Memory(id, bullGamma, nb_blocks)

A Memory is Word directly connected to the Bullgamma (not through an Octad or a DrumBlock). It possess some computation methods that makes it easier to manipulate for instructions.

Constructor

new Memory(id, bullGamma, nb_blocks)

constructs a new instance of Memory
Parameters:
Name Type Description
id the ID of this memory
bullGamma the machine attached to this memory
nb_blocks the number of blocks for this memory (same as Word)
Source:

Methods

add(other, from, to, overriding_carry)

add the given memory to this one
Parameters:
Name Type Default Description
other the memory that should be added
from index of the block from which the addition should start
to index of the block to which the addition should end (excluded)
overriding_carry true if true, at the end of the addition, the resulting carry out will override the next memory block if it is not null. Otherwise it will be added to the next memory block.
Source:

addValue(value, at)

Add a value to any block of the memory, carrying out the result if in decimal mode.
Parameters:
Name Type Description
value the value to add, must be between -16 and 16
at the block index to which the value should be added
Source:

compareTo(other, from, to)

compare the whole memory to another one between selected blocks
Parameters:
Name Type Description
other the other memory to which it should be compared
from the starting block from which the comparison should start
to the end block of the comparison (excluded)
Source:
Returns:
an array of two booleans, index 0 is true if this is greater than other, index 1 is true if they are equal

copyBlockValues(other, from, to)

Copy the selected values from an other memory If the calculator is in decimal mode, only ten's complement values will be copied
Parameters:
Name Type Default Description
other the other memory from which values will be copied
from 0 which block index should the copy start from, should be positive and inferior to 12
to where should the copy end (excluded), should be inferior or equal to 12
Source:

divide(other, from, to)

divide the given memory to this one
Parameters:
Name Type Description
other the memory that should be divided
from index of the block from which the division should start
to index of the block to which the division should end (excluded)
Source:

divideValue(value, at)

divide the memory with the given value, equivalent to this = this / (value * (10 or 2)^at)
Parameters:
Name Type Description
value
at
Source:

getDecimalValue(from, to) → {number}

return the unsigned decimal value of this memory between the selected blocks (decimal mode only)
Parameters:
Name Type Description
from the starting block from which the value should be computed
to the ending block (excluded)
Source:
Returns:
the computed value
Type
number

getMode() → {MEMORY_MODE}

Source:
Returns:
the computation mode for this Memory
Type
MEMORY_MODE

multiply(other, from, to)

multiply the given memory to this one
Parameters:
Name Type Description
other the memory that should be multiplied
from index of the block from which the multiplication should start
to index of the block to which the multiplication should end (excluded)
Source:

multiplyValue(value, at)

multiply the memory with the given value, equivalent to this = this * value * (10 or 2)^at
Parameters:
Name Type Description
value
at
Source:

setBlockValue(idx, value)

Set the selected memory block to the given value. If in decimal mode and value is > 9, the value's digits are split then the lower one goes to blocks[idx] while blocks[idx + 1] gets the higher one.
Parameters:
Name Type Description
idx the idx of the the block that should be set, must be positive or zero but inferior to NB_CHRS_PER_WORD
value the value to which the block should be set, must be positive or zero and inferior to 16.
Source:

setDecimalValue(value, from, to)

set the value of the memory between the selected blocks
Parameters:
Name Type Description
value
from
to
Source:

setToZero(from, to)

Set every memory block in range to 0
Parameters:
Name Type Description
from start index of the selected memory blocks, should be positive or zero
to end index (excluded) of the selected memory blocks, should be inferior to NB_CHRS_PER_WORD
Source:

shiftLeft()

Every block in the memory gets the value of its right neighbour (index 0 gets value of index 11)
Source:

shiftRight()

Every block in the memory gets the value of its left neighbour (index 11 gets value of index 0)
Source:

subtract(other, from, to)

subtract the given memory to this one
Parameters:
Name Type Default Description
other the memory that should be subtracted
from 0 index of the block from which the subtraction should start
to index of the block to which the subtraction should end (excluded)
Source: