Mikes360 Posted August 23, 2013 Share Posted August 23, 2013 Hi Guys, I have started creating a few macros to tidy up some of my code and wrap up common routines. I have created a macro that copy a table of ROM addresses to RAM and for some reason its not assembling correctly in DASM. MAC COPY_TO_RAM_BUFFER .ADDRESS SET {1} .INDEX SET {2} .RAM_BUF SET {3} ldy .INDEX .copyLoop lda .ADDRESS+1,y sta .RAM_BUF+1,y lda .ADDRESS,y sta .RAM_BUF,y dey dey bpl .copyLoop ENDM Example usage: COPY_TO_RAM_BUFFER PointZeroLogoTable, 12, spriteBuf Can anyone see an obvious error looking at this? Thanks, Mike Quote Link to comment Share on other sites More sharing options...
Mikes360 Posted August 23, 2013 Author Share Posted August 23, 2013 As soon as I posted this I thought it could be optimised better but it still wont actually work! MAC COPY_TO_RAM_BUFFER .ADDRESS SET {1} .INDEX SET {2} .RAM_BUF SET {3} ldy .INDEX .copyLoop lda .ADDRESS,y sta .RAM_BUF,y dey bpl .copyLoop ENDM Example usage: COPY_TO_RAM_BUFFER PointZeroLogoTable, 13, spriteBuf Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted August 23, 2013 Share Posted August 23, 2013 (edited) What is getting assembled in DASM? Maybe DASM doesn't know, which address is 8 or 16 bit. Try lda.w .ADDRESS. Edited August 23, 2013 by Thomas Jentzsch Quote Link to comment Share on other sites More sharing options...
Mikes360 Posted August 23, 2013 Author Share Posted August 23, 2013 I have added the DASM output below. The first argument is a Table of addresses in ROM the second argument is the size of the table in bytes and the third is the location of the RAM buffer. 216 f89b CopyPointZeroLogoToSpriteBuf SUBROUTINE 217 f89b 0 f89b COPY_TO_RAM_BUFFER PointZeroLogoTable, 13, spriteBuf 1 f89b 2 f89b .ADDRESS SET PointZeroLogoTable 3 f89b .INDEX SET 13 4 f89b .RAM_BUF SET spriteBuf 5 f89b 6 f89b a4 0d ldy .INDEX 7 f89d .copyLoop 8 f89d b9 c3 f3 lda .ADDRESS,y 9 f8a0 99 dc 00 sta .RAM_BUF,y 10 f8a3 88 dey 11 f8a4 10 f7 bpl .copyLoop 12 f8a6 219 f8a6 220 f8a6 60 rts Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted August 23, 2013 Share Posted August 23, 2013 ldy #.INDEX 1 Quote Link to comment Share on other sites More sharing options...
Mikes360 Posted August 23, 2013 Author Share Posted August 23, 2013 (edited) Ok I see what you mean now! Thanks for that. Edited August 23, 2013 by Mikes360 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted August 23, 2013 Share Posted August 23, 2013 So how should this be done? Just use the # before loading .INDEX. Else DASM will load from RAM address 13. Quote Link to comment Share on other sites More sharing options...
Mikes360 Posted August 23, 2013 Author Share Posted August 23, 2013 Yes I should have spotted that thank you very much for the swift response. Quote Link to comment Share on other sites More sharing options...
+SvOlli Posted August 23, 2013 Share Posted August 23, 2013 Also think about using X instead of Y, saves you one byte of ROM, because of sta ZP,x. Quote Link to comment Share on other sites More sharing options...
Mikes360 Posted August 24, 2013 Author Share Posted August 24, 2013 Interesting I didn't know that it was not the same for Y. Thanks SvOlli ill change my macro as I need every byte I can get! If anyone else wants a good reference to work out cycle and byte counts for 6502 I find this useful: http://www.obelisk.demon.co.uk/6502/reference.html#STA 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.