Canite wrote:I think that would work though, right?
Almost! You got the right idea, there are just a couple of logic issues:
1. The "CPY #$FF" is not necessary. If you use it, you will actually copy 255 bytes instead of 256. Just let Y wrap back to $00 with the INY, and because the Z flag will be set the branch will not happen, so there's no need to compare anything. As a bonus you also don't need to reset Y later, as it will already be 0.
2. Similar to the above, you don't need the "CPX #$00". This isn't an error though, it's just redundant. If the result of any operation is zero, the Z flag will be set, so there's no need to compare against #$00.
The status flags are kinda mystical for people who have never programmed in assembly before (for me at least that was one of the weirdest things). Just keep in mind that a lot of instructions modify the flags (specially the ones that manipulate values in any way), and after these modifications you can use the branch instructions to make decisions about what to do next. You don't have to "compare" all the time, as most of the time the operations themselves will set the flags for you.