Main Memory

The main memory of the simulator is used to store data and machine language programs. The memory capacity is 64KB but the CPU views memory in two different ways depending on whether it is accessing data or accessing machine language programs.


The CPU is designed to process 32-bit signed integer data (i.e., the word size is 32 bits). When accessing data, memory can only be addressed by word and is viewed as having a 16K x 32-bit organization. The memory address register (MAR) stores a word address; the high-order 32 bits of the corresponding byte address (the 2 low-order bits are both zero and are not stored). The address space of the CPU is considerably larger than the memory capacity of the simulated computer. Given any word address, the corresponding byte address is four times the word address. For example, the first byte of the word at word address 10 is at byte address 40.

Machine Langauge Programs

The CPU accesses machine language programs one byte at a time. The program counter (PC) stores the address of the next byte of the machine language program. When accessing a machine language program, memory is viewed as having a 64K x 8-bit organization.

Predefined Sections

When running machine language programs, memory is divided into four 16KB sections:

  1. 0x0000 - the machine language program; accessed using the program counter (PC).
  2. 0x1000 - the stack; accessed using the stack pointer (SP).
  3. 0x2000 - variables declared in the main method; accessed using the local variables register (LV).
  4. 0x3000 - program constants; accessed using the constant pool pointer CPP).

When the simulated computer is reset, the PC, SP, LV, and CPP registers are initialized to point at the memory locations given above.