Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: meishe91 on July 29, 2010, 09:15:13 am

Title: Assembly Noob Question
Post by: meishe91 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 :)
Title: Re: Assembly Noob Question
Post by: thepenguin77 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
Title: Re: Assembly Noob Question
Post by: meishe91 on July 29, 2010, 07:22:23 pm
Woo! I thought so ;D Thanks for confirming :)