RXB Posted June 27, 2013 Share Posted June 27, 2013 Something I rarely do is write Assembly support but this is driving me nuts? CLR R6 or CLR R3 or CLR R8 all error out as SYNTAX ERROR or INVALID REGISTER?????? TITL 'SPEED UP ROUTINES' AORG >B000 WRKSPC DATA 0 R0 ADDRESS OF X DATA 0 R1 RETURN VALUE G DATA 0 R2 VALUE TO CHECK 225,226,227,128 DATA 0 R3 DATA 0 R4 ADDRESS OF X MODIFIED DATA 0 R5 DATA 0 R6 value found DATA 0 R7 DATA 0 R8 DATA 0 R9 DATA 0 R10 POSITIONS DATA 0 R11 1 2 3 DATA 0 R12 4 5 6 DATA 0 R13 7 8 9 DATA 0 R14 UR CLR R1 G LI R2,225 VALUES 225 226 227 UPRT MOV R0,R4 POSITION 5 AI 33,R4 POSITION 9 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ URG YES MOV R0,R4 POSITION 5 AI 32,R4 POSITION 8 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ URG YES MOV R0,R4 POSITION 5 AI 31,R4 POSITION 7 LI R6.0 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ URG YES MOV R0,R4 POSITION 5 AI 1,R4 POSITION 6 CLR R6 MOVB *R4,R6 GET VALUE C R2,R6 EQUAL? JEQ URG YES MOV R0,R4 POSITION 5 AI -1,@R4 POSITION 4 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ URG YES MOV R0,R4 POSITION 5 AI -31,R4 POSITION 3 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ URG YES MOV R0,R4 POSITION 5 AI -32,R4 POSITION 2 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ URG YES MOV R0,R4 POSITION 5 AI -33,R4 POSITION 1 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ URG YES CI R2,227 LOOP DONE? JEQ RETURN YES INC R2 KEEP GOING JMP UPRT LOOP URG CI R2,227 JNE URG2 LI R1,128 JMP RETURN URG2 INC R2 MOV R2,R1 RETURN RTWP DL CLR R1 G LI R2,225 VALUES 225 226 227 DWNLFT MOV R0,R4 POSITION 5 AI -33,R4 POSITION 1 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ URG YES MOV R0,R4 POSITION 5 AI -32,R4 POSITION 2 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ URG YES MOV R0,R4 POSITION 5 AI -31,R4 POSITION 3 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ URG YES MOV R0,R4 POSITION 5 AI -1,R4 POSITION 4 CLR R6 MOVB *R4,R6 GET VALUE C R2,R6 EQUAL? JEQ URG YES MOV R0,R4 POSITION 5 AI 1,@R4 POSITION 6 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ URG YES MOV R0,R4 POSITION 5 AI 31,R4 POSITION 7 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ URG YES MOV R0,R4 POSITION 5 AI 32,R4 POSITION 8 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ URG YES MOV R0,R4 POSITION 5 AI 33,R4 POSITION 9 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ URG YES CI R2,227 LOOP DONE? JEQ RETURN YES INC R2 KEEP GOING JMP DWNLFT LOOP END What the hell is wrong? Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted June 27, 2013 Share Posted June 27, 2013 Hi Rich: The CLR should be OK. Your mistake is in the AI instructions. They should be AI R4,32 and not AI 32,R4. Most of your AI instructions are followed by CLR and I think you are just one line off when you read the error message. Quote Link to comment Share on other sites More sharing options...
RXB Posted June 27, 2013 Author Share Posted June 27, 2013 Thanks will try that but the stupid Assembler says the line that has the syntax error is the lines with the CLR R6 Quote Link to comment Share on other sites More sharing options...
Willsy Posted June 27, 2013 Share Posted June 27, 2013 Yes, your AI instructions have the parameters the wrong way around. Also worth mentioning (for the benfit of others) make sure you select R as an options when asked for options by the TI assembler! Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted June 27, 2013 Share Posted June 27, 2013 Yes, your AI instructions have the parameters the wrong way around. Also worth mentioning (for the benfit of others) make sure you select R as an options when asked for options by the TI assembler! Just to clarify (for the benefit of others), without specifying the R option, registers can only be referenced by number. The R option includes sixteen EQUates for registers, viz., R0 EQU 0 ... . You can, of course, include them yourself. ...lee Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted June 27, 2013 Share Posted June 27, 2013 ... What the hell is wrong? Two of your lines are not only backwards but misuse '@' with registers (probably an oversight). ~line 51 AI -1,@R4 POSITION 4 should be AI R4,-1 POSITION 4 ~line 121 AI 1,@R4 POSITION 6 should be AI R4,1 POSITION 6 ...lee Quote Link to comment Share on other sites More sharing options...
RXB Posted June 27, 2013 Author Share Posted June 27, 2013 Ok cleaned up the code and looks good now. TITL 'SPEED UP ROUTINES' AORG >C000 UPLFT DATA WRKSPC BOTH USE WORKSPACE DATA UL DWNRT DATA WRKSPC BOTH USE WORKSPACE DATA DR DOWN AND RIGHT DR CLR R1 G LI R2,225 VALUES 225 226 227 DRT MOV R0,R4 POSITION 5 AI R4,33 POSITION 9 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,32 POSITION 8 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,31 POSITION 7 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,1 POSITION 6 CLR R6 MOVB *R4,R6 GET VALUE C R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,-1 POSITION 4 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,-31 POSITION 3 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,-32 POSITION 2 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,-33 POSITION 1 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ GOUT YES CI R2,227 LOOP DONE? JEQ RETURN YES INC R2 KEEP GOING JMP DRT LOOP GOUT CI R2,227 227? JNE GOUT2 LI R1,128 Replace with blank JMP RETURN Done GOUT2 INC R2 Replace with 225? or 226? MOV R2,R1 Load G with value RETURN RTWP Done go back to RXB UL CLR R1 G LI R2,225 VALUES 225 226 227 ULT MOV R0,R4 POSITION 5 AI R4,-33 POSITION 1 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,-32 POSITION 2 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,-31 POSITION 3 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,-1 POSITION 4 CLR R6 MOVB *R4,R6 GET VALUE C R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,1 POSITION 6 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,31 POSITION 7 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,32 POSITION 8 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,33 POSITION 9 CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? JEQ GOUT YES CI R2,227 LOOP DONE? JEQ RETURN YES INC R2 KEEP GOING JMP ULT LOOP WRKSPC DATA 0 R0 ADDRESS OF X PRELOADED BYTE 0 R1 MSB G BYTE 0 ADRESS VALUE G PRELOADED DATA 0 R2 VALUE TO CHECK 225,226,227,128 DATA 0 R3 DATA 0 R4 ADDRESS OF X MODIFIED DATA 0 R5 DATA 0 R6 value found DATA 0 R7 DATA 0 R8 DATA 0 R9 DATA 0 R10 POSITIONS DATA 0 R11 1 2 3 DATA 0 R12 4 5 6 DATA 0 R13 7 8 9 DATA 0 R14 DATA 0 R15 END Quote Link to comment Share on other sites More sharing options...
RXB Posted June 27, 2013 Author Share Posted June 27, 2013 Two of your lines are not only backwards but misuse '@' with registers (probably an oversight). ~line 51 AI -1,@R4 POSITION 4 should be AI R4,-1 POSITION 4 ~line 121 AI 1,@R4 POSITION 6 should be AI R4,1 POSITION 6 ...lee I want to use the address of the contest of R4 bo put in R6, so I wrote MOVB *R4,R6 I only use GPL mostly so out of touch on Assembly lately. Quote Link to comment Share on other sites More sharing options...
Willsy Posted June 27, 2013 Share Posted June 27, 2013 Rich, Hope you don't mind me commenting, but I'm seeing this pattern in your code: CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? You can save two bytes each time by using this technique: MOVB *R4,R6 get value SRL R6,8 move to low-byte C R2,R6 equal? From a quick scan of the code, I reckon you can save 30 bytes, which is worth having. It's also faster, as you are executing fewer instructions. For what it's worth... Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted June 27, 2013 Share Posted June 27, 2013 Haven't gone through your code in detail, but iIt looks as if you are comparing bytes. If so, here's a way that is even shorter and faster. Instead of: CLR R6 MOVB *R4,R6 SWPB R6 C R2,R6 you could write: CB *R4,@WRKSPC+5 (WRKSPC+5 is the LSB of R2) 1 Quote Link to comment Share on other sites More sharing options...
Tursi Posted June 27, 2013 Share Posted June 27, 2013 (edited) CLR R6 SWPB R6 LSB SRL R6,8 move to low-byte It's also faster, as you are executing fewer instructions. It's almost a wash, speed-wise. The shift will take 12+16=28 cycles, the swap will take 10. The CLR is a 10 cycle instruction, so you have 8 cycles left in the difference. It'll take 4 cycles to read the extra word in 8-bit memory, so the SWPB is actually 4 cycles faster. In 16-bit RAM it would be 8 cycles faster. The 9900's shifts are 2 cycles per bit, so they add up quick. In most cases, though, saving the RAM is worth 4 cycles. Edited June 27, 2013 by Tursi Quote Link to comment Share on other sites More sharing options...
RXB Posted June 27, 2013 Author Share Posted June 27, 2013 (edited) Rich, Hope you don't mind me commenting, but I'm seeing this pattern in your code: CLR R6 MOVB *R4,R6 GET VALUE SWPB R6 LSB C R2,R6 EQUAL? You can save two bytes each time by using this technique: MOVB *R4,R6 get value SRL R6,8 move to low-byte C R2,R6 equal? From a quick scan of the code, I reckon you can save 30 bytes, which is worth having. It's also faster, as you are executing fewer instructions. For what it's worth... Thanks that would help a little to compress the amount of code I have to type in by hand. But then Tursi pointed out the reason for using Assembly was the speed so guess I stumbled onto the correct method. Edited June 27, 2013 by RXB Quote Link to comment Share on other sites More sharing options...
RXB Posted June 27, 2013 Author Share Posted June 27, 2013 Well oddly no one suggested what I just figured out. I got rid of the SWPB and CLR in all the code and even used CB instead. Is CB slower then C alone? TITL 'SPEED UP ROUTINES' AORG >C000 UPLFT DATA WRKSPC BOTH USE WORKSPACE DATA UL DWNRT DATA WRKSPC BOTH USE WORKSPACE DATA DR DOWN AND RIGHT DR CLR R1 G CLR R6 BUFFER LI R2,>E100 VALUES 225 226 227 DRT MOV R0,R4 POSITION 5 AI R4,33 POSITION 9 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,32 POSITION 8 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,31 POSITION 7 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,1 POSITION 6 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,-1 POSITION 4 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,-31 POSITION 3 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,-32 POSITION 2 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,-33 POSITION 1 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES CI R2,>E300 LOOP 227? JEQ GOUT2 YES AI R2,>0100 ADD 1 JMP DRT LOOP GOUT CI R2,>E300 227? JNE GOUT3 G0UT2 LI R1,>8000 Replace with SPACE JMP RETURN Done GOUT3 AI R2,>0100 Replace with 225? or 226? MOV R2,R1 Load G with value RETURN RTWP Done go back to RXB UL CLR R1 G CLR R6 LI R2,>E100 VALUES 225 226 227 ULT MOV R0,R4 POSITION 5 AI R4,-33 POSITION 1 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,-32 POSITION 2 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,-31 POSITION 3 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,-1 POSITION 4 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,1 POSITION 6 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,31 POSITION 7 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,32 POSITION 8 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES MOV R0,R4 POSITION 5 AI R4,33 POSITION 9 MOVB *R4,R6 GET VALUE CB R2,R6 EQUAL? JEQ GOUT YES CI R2,>E300 LOOP 227? JEQ GOUT2 YES AI R2,>0100 ADD 1 JMP ULT LOOP WRKSPC DATA 0 R0 ADDRESS OF X PRELOADED DATA 0 R1 ADDRESS VALUE G PRELOADED DATA 0 R2 VALUE TO CHECK 225,226,227,128 DATA 0 R3 DATA 0 R4 ADDRESS OF X MODIFIED DATA 0 R5 DATA 0 R6 value found DATA 0 R7 DATA 0 R8 DATA 0 R9 DATA 0 R10 POSITIONS DATA 0 R11 1 2 3 DATA 0 R12 4 5 6 DATA 0 R13 7 8 9 DATA 0 R14 DATA 0 R15 END Quote Link to comment Share on other sites More sharing options...
Tursi Posted June 27, 2013 Share Posted June 27, 2013 Well oddly no one suggested what I just figured out.I got rid of the SWPB and CLR in all the code and even used CB instead. Is CB slower then C alone? hehe.... good point. Same speed, IIRC. It probably was not mentioned because your compare value, R2, has the data in the LSB, but yeah, as long as you can move it to the MSB, CB is a better way to go. Good catch! Quote Link to comment Share on other sites More sharing options...
matthew180 Posted June 27, 2013 Share Posted June 27, 2013 Well oddly no one suggested what I just figured out. I got rid of the SWPB and CLR in all the code and even used CB instead. Is CB slower then C alone? Uh, senior_falcon caught it and made the suggestion to use CB in post #10. Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted June 28, 2013 Share Posted June 28, 2013 LI R2,>E100 puts 225 in the MSB of R2 and now you can use CB directly on the registers. There's no need to MOVB *R4,R6 and then CB R2,R6 CB R2,*R4 will do the same thing Quote Link to comment Share on other sites More sharing options...
RXB Posted June 28, 2013 Author Share Posted June 28, 2013 (edited) Uh, senior_falcon caught it and made the suggestion to use CB in post #10. Yea but I was all caught up on the CLR R6 and SWPB R6 thing at the time, so I missed that one. Thanks. The whole point of this is to speed up the looking for where the enemy is going. I did not want to use CALL LINK as that resides in the Lower 8K and that is where all my map is saved. To swap out that and use assembly to check the map would require only 4K chunks and that gets really complicated fast. So it occurred to me that I was not using most of the upper 24K thus I could put the Assembly there and use my RXB CALL EXECUTE(ADDRESS) to do the dirty work. I just use a CALL LOAD to load the ADDRESS (2 bytes) then when it is finished I just use a CALL PEEK to get the single byte value. Nice thing is RXB keeps track of the SAMS memory for me so the Enemy can be at page 3 of SAMS and the player at page 10 but everything is automatic. Also as RXB reduced the size of the XB program so much the more space I have for Assembly routines. Currently I have 16K unused in upper 24K. Edited June 28, 2013 by RXB Quote Link to comment Share on other sites More sharing options...
RXB Posted June 28, 2013 Author Share Posted June 28, 2013 LI R2,>E100 puts 225 in the MSB of R2 and now you can use CB directly on the registers. There's no need to MOVB *R4,R6 and then CB R2,R6 CB R2,*R4 will do the same thing Cool thanks will look at that. Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted June 28, 2013 Share Posted June 28, 2013 If you are putting assembly routines into high memory there is a way to do it that will embed them in your XB program so both the subroutines and the XB program can be saved and loaded as one file. "The Missing Link" comes with a utility called HMLOADER. This lets you use the routines just as if they were loaded the "proper" way into low memory. Access them with CALL LINK in the usual way. Parameters can be passed from XB to AL or from AL to XB. Relocatable programs only - don't use AORG. Pages 26-27 of the TML manual describe how to use this. TML can be found in the development resources on this forum. Quote Link to comment Share on other sites More sharing options...
RXB Posted June 28, 2013 Author Share Posted June 28, 2013 If you are putting assembly routines into high memory there is a way to do it that will embed them in your XB program so both the subroutines and the XB program can be saved and loaded as one file. "The Missing Link" comes with a utility called HMLOADER. This lets you use the routines just as if they were loaded the "proper" way into low memory. Access them with CALL LINK in the usual way. Parameters can be passed from XB to AL or from AL to XB. Relocatable programs only - don't use AORG. Pages 26-27 of the TML manual describe how to use this. TML can be found in the development resources on this forum. Yea but those do not let you RES the program and my ASSEMBLY code is less than 224 bytes long now. So not like it takes a ton of memory or time to load it. Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted June 29, 2013 Share Posted June 29, 2013 Hi Rich: I figured out a reasonably simple way to resequence an XB program containing code embedded by HMLOADER. CALL PEEK(8192,A,B) (gets pointer to beginning of assembly routines. if you haven't RUN the program yet these values are in line 3 of the XB program) CALL LOAD(-31868,A,B) (tells XB where the end of XB program is) RES CALL LOAD(-31868,255,231) (restore pointer to normal value) Thanks for getting me to look at this again. 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.