Author Topic: Assembly Noob Question  (Read 2376 times)

0 Members and 1 Guest are viewing this topic.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Assembly Noob Question
« on: July 29, 2010, 09:15:13 am »
Ok, so I started to read Hot_Dog's tutorials and just have a noobish optimization question. It doesn't matter either way really but I just wanna know if I am technically correct or not.

One of the sample programs shows this, or something close:

Code: [Select]
#include "ti83plus.inc"
.org 40339
.db t2ByteTok,tAsmCmp

 B_CALL _ClrLCDFull

 ld b,200
 ld a,5

Beginning_Of_Loop:

 add a,1

 djnz Beginning_Of_Loop

 ld h,0
 ld l,a

 B_CALL _DispHL
 B_CALL _getKey
 B_CALL _ClrLCDFull

 ret

Wouldn't it technically be better to do:

Code: [Select]
#include "ti83plus.inc"
.org 40339
.db t2ByteTok,tAsmCmp

 B_CALL _ClrLCDFull

 ld b,200
 ld a,5

Beginning_Of_Loop:

 inc a

 djnz Beginning_Of_Loop

 ld h,0
 ld l,a

 B_CALL _DispHL
 B_CALL _getKey
 B_CALL _ClrLCDFull

 ret

I have no idea if that even does the same thing, I didn't test it. I'm just doing this off what I see.

Sorry if this sounds dumb, but I'm just a little curious. Thanks for any help :)
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

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: Assembly Noob Question
« Reply #1 on: July 29, 2010, 10:22:38 am »
Yay, your first optimization! Those are equivalent in everything but t-states and bytes. Yours is 3 t-states faster and 1 byte shorter.

Of course the best optimization would be   ld    hl, 205.  :P
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

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Assembly Noob Question
« Reply #2 on: July 29, 2010, 07:22:23 pm »
Woo! I thought so ;D Thanks for confirming :)
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)