UNPKG

eighty-eighty-js

Version:

A nice little Intel 8080 emulator for Node.js and Browser!

48 lines (47 loc) 1.55 kB
import { u16, u8 } from 'typed-numbers'; /** * Represents the memory of the CPU. */ export declare class Memory { /** Memory size. */ static readonly MEMORY_SIZE: number; /** Memory data. */ data: ArrayBuffer; /** Memory data view. */ protected view: DataView; /** * Load a whole buffer into memory, starting at `offset`. * @param buffer - The buffer to load into memory. Can be of any array-like type. * @param [offset = 0] - The offset from where to start writing the buffer into memory. */ load(buffer: ArrayLike<number>, offset?: number): void; /** * Read memory at `address`. * @param address - The address. * @return - The value as an unsigned 8-bit integer. */ get(address: u16): u8; /** * Write `value` to memory at `address`. * @param address - The address. * @param value - The unsigned 8-bit integer to write into memory. */ set(address: u16, value: u8): void; /** * Read memory at `address` and `address + 1`. * @param address - The address. * @return - The value as an unsigned 16-bit integer. */ getWord(address: u16): u16; /** * Write `value` to memory at `address`. * @param address - The address. * @param value - The unsigned 16-bit integer to write into memory. */ setWord(address: u16, value: u16): void; } export declare namespace Memory { class NotEnoughMemoryError extends Error { constructor(); } }