sta #$00,x makes no sense and will not assemble. You probably meant
sta $00,x. Immediate addressing (
#) is not the same thing as indexed addressing
$blah,x.
Your loop is broken and the code doesn't even really make sense. :-)
First, you're saying
inx / bne. In English this means: increment the X register (which affects the zero flag); next, if the zero flag IS NOT set (i.e. if the value in X is non-zero), then branch to ColumnMapDone (which is the label right after the
bne). What you probably meant was
bne ColumnMap, to keep the loop iterating until X had wrapped to zero -- but this really isn't what you want either, because you'll end up copying data past where ColumnData ends (there's only 32 bytes of data there).
Second, in the code you showed, you don't define what X contains at before ColumnMap is reached. It could be $20, it could be $00, who knows. So your "starting offset" (into the ColumnData buffer) is going to vary, as well as the starting location in ZP where the values are being copied to. But, funny enough, that doesn't really matter because you have your branch conditional inverted (IMO), or the label wrong (my guess is this) as I describe above.
I can't tell exactly what you're wanting to do with this routine. Are you wanting to copy 16 bytes into ZP $00-$0F? 32 bytes into ZP $00-1F? Do you want some kind of support for an offset into the ColumnData table (say, starting at byte 5 (value $05) and thus copy only 11 bytes)? If so, do you want that copied into $00-0B or $05-0F? All this matters!
As for a literal answer to your initial question: it's easy: you use a compare instruction (
cmp for accumulator,
cpx for X,
cpy for Y) and then do your branch instruction after that. For data copying routines, you have two approaches: 1) you pre-calculate the length of the data you're copying and iterate in a loop that number of times, or b) you use a special byte/value that signifies "end of buffer" (think NULL string termination in C).
Edit: Sorry about the first example. My brain was off in some weird state where I was thinking about dealing with multiple loops (for >256 byte copies) and didn't write the routine even remotely correctly. The simple version:
Code:
ldx #0
ColumnLoop:
lda ColumnData,x
sta $00,x
inx
cpx #32
bne ColumnLoop
...
ColumnData:
.db $01,$02,$03,$04,$05,$06,$07,$08,$09,$10,$0A,$0B,$0C,$0D,$0E,$0F
.db $02,$03,$04,$05,$06,$07,$08,$09,$10,$11,$1A,$1B,$1C,$1D,$1E,$1F
For the latter, if you know ColumnData will never contain the value $FF, then you could simply compare for that using
cmp #$ff like so. (This routine will break badly if you try to copy more than 256 bytes, but it should be obvious why):
Code:
ldx #0
ColumnLoop:
lda ColumnData,x
cmp #$ff
beq ColumnDone
sta $00,x
inx
jmp ColumnLoop
ColumnDone:
...
ColumnData:
.db $01,$02,$03,$04,$05,$06,$07,$08,$09,$10,$0A,$0B,$0C,$0D,$0E,$0F
.db $02,$03,$04,$05,$06,$07,$08,$09,$10,$11,$1A,$1B,$1C,$1D,$1E,$1F
.db $FF ; End of buffer