ST Instruction
The ST instruction allows storing of values at specific addresses
Stores a register into memory
ST
The ST instruction stores a given register's value in an address relative to the current program counter + the given offset.
0011 SR1 FFFFFFFFF
Input
- 0011
- The ST opcode
- SR1
- Source Register who's value is going to be copied to an address
- FFFFFFFFF
- Offset based on Program Counter + Offset, where the value will be stored at.
Example:
0011 000 000000011
This will take the value stored at R0, and store the value at the address that is 1 + 0000 0001 1
Which is (1 + 2) addresses away from the ST command.
STR
The STR instruction stores the value of a given input at the base address of a given register's value + the offset given
0111 SR1 RRR FFFFFF
Input
- 0111
- The STR opcode
- SR1
- Source of register's value which we are copying to an address
- RRR
- Base Register, Use it's value + offset to calculate address to which we are storing the value
- FFFFFF
- Offset, used to calculate destination base + offset
Example:
0111 000 001 000001
This line will get the value stored at R0, Get the value at R1, Add R1's value to the offset(000001 = 1), and store the value at that given address.
Let's say R1's value = x4000
(hex) or in binary 0100 0000 0000 0000
(binary) and our offset is still 000001
so it'd be x4000 + 1 = x4001. Therefore, the value stored at R0 will be stored at address x4001