mos6507 Posted August 26, 2005 Share Posted August 26, 2005 I was reading the docs in relation to user-defined functions and I was wondering how you would handle user-defined procedures that are coded in assembly. Normally a procedure is handled with GOTO or GOSUB. If you had an assembly routine could you simply GOSUB to the label assigned to it within the asm? I would also assume that labels, equates, constants have to be unique across all the cumulative asm and basic code otherwise the compilation will fail? Also, might there be a way to pass-through calls to DASM macros? Quote Link to comment Share on other sites More sharing options...
+batari Posted August 26, 2005 Share Posted August 26, 2005 (edited) I was reading the docs in relation to user-defined functions and I was wondering how you would handle user-defined procedures that are coded in assembly. Normally a procedure is handled with GOTO or GOSUB. If you had an assembly routine could you simply GOSUB to the label assigned to it within the asm? close - to allow labels and linenumbers, bB sticks a dot (.) before everything because if it compiled goto 40 as JMP 40, it wouldn't jump to the label called 40 but instead would jump to zero-page address 40 and probably crash. Come to think of it, maybe a dot wasn't the best choice because it's actually a "local label" in DASM - Maybe I'll change this to an underscore in the next version. But anyway, if you want to "goto" an asm procedure, you just add a dot before the label in asm, but maybe you'll need to change to an underscore later. I would also assume that labels, equates, constants have to be unique across all the cumulative asm and basic code otherwise the compilation will fail? Yes, but with the dot in front of all bB labels, it's unlikely to have asm conflict with bB labels, but asm labels in one module can certainly conflict with another. Therefore, using generic labels line "loop3" probably isn't a good idea for inline asm/asm modules. Also, might there be a way to pass-through calls to DASM macros? 919014[/snapback] Like what? Edited August 26, 2005 by batari Quote Link to comment Share on other sites More sharing options...
mos6507 Posted August 26, 2005 Author Share Posted August 26, 2005 Like what? 919029[/snapback] Like the macros inside macro.h such as SLEEP. Quote Link to comment Share on other sites More sharing options...
+batari Posted August 26, 2005 Share Posted August 26, 2005 (edited) Like what? 919029[/snapback] Like the macros inside macro.h such as SLEEP. 919296[/snapback] You can do this in inline asm - does this answer your question? asm sleep 10 end Edited August 26, 2005 by batari Quote Link to comment Share on other sites More sharing options...
vdub_bobby Posted August 26, 2005 Share Posted August 26, 2005 Like what? 919029[/snapback] Like the macros inside macro.h such as SLEEP. 919296[/snapback] You can do this in inline asm - does this answer your question? I am somewhat curious to know what use you would have for the SLEEP macro in bBASIC. ?? Quote Link to comment Share on other sites More sharing options...
mos6507 Posted August 28, 2005 Author Share Posted August 28, 2005 Like what? 919029[/snapback] Like the macros inside macro.h such as SLEEP. 919296[/snapback] You can do this in inline asm - does this answer your question? I am somewhat curious to know what use you would have for the SLEEP macro in bBASIC. ?? 919379[/snapback] You can do anything in inline asm. It's just that it defeats the purpose of using batari Basic to rely on it. Macros are a little strange in assembly because normally you'd want to make something a subroutine and just call that instead of inserting code inline everytime you did something. Assembly subroutines can be integrated in batari Basic already. Nevertheless, there are some cases where macros make sense. For instance, I was working on some macros for the Supercharger. Instead of doing CMP $F000+$DD to set the value you are going to write to RAM, you could do SC_RAMVAL $DD or something similar, since it reads better. so it would be the difference between doing this: asm SC_RAMVAL $DD end and this: SC_RAMVAL $DD Not having to bracket the macros with asm/end makes the code read a little better. Since DASM is going to process the files anyway, then I'm sure something like that would be easy to do. As long as the parser is told to pass through any lines it doesn't understand directly to DASM then as long as the macro is defined then it would work. 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.