Class: BFCpu

BFCpu(nbits, program, memorySize)

A class that stores the CPU model for the BF program execution. This includes the: data and instruction pointers, the instruction list, the memory and the execution counter

Constructor

new BFCpu(nbits, program, memorySize)

The constructor for the BF CPU
Parameters:
Name Type Description
nbits Number The number of bits the architecture supports
program BFProgram The program to execute
memorySize Number The size of the allocated memory at start up
Source:
See:
  • Program
  • Instruction

Methods

execute()

Execute the entire program until the instruction pointer reaches the end of the file.
Source:

getCurrentCell() → {Number}

Gets the current data cell value.
Source:
Returns:
- The current cell value
Type
Number

getDataPtr() → {Number}

Get the current location of the data pointer.
Source:
Returns:
- The data pointer location.
Type
Number

reset()

Resets the CPU architecture: clears the output, zeros memory, moves data pointer to the start, moves instruction pointer to the start, zeros the execute counter.
Source:

setCurrentCell(value)

Set the current data cell to a new value.
Parameters:
Name Type Description
value Number The new cell value
Source:

setDataPtr(value)

Set the data pointer to a new value
Parameters:
Name Type Description
value Number The new data pointer location.
Source:

setInstructionPtr(value)

Set the instruction pointer to a new location
Parameters:
Name Type Description
value Number The new instruction location
Source:

step()

Execute one instruction and increment the instruction pointer.
Source:

Documentation generated by JSDoc 4.0.2 on Sun Feb 08 2026 18:39:25 GMT-0800 (Pacific Standard Time)