Jump to content
IGNORED

mixing assembly with basic


mos6507

Recommended Posts

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?

Link to comment
Share on other sites

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 by batari
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...