Author Topic: which is faster?  (Read 5753 times)

0 Members and 1 Guest are viewing this topic.

Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
which is faster?
« 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)?

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: which is faster?
« Reply #1 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
« Last Edit: June 27, 2011, 04:59:12 pm by willrandship »

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: which is faster?
« Reply #2 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.
« Last Edit: June 27, 2011, 04:59:49 pm by ben_g »
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
Re: which is faster?
« Reply #3 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 :)

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: which is faster?
« Reply #4 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

Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
Re: which is faster?
« Reply #5 on: June 27, 2011, 05:05:42 pm »
Oh i see.

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

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: which is faster?
« Reply #6 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.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: which is faster?
« Reply #7 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.




Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
Re: which is faster?
« Reply #8 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.
« Last Edit: June 27, 2011, 05:16:19 pm by TiAddict »

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: which is faster?
« Reply #9 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.




Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
Re: which is faster?
« Reply #10 on: June 27, 2011, 05:17:58 pm »
so creating Real Variable is faster than storing?

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: which is faster?
« Reply #11 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.




Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: which is faster?
« Reply #12 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.

Offline TiAddict

  • LV3 Member (Next: 100)
  • ***
  • Posts: 68
  • Rating: +0/-0
    • View Profile
Re: which is faster?
« Reply #13 on: June 27, 2011, 05:21:37 pm »
oh cool i get it. :D thanks!

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: which is faster?
« Reply #14 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.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112