tryphon wrote:
And I didn't know it was so awful
Believe me, it's insane :p
So, if I understood correctly, d0 is the return value ?
Oh yeah, i forgot about that one (i just edited my reply), D0 contains return value when needed.
For situation 1, it would be something like :
Code: Select all
.global schmurtz
schmurtz:
[b]move.l[/b] (a7), d1
moveq #42, d0
cmpi.l #10, d1
bge .exit
moveq #31, d0
.exit:
rts
And then I can use schmurtz(18); in my C code ?
Yeah, that is exactly that
Note that i exchanged you movem with move as movem is useful for multiple moves
Now you just need to declare the method in a .h file as:
And that is, your compiler will know the method exist somewhere so you can use it in your C code and don't worry about undefined method
Also, why are labels prefixed by a dot ? To make them local ?
Yeah, handy to not accidentally use an already existing label / variable / function name. As you can see all these are basically the same: just an address with a name
I saw this line in vdp_pal (but not in tools):
Code: Select all
.type VDP_getPaletteColors, @function
What does it mean ? Can I define something else with the @syntax ?
Definitely not needed, that is tips for the assembler but is completely useless (at least i don't know where it is used).
The type is defined on your own depending how you declare it in the .h file.
For instance you could declare schumurtz as
so C code will then see schumurtz as a u32 variable.
For situation 2, how do I call an already defined C function ? Simple jsr ? And for variables / constants defined elsewhere ?
Something like that :
Code: Select all
zorglub:
jsr schmurtz
addq #1, d0
rts
Yeah you just call them with their name :
jsr myFunction for function
move var, d0 for variable
You can see in the maths3d_a.s file, i directly access the 'context3D' variable declared in math3d.c freely.
The linker will resolve all the symbols and if they exists you should not have any troubles.
Hope that make things clearer for you !