# *A (0) -> next output
A = 0x0fff
*A = A
# Store pressed key to D
begin:
A = 0x6000
D = *A
# check with prev clock pressed value
A = begin
*A - D; JEQ
# get store address
A = 0x0fff
*A = *A + 1
A = *A
# store pressed key
*A = D
A = begin
JMP
Я написал код
Но я не успеваю буквально на 2 такта, для прохождения уровня мне надо сохранить значение до 10 такта включительно, но я сохраняю на 12 (на первой итерации) и на 10-ой на остальных. Помогите исправить код (сжать или вообще поменять идею)
Note: на сайте используется не стандартный assembler, а свой со своими правилами:
**Assembler quick reference**
Syntax is: destination = calculation ; jump-condition Destination and jump-condition are optional.
D and A are the two registers. *A indicate the value in RAM at the address contained in A.
**Examples:**
D = D + 1 Calculate D + 1 and store the result in D.
D - 1 ; JGE Calculate D - 1. Jump if the result is greater than 0. (Result is not stored.)
A = 1234 Store the number 1234 in the A register.
# Hello Comment - ignored by assembler
**Calculations**
D + A
D - A or A - D
D & A (Bitwise and)
D | A (Bitwise or)
A+1 or D+1
A-1 or D-1
-A or -D
~A or ~D (Bitwise inversion)
1 or 0 or -1
In all cases can *A be used instead of A.
**Destinations**
Any combination of D, A and *A can be used as destination. Multiple destinations are comma separated, e.g. D, A = 1.
**Jump conditions**
Jump when result of calculation is:
JEQ equal to 0
JNE not equal to 0
JGT greater than 0
JGE greater than or equal to 0
JLT less than 0
JLE less than or equal to 0
JMP Unconditional jump (regardless of the calculation result.)
**Number instructions**
A can be directly assigned a number. Example: A = 47.
Numbers in hexadecimal is prefixed with 0x, e.g: A = 0x7FFF
Numbers in binary is prefixed with 0b, e.g: A = 0b010111. Underscores can be used to separate digit groups, e.g: A = 0b_0101_1100.
**Comments**
Lines staring with # are ignored by the assembler. They can be used for comments and documentation.
**Labels**
The keyword LABEL followed by a name makes the name represent the address of the following instruction. This address can be assigned to A before a jump, e.g. A = LOOP.
**Defines**
The keyword DEFINE followed by a name and a number will cause the name to be replaced with the number when it occurs in other instructions. For example the two lines:
DEFINE foo 0x7FFF
A = foo
Is equivalent to: A = 0x7FFF
**Multiple targets**
It it possible to assign a result to multiple registers.
E.g. D, A = D - *A The result of the calculation will be written to both A and D.
Any combination of A, D and *A can be specified as destination.