You can use preprocessor directive :
#ifdef 65C816 ldy #512+256 loop2 lda charset,y sta $b500,y dey bne loop2 #else ldy #0 loop lda charset,y sta $b500,y lda charset+256,y sta $b500+256,y lda charset+512,y sta $b500+512,y iny bne loop #endif rts