BartmanAbyss / vscode-amiga-debug

One-stop Visual Studio Code Extension to compile, debug and profile Amiga C/C++ programs compiled by the bundled gcc 12.2 with the bundled WinUAE/FS-UAE.
GNU General Public License v3.0
314 stars 39 forks source link

Separate assembly file documentation #61

Closed rjobling closed 3 years ago

rjobling commented 3 years ago

@BartmanAbyss I've been using the inline assembly feature with only a few issues but wanted to use a separate .s file for a larger routine.

Do you have advice on where to find documentation about the assembler that covers how to correctly interface with C/C++ and also what all the assembler syntax is. Things like: .type Label,function and things like that.

As it is I got something working but I'm not sure if it's wastefully saving/restoring registers when called. I'm also sure I'll run into issues sharing global variables. Ideally it'd be nice to share some of the C/C++ constant literals. Just not sure what is possible.

The support .s file uses a weird syntax. I was wondering why it does that?

Thanks!

BartmanAbyss commented 3 years ago

GNU Assembler Manual So, for interfacing assembler functions to C, the calling convention is to push all argument onto the stack. If your assembler routine can handle that, you can call it directly from C. If you however have existing assembler routines that expect arguments in specific registers, you need to create a C wrapper (see p61Init, p61Music, p61End in the example project. Of course you can share all kinds of symbols between C and Assembler. Yeah the support.s file uses a weird syntax, it has always been like this from GCC, so you better check out depacker_doynax.s for a better reference. Also, if you plan on using callstacks for debugging or profiling, and you're modifying the stack pointer (a7), you should use .cfi* directives to tell the compiler about that (see support.s)

rjobling commented 3 years ago

Okay, thanks!