eflake Posted October 13, 2020 Share Posted October 13, 2020 (edited) I'm trying to load in a charset using an example, how would I change this to a 16-bit counter to read the entire 1024 bytes of a redefined character set? Can only seem to go to 255 - thought X was a 16 bit register. Thanks. space_loop lda charset.space,x sta chr,x inx cpx $400 bne space_loop Edited October 13, 2020 by eflake Quote Link to comment Share on other sites More sharing options...
Rybags Posted October 13, 2020 Share Posted October 13, 2020 On the 6502 and non 16 bit derivatives the only 16-bit register is the PC. Zero-page can be sort of like a bunch of psuedo 16-bit registers since the indirect addressing modes use them as such. To copy more than 256 bytes there's generally 3 usual options: . Use extra indexed instructions e.g. lda charset.space+$100,x / sta chr+$100,x . Use a pair of z-page pointers. The usual case there is when the size to be copied is variable or unknown. More coding needed and you usually keep a counter for the # of pages or do a compare when incrementing the high byte of source or destination. . Self-modifying code. It can be done in a compact fashion and can often be the fastest method but hard to debug if things go wrong. 1 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted October 13, 2020 Share Posted October 13, 2020 you need an outer loop and an inner loop and as @Rybags said page zero pointers something like this lda #source&255 sta $E0 lda #source/256 sta $E1 lda #dest&255 sta $E2 lda #dest/256 sta $E3 ldx #4 ; will move 1K loop ldy #0 lda ($E0),y sta ($E2),y iny bne loop dex bne loop 1 Quote Link to comment Share on other sites More sharing options...
StickJock Posted October 13, 2020 Share Posted October 13, 2020 47 minutes ago, TGB1718 said: ldx #4 ; will move 1K loop ldy #0 lda ($E0),y sta ($E2),y iny bne loop dex bne loop Almost.... You still need to inc $E1 & $E3 in the outer loop. As written, it will just copy the same $100 bytes four times. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted October 13, 2020 Share Posted October 13, 2020 22 minutes ago, StickJock said: You still need to inc $E1 & $E3 in the outer loop. As written, it will just copy the same $100 bytes four times oops, knew I missed something Quote Link to comment Share on other sites More sharing options...
StickJock Posted October 13, 2020 Share Posted October 13, 2020 Or you just wanted to really make sure those $100 bytes were copied! ? Quote Link to comment Share on other sites More sharing options...
eflake Posted October 13, 2020 Author Share Posted October 13, 2020 m'kay 224-229 E0-E5 FR1 Floating point register one; holds a six-byte internal form of the FP number as does FR0. The FP package frequently transfers data between these two registers and uses both for two-number arithmetic operations. Quote Link to comment Share on other sites More sharing options...
ivop Posted October 13, 2020 Share Posted October 13, 2020 4 hours ago, eflake said: space_loop lda charset.space,x sta chr,x inx cpx $400 bne space_loop If X was 16-bit, you'd need #$400 I would copy a kilobyte without using page zero. Like Rybags said: ; mads syntax ldx #0 loop mva src+$0000,x dst+$0000,x mva src+$0100,x dst+$0100,x mva src+$0200,x dst+$0200,x mva src+$0300,x dst+$0300,x inx:bne loop 4 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted October 13, 2020 Share Posted October 13, 2020 45 minutes ago, ivop said: I would copy a kilobyte without using page zero. Like Rybags said: Agreed, that's much better for small chunks of code, I just looked at some code I used in a Centronics Printer handler I wrote many moons ago that moved the OS ROM into RAM, then overwrote the internal printer handler with my own code (saved using any memory), so was moving lots more code Quote Link to comment Share on other sites More sharing options...
eflake Posted October 13, 2020 Author Share Posted October 13, 2020 (edited) This did it, thanks. to get it to where i can understand it - and it seems smart doing 4 at once ldx #0 ;set counter to 0 space_loop mva charset.space,x chr,x ;move charset(x) to High byte of character set pointer mva charset.space+$100,x chr+$100,x ;move charset(x+256) to High byte of character set pointer mva charset.space+$200,x chr+$200,x ;move charset(x+512) to High byte of character set pointer mva charset.space+$300,x chr+$300,x ;move charset(x+768) to High byte of character set pointer mva charset.space+$400,x chr+$400,x ;move charset(x+1024) to High byte of character set pointer inx ;add 1 to pointer (counter) bne space_loop ;if not rolled over keep looping Edited October 13, 2020 by eflake 1 Quote Link to comment Share on other sites More sharing options...
StickJock Posted October 13, 2020 Share Posted October 13, 2020 In the above code, you are actually copying $500 bytes instead of $400 bytes. Your last mva line will copy bytes $400..$4FF. For a character set, you only want to copy bytes $000..$3FF (1KB). 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.