Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: TiAddict on June 27, 2011, 04:57:01 pm

Title: which is faster?
Post by: TiAddict on June 27, 2011, 04:57:01 pm
in this situation, is assembly faster? or same speed?

TI-BASIC
2->kTheta
or
Assembly
B_CALL OP1Set2
B_CALL StoTheta
RET
 if ASM's faster, that means TI BASIC games/program will be faster if i use some ASM prgm to store and add/sub/multiply/divide the floating point variables?(A~Z and kTheta)?
Title: Re: which is faster?
Post by: willrandship on June 27, 2011, 04:58:39 pm
Asm will usually be faster, but keep in mind that bcalls tend to suck compared to handwritten routines.

Also, remember that it takes asm time to load as well. if you have tons of tiny programs, you will end up possibly slower, and take up more space.
Can't give you an exact answer on your particular one, just a little advice :P
Title: Re: which is faster?
Post by: ben_g on June 27, 2011, 04:59:04 pm
Asm should be a bit faster, as basic is interpreted. But basic should be a lot smaller in a large program.
Title: Re: which is faster?
Post by: TiAddict on June 27, 2011, 05:01:52 pm
willrandship,That makes sense :D but if i use 1 ASM prgm to do many storing and addition, i should use it right? and handwritten routines? How fast are they?
Ben_g, alright thanks :)
Title: Re: which is faster?
Post by: willrandship on June 27, 2011, 05:03:51 pm
well, maybe. A handwritten routine that is well optimized (and there are people here very good at that :P ) would definitely be faster. And it would probably be worth it, especially for larger calculations.

You won't ever be going over 32768, right? I think that's the 84's bit limit for integers without some complications
Title: Re: which is faster?
Post by: TiAddict on June 27, 2011, 05:05:42 pm
Oh i see.

and no, so i should use HL to do the math?
Title: Re: which is faster?
Post by: willrandship on June 27, 2011, 05:08:46 pm
that should be fine, I think. very optimized as compared to bcalls, but you might have some trouble getting it back without using the stotheta bcall.
Title: Re: which is faster?
Post by: Deep Toaster on June 27, 2011, 05:13:52 pm
Oh i see.

and no, so i should use HL to do the math?

Yep, that'll probably make it a couple thousand times faster. Literally.
Title: Re: which is faster?
Post by: TiAddict on June 27, 2011, 05:15:14 pm
lol, so after i do all the math, store HL to the OP1, and then use StoTheta?
Oh i see.

and no, so i should use HL to do the math?
Yep, that'll probably make it a couple thousand times faster. Literally.
Title: Re: which is faster?
Post by: Deep Toaster on June 27, 2011, 05:16:58 pm
lol, so after i do all the math, store HL to the OP1, and then use StoTheta?

That would work, or if you want to make it even faster and don't care about using up a couple more bytes, do it yourself with _CreateReal.
Title: Re: which is faster?
Post by: TiAddict on June 27, 2011, 05:17:58 pm
so creating Real Variable is faster than storing?
Title: Re: which is faster?
Post by: Deep Toaster on June 27, 2011, 05:19:30 pm
Well, that's what StoTheta does. It finds the theta var if it exists, deletes it if it's there, creates a new one, and loads OP1 into it. The reason there's a bcall for that is to save you code, but bcalls are always going to be a bit slower than hard-coding everything.
Title: Re: which is faster?
Post by: willrandship on June 27, 2011, 05:21:27 pm
so just make sure you delete it if necessary, by hand. That way the program doesn't have to check.
Title: Re: which is faster?
Post by: TiAddict on June 27, 2011, 05:21:37 pm
oh cool i get it. :D thanks!
Title: Re: which is faster?
Post by: thepenguin77 on June 27, 2011, 05:39:40 pm
I think I should just point out that bcalls aren't as slow as what people think. Yes, if you are using bcall(_multAbyE) inside a djnz loop, then you are wasting some time. But the time wasted is relative.

The whole bcall process takes about 1000 t-states. In 6.5MHz mode, that's .00015 sec. If you do 100 bcalls, that's only .01 sec.

In this case, since you are making a basic library, there's no reason why you shouldn't use bcalls. The bcalls aren't slow compared to basic. However, floating point numbers vs. HL makes a big difference. If you don't need decimals, then HL is definitely the way to go.
Title: Re: which is faster?
Post by: TiAddict on June 27, 2011, 09:11:53 pm
ah thanks! and wow i never new how fast bcall process were!  :o
Title: Re: which is faster?
Post by: AngelFish on June 27, 2011, 11:09:59 pm
That's actually pretty slow compared to raw ASM. Keep in mind that even the slow 6MHz chip in the TI's are screaming along at 6 million cycles a second.