artrag Posted October 15, 2019 Share Posted October 15, 2019 I'm compiling this line of code A = PEEK($0200+(X-8)/8+ (Y+3 AND $F8)/2*5) and I get this MVI var_X,R1 SUBI #8,R1 SLR R1,2 SLR R1,1 ADDI #512,R1 MVI var_Y,R2 ADDI #3,R2 ANDI #248,R2 SLR R2,1 MULT R2,R4,5 ADDR R2,R1 MVI@ R1,R0 MVO R0,var_&A Later I compile this line: A = PEEKAT(X-8,Y+3) where I've defined DEF FN PEEKAT(x,y) = #backtab((x)/8+ ((y) AND $F8)/2*5) and I get this: MVI var_X,R1 SUBI #8,R1 SLR R1,2 SLR R1,1 MVI var_Y,R2 ADDI #3,R2 ANDI #248,R2 SLR R2,1 MULT R2,R4,5 ADDR R2,R1 MVII #Q2,R2 ADDR R2,R1 MVI@ R1,R0 MVO R0,var_&A It seems that this latter solution using backtab is slower and larger in ROM Is this correct? And if yes, why? Quote Link to comment Share on other sites More sharing options...
+nanochess Posted October 17, 2019 Share Posted October 17, 2019 The IntyBASIC compiler isn't smart enough to discover that #backtab is a constant, so it loads it separately inside a register, instead of adding it directly. 1 Quote Link to comment Share on other sites More sharing options...
artrag Posted October 17, 2019 Author Share Posted October 17, 2019 can't the 200h address be embedded in the asm generated by the compiler? Quote Link to comment Share on other sites More sharing options...
intvnut Posted December 4, 2019 Share Posted December 4, 2019 On 10/15/2019 at 10:45 AM, artrag said: ((y) AND $F8)/2*5) I keep staring at that and it hurts my eyes. I know you're losing 6 cycles to "ADDI" being split into "MVII + ADDR", but it feels like you're losing as much to "SLR + MULT." This sequence: ANDI #248,R2 SLR R2,1 MULT R2,R4,5 ADDR R2,R1 expands to: ANDI #248,R2 SLR R2,1 MOVR R2,R4 SLL R2,2 ADDR R4,R2 ADDR R2,R1 That's 40 cycles and 7 words. If you coded this in assembly yourself you could do: ANDI #$F8, R2 SLR R2, 1 ADDR R2, R1 SLL R2, 2 ADDR R2, R1 That's 34 cycles and 6 words, and leaves R4 untouched. *shrug* If you care about 6 cycles and one word, why not code directly in assembly? 1 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.