AQA Style Microcontroller Simulation - Electronics Tutorials |
Each instruction consists of a six bit op code and an eight bit operand.
The op code is fetched on the instruction bus and simultaneously, the operand is fetched on the data bus.
When the power is switched on, or after a reset, code execution starts from address 0x00.
This image shows the buses linking the internal microcontroller devices

A Possible Pinout

The simulator clock can be set between 0Hz and 120Hz. The upper limit is determined by the maximum Flash player frame rate. With older hardware, the higher clock rates might not be achieved. These slow clock speeds make visible strange effects that are never seen with real-life microcontrollers. For example, seven segment displays switching from 09 to 10 might show 19 for a brief moment because it is impossible to change both digits at the same instant.
The code is not case sensitive so movw is the same as MOVW and 0XFF is the same as 0xff.
Most features in the AQA specification are now available in the simulator.
K is used to represent a literal, which can be a memory location (e.g. 0x29), a label (e.g. display:) or a value, (e.g. 0xFA).
KKKK KKKK represents the same as an eight bit binary number.
Legal literal names for K begin with _ or a text character.
Literal names must not begin with a digit and must only contain _ : a-z A-Z 0-9.
Literal names must not duplicate reserved words such as MOVW or CALL.
Literal names must be unique or the assembler will not be able to resolve the ambiguity.
R represents a register or memory location.
RR RRRR RRRR RRRR is a fourteen bit binary representation of the same.
XX XX represents a fourteen bit or four digit hexadecimal number.
x (lower case) is a "don't care" value that is ignored.
Mnemonics & |
Description |
Operation |
OP Codes in Binary |
Flags |
Clock |
|
NOP |
No Operation |
None |
00 0000 xxxx xxxx |
none |
1 |
|
CALL K |
Call procedure |
(SP) <= PC + 1, SP <= SP - 1, PC <= K |
10 0000 KKKK KKKK |
none |
2 |
|
RET |
Return from procedure or interrupt |
SP <= SP + 1, PC <= (SP) |
00 0000 0000 1000 |
none |
2 |
|
INC R |
Increment the contents of R |
(R) <= (R) + 1 |
00 1010 RRRR RRRR |
Z |
1 |
|
DEC R |
Decrement the contents of R |
(R) <= (R) - 1 |
00 0011 RRRR RRRR |
Z |
1 |
|
ADDW K |
Add K to W |
W <= W + K (Addition) |
11 1110 KKKK KKKK |
Z, C |
1 |
|
ANDW K |
And K with W |
W <= W & K (AND) |
11 1001 KKKK KKKK |
Z |
1 |
|
SUBW K |
Subtract K from W |
W <= W - K (Subtraction) |
11 1100 KKKK KKKK |
Z, C |
1 |
|
ORW K |
OR K with W |
W <= W | K (OR) |
11 1000 KKKK KKKK |
Z |
1 |
|
XORW K |
XOR K with W |
W <= W ^ K (XOR) |
11 1010 KKKKKKKK |
Z |
1 |
|
JMP K |
Jump to K (GOTO) |
PC <= K |
10 1000 KKKK KKKK |
none |
2 |
|
JPZ K |
Jump to K if the Zero Flag is set |
PC <= K |
10 1001 KKKK KKKK |
none |
2 |
|
JPC K |
Jump to K if the Carry Flag is set |
PC <= K |
10 1010 KKKK KKKK |
none |
2 |
|
MOVWR R |
Copy from W into the register with address R |
(R) <= W |
00 0001 RRRR RRRR |
Z |
1 |
|
MOVW K |
Move K to W |
W <= K |
11 0000 KKKK KKKK |
Z |
1 |
|
MOVRW R |
Copy the contents of R to W |
W <= (R) |
00 1000 RRRR RRRR |
Z |
1 |
|
MOVRW SR |
Copy the contents of SR into W |
W = (SR) |
00 1001 RRRR RRRR |
N/A |
1 |
|
K |
Label used with jumps and CALL |
K is a reference to a register address. This address can be used with CALL and Jump commands. When used as a label, no data is stored at the address. Care should be taken NOT to assign a value to a label as this would overwrite a word of program code. Destination labels must end with a : and must be unique. |
N/A |
N/A |
N/A |
|
Other Reserved Words - These are constants that refer to memory mapped Register locations. |
||||||
trisa |
0xF8 |
|||||
porta |
0xF9 |
|||||
trisb |
0xFA |
|||||
portb |
0xFB |
|||||
trisc |
0xFC |
|||||
portc |
0xFD |
|||||
pre |
0xFE |
|||||
tmr |
0xFF |
|||||
Additional Instructions NOT in the AQA Specification |
||||||
DW K |
Define Word |
NOT YET AVAILABLE |
K is stored into a memory register. |
N/A |
N/A |
|