Simple Computer
Arrays
array[index]
- This is done by using the address register

- How to implement
- Load base address (start of array) into address register
- Load index i into accumilator
- Add address register to accumulator, send result to address register
- Use address register to access memory
- Repeated Sequential access - after starting with the sequence use the auto-increment facility
Functions
Stored Program Concept
- Address of functions first instruction must be known
- Return address must be stored, so that can resume
- Note specialised register is useless if functions are nested, solved with a stack
Stack

- Stacks have a specialised register known as a stack pointer (SP)
PUSH
- Decrement SP, (grow stack) store value where SP is pointing
POP
- retrieve value then increment SP (note value of the stack will be overwritten)
SubRoutine
Jump to SubRoutine (JSR)
- Performs the jump to the first instruction
- Pushes return address from program counter onto stack
Return to SubRoutine(RTS)
- Pops stored return address back into program counter from
Stack Pointer wiring
The layout of the address register is the same as the stack pointer except it has a adder

Different addressing modes


Directives - used to define variables, giving them a : type, name, space in memory, value
Identifiers - this is the chosen name for a variable
- Assembly language uses identifiers just like high level code
- Identifiers are declared by a directive that allocates memory and assosiates the address with an identifier
- We must assume functionality of a instruction is encoded with the opcode (makes life hard)
- Real world assembly languages assessing operands is encoded using addressing modes
Immediate
#4 - # followed by address
Load the address
Direct
4 - just the address
Operand is the address of the value to be used
Indirect
(A0)
-(A0) - pre-decriment first
(A0)+ - increment first
Operand is the address of the address of the data to be used
Indexed (Displacement)
Operand + Index register = address of data to be loaded
Relative
Operand + Address register = address of data to be loaded