Your place is saved automatically on this browser.
For unsigned values, CP followed promptly by JR C answers ‘is A below this limit?’ Here is another complete experiment. Replace the previous source; do not append it.
Here $10 (decimal 16) is below $20 (decimal 32). The comparison requires a borrow, so Carry is set and execution goes to smaller. Expected result: B = $01 and A = $10. Change A to $30 (decimal 48) and the branch is not taken: B becomes $00.
A useful pattern for a proposed Next Asset Lab routine is cp limit followed by jr c,within_range. But remember the word unsigned. For signed negative numbers, Carry alone does not tell you whether one signed value is less than another. Correct signed comparisons require considering the overflow condition too; they are not simply a matter of checking S in isolation. We will revisit advanced signed comparison strategies when coordinate and movement code needs them.
What to record in your notebook
For each run, record: the A value, the comparison value, whether Z was set, whether Carry was set, which label executed, and the final B value. This is a small form of testing. Once the relationship between input and output becomes predictable, the machine is no longer mysterious.
