Register Transfer Language - MARIE-js/MARIE.js GitHub Wiki

Table of Contents
1. Introduction
2. RTL of MARIE Code
2.1 Direct Addressing
2.2 Indirect Addressing

Introduction

Register Transfer Language or RTL shows how the CPU (Assembler) works. Within the CPU there are many components including:

  • AC or Accumulator : intermediate data is stored within the AC
  • PC or Program Counter : as the name suggests it counts the current position of the code, each line has it's own address
  • MAR or Memory Access Register , stores or fetches the 'data' at the given address
  • MBR or Memory Buffer Register , stores the data when being transferred
  • IR or Instruction Register

Note that the end of each code, you will need to increment the PC by 1, so:

PC ← PC + 1

RTL of MARIE Code

Direct Addressing

Load X

Load X loads the value from address X into the AC

MAR ← X       # load X (address) into MAR
MBR ← M[MAR]  # load value stored at address into MBR
AC  ← MBR     # load value in MBR into AC

Store X

Store X stores the current value from the AC into address X

MAR    ← X    # load address into MAR
MBR    ← AC   # load AC value into MBR
M[MAR] ← MBR  # write MBR value into the Memory of the address indicated by the MAR

Add X

Add X adds the value stored at address X into AC

MAR ← X           # load X into MAR
MBR ← M[MAR]      # load value stored at address X into MBR
AC  ← AC + MBR    # add value in AC with MBR value and store it back into AC

Subt X

Subt X subtracts the value in AC with the value stored at address X

MAR ← X
MBR ← M[MAR]
AC  ← AC - MBR

Jump X

Jump X jumps to address X

PC ← X

Indirect Addressing

LoadI X

LoadI X loads the value which is stored at address of the address X into the AC

MAR ← X       # load value X into MAR
MBR ← M[MAR]  # load value stored at address X into MBR
MAR ← MBR     # load value back into MAR (MAR cant write itself)
MBR ← M[MAR]  # load value stored at the address indicate by the value of address X
AC  ← MBR     # Load value into AC.

AddI X

AddI X adds the value which is stored at address of the address X to the value in AC and stores it back into AC

MAR ← X              # load value X into MAR
MBR ← M[MAR]         # load value stored at address X into MBR
MAR ← MBR            # load value back into MAR (MAR cant write itself)
MBR ← M[MAR]         # load value stored at the address indicate by the value of address X
AC  ← MBR + AC       # Load value into AC

JnS X

JnS X or Jumps and Stores: Stores PC at address X and jumps to X+1

MAR    ← X           # loads value X into MAR
MBR    ← PC + 1      # loads value of PC into MBR
M[MAR] ← MBR         # stores value in MBR into address of MAR
AC     ← X + 1       # increments X by 1 and stores it into AC
PC     ← AC          # jumps program counter to the address indicated by the AC

JumpI X

JumpI X uses the value at X as the address to jump to

MAR ← X             # loads value X into MAR
MBR ← M[MAR]        # loads value stored at address X into MBR
PC  ← MBR           # loads the value into PC