To be perfectly honest, I forgot to cover the comparison instructions in Day 6 so I'm going to have this Day 8 just be a short one on compares.
There are three compare instructions:
where "value" is either a number, or a value from a memory location*
Have you noticed that there's no compare instruction to compare the registers together? Weird! :)
Some examples of use:
cpx #32 ; remember to put a '#' (decimal) or a '#$' (hex) before immediate ; numbers. (immediate==just a number, not an address) cpy $2002 ; compares Y with contents of $2002 cmp #$20 ; compares A with 20 in hex. beq IfEqual ; branches to label IfEqual, if A was equal to #$20.
Compare instructions are used to set those conditions we talked about in Day 6, so that we can use the conditional jumps (BEQ, BNE, BCC, etc...).
Sorry about leaving this out of Day 6, I guess my mind just slipped.
Until Next Time,
-Mike H a.k.a GbaGuy