AQA Assemby Language Activity |
About the Assembly Language Activity.
The Assembly Activity allows small programs to be entered using the assembly language based
on the one used by AQA in its Computer Science exams. It uses an input mechanism which restricts the entry so that only
valid code can be entered as well as the option to enter code using text entry.
The code can then be run using the Session tab. This allows for memory data to be entered and then for the code to be run. There is
also the option to run the code line by line that shows the registers and flags being updated at each point.
This activity can be used to give a better understanding of Assembly language and how it works.
The machine code tab simulates how a program is loaded into memory and run. The machine code instruction set is loosely based on
the ARM instruction set, using where possible, similar opcode values. Each instruction is stored in three bytes. One for the opcode and
two for the operands. (Three 4-bit values for the registers or two 4-bit values for the registers and one 8-bit value for the data).
Note that all values are restricted to a byte and all values and results are therefore taken as the modulo of 256.
Code Entry |
|||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||
Set the Program Name
Text Edit
Enter the assembly language commands directly
Session
Register Values
Flag Values
Assembly Code
Line Counter: |
Last Instruction
Set Memory Value (Values in Decimal)
| Memory Location: | ||
| Value: |
General Memory
Machine Code Session
Register Values
Flag Values
Assembly Language and Machine Code
Label Addresses
Program Counter: |
Code Memory (Values in hexadecimal)
Current Instruction (Hexadecimal)
General Memory (Values in hexadecimal)
Example Programs |
There are a number of example programs which can be loaded in to illustrate how Assembly-Code can be written and run using this application. |
|
Add |
Adds the values in memory locations 0 and 1 together.
|
Count to 10 |
Counts through the numbers from 1 to 10, using register 0 to store the values. |
multiply |
Multiplies the values in memory locations 0 and 1 together.
|
Power of 2 |
Calculates 2 to the power of the value stored in memory location 0 using the LSL command.
|
Divide by 16 |
Divides the value in memory locations 0 by 16.
|
Div and Mod |
Does an integer division on the value in memory location 0 by the value in memory location 1.
|
Is Even |
Does a bitwise logical AND with 1 to find whether the value in memory location 0 is odd or even..
|
A and B or C |
Does a bitwise logical AND between the values in memory locations 0 and 1 and then does a bitwise logical OR between the result and the value in memory location 2.
|
NAND |
Does a bitwise logical AND between the values in memory locations 0 and 1.
|
Triangular Numbers |
Calculates the triangular number of the value in memory location 0.
|
Commands
The following Assembler Commands are used in this similator. The operands used are:
- Rd: Register number d. When a calculation is performed, the result is stored in the register d
- Rn. Register number n
- operand2: Either a register or a value preceded by #
- label: a label that has been assigned to a specific code line
- memory-ref: A location in memory
Command |
Detail |
||
Opcode |
Operands |
Machine Code |
|
ADD |
Rd Rn operand2 |
#04 - operand2 is a register#24 - operand2 is a value |
Add the value in Rn to the value of operand2.The result goes in Rd |
AND |
Rd Rn operand2 |
#00 - operand2 is a register#20 - operand2 is a value |
Perform a bitwise logical AND between the value in Rn and the value of operand2The result goes in Rd |
B |
label |
$8E |
Branch always to the position in the code of label. |
BEQ |
label |
#80 |
Branch if the EQ flag is equal to Y to the position in the code of label |
BNE |
label |
#81 |
Branch if the NE flag is equal to Y to the position in the code of label |
BLT |
label |
#8B |
Branch if the GT flag is equal to Y to the position in the code of label |
BGT |
label |
#8C |
Branch if the LT flag is equal to Y to the position in the code of label |
CMP |
Rd operand2 |
#0A - operand2 is a register#2A - operand2 is a value |
Compares the value in Rd with the value of operand2Sets the flag bits depending on the result |
EOR |
Rd Rn operand2 |
#01 - operand2 is a register#21 - operand2 is a value |
Perform a bitwise logical XOR between the value in Rn and the value of operand2The result goes in Rd |
HALT |
label |
#C0 |
Forced Interupt |
LBL |
label |
Labels a point in the code to branch to |
|
LDR |
Rd operand2 |
#58 |
Load the value in memory location memory-ref to the register Rd |
LSL |
Rd Rn operand2 |
#0E - operand2 is a register#2E - operand2 is a value |
Logical Shift Left the value in Rn by the number of bits given by operand2The result goes in Rd |
LSR |
Rd Rn operand2 |
#0F - operand2 is a register#2F - operand2 is a value |
Logical Shift Right the value in Rn by the number of bits given by operand2The result goes in Rd |
MOV |
Rd operand2 |
#0D - operand2 is a register#2D - operand2 is a value |
Move the value of operand2 into register Rd |
MVN |
Rd Rn operand2 |
#07 - operand2 is a register#27 - operand2 is a value |
Perform a bitwise logical NOT between the value in Rn and the value of operand2The result goes in Rd |
ORR |
Rd Rn operand2 |
#0C - operand2 is a register#2C - operand2 is a value |
Perform a bitwise logical OR between the value in Rn and the value of operand2The result goes in Rd |
STR |
Rd memory-ref |
#48 |
Store the value in register Rd to memory location memory-ref |
SUB |
Rd Rn operand2 |
#02 - operand2 is a register#22 - operand2 is a value |
Subtract the value of operand2 from the value in RnThe result goes in Rd |
