I have this easy ASM function to multiply two 1:15:16 fixed numbers and return a 1:15:16 fixed too:
I use it very often in my program, but as it's in a external asm file it's impossible to make it inline (at least I've tried everything in my hands). BTW, thanks microsoft for not including __asm in your compiler.
microsoft states clearly that if you want a function inlined, define it in a .h so that every file including it can see the function. That would be great, if __asm were supported :)
after being frustrated a lot with this issue (as most of you, probably) I thought about hacking a little bit their compiler so that I could create a custom intrinsic function, but that requires a lot of time, work and knowledge I don't have.
Unfortunately I think there's only one way to go, and it's trying to do a C function which has the same code as my ASM code, but I haven't been able to do so. I've tried the "logical"
but it's generating a mul instead of an smull. casting the result or the operands is not working.
any ideas? :)
TIA
Kak
p.s. of course I suppose there's no way to fool the compiler and generate raw opcodes, something like dcd in the middle of the code,isn't it? :)
- Code:
mult1_15_16x1_15_16_return_1_15_16
smull r2,r3,r0,r1
mov r0,r2,lsr #16
add r0,r0,r3,lsl #16
mov pc,lr
I use it very often in my program, but as it's in a external asm file it's impossible to make it inline (at least I've tried everything in my hands). BTW, thanks microsoft for not including __asm in your compiler.
microsoft states clearly that if you want a function inlined, define it in a .h so that every file including it can see the function. That would be great, if __asm were supported :)
after being frustrated a lot with this issue (as most of you, probably) I thought about hacking a little bit their compiler so that I could create a custom intrinsic function, but that requires a lot of time, work and knowledge I don't have.
Unfortunately I think there's only one way to go, and it's trying to do a C function which has the same code as my ASM code, but I haven't been able to do so. I've tried the "logical"
- Code:
_int64 c;
c=a*b;
c=c>>16;
return (int)c;
but it's generating a mul instead of an smull. casting the result or the operands is not working.
any ideas? :)
TIA
Kak
p.s. of course I suppose there's no way to fool the compiler and generate raw opcodes, something like dcd in the middle of the code,isn't it? :)