Author Topic: The worst TI code I've ever seen  (Read 9325 times)

0 Members and 2 Guests are viewing this topic.

Offline ralphdspam

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 841
  • Rating: +38/-1
  • My name is actually Matt.
    • View Profile
Re: The worst TI code I've ever seen
« Reply #15 on: September 18, 2011, 04:59:04 pm »
Code: [Select]
ld b, 9 ;Really?  You have to load 9 into B to subtract it?  
sub b
jr c, loc_4E6B
pop af
ld b, 8  ;Ok, so you already have 9 in b.  The logical thing to do now would be dec b.
sub b ;Oh, but no, you do the same bloody thing again!!!
;I forgot to mention that this code is missing a ld a,a.  :P


As for the add and adc, there seem to be quite a few programmers (not here, of course) who misused the add instruction.  For example, the code for the Pac Man machine (yes, it was a z80 too) has a lot of "ccf \ add b".  They still have no excuse.
« Last Edit: September 18, 2011, 05:19:53 pm by ralphdspam »
ld a, 0
ld a, a

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: The worst TI code I've ever seen
« Reply #16 on: September 18, 2011, 05:09:09 pm »
As for the add and adc, there seem to be quite a few programmers (not here, of course) who misused the add instruction.  For example, the code for the Pac Man machine (yes, it was a z80 too.) has a lot of "ccf \ add b".  They still have no excuse.

Actually, you'll notice that instead of doing the stupid subtraction with B, they should have just done CP 9 since they restore A :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 ralphdspam

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 841
  • Rating: +38/-1
  • My name is actually Matt.
    • View Profile
Re: The worst TI code I've ever seen
« Reply #17 on: September 18, 2011, 05:13:39 pm »
Actually, you'll notice that instead of doing the stupid subtraction with B, they should have just done CP 9 since they restore A :P
Oh, lol.  I didn't notice the push af in the beginning.  
Wow...
...and they use "cp 0" earlier even though they use "or a" before.
It's like they have a memory span of a goldfish or something.  This is absolutely inexcusable and yet somewhat hilarious.  
« Last Edit: September 18, 2011, 05:14:18 pm by ralphdspam »
ld a, 0
ld a, a

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: The worst TI code I've ever seen
« Reply #18 on: September 18, 2011, 06:22:22 pm »
I know nothing about ASM, and yet I still feel that faint sense of revulsion.
Spoiler For Unnecessary Simile:
It's like when I read the CodeSODs on TDWTF. I don't know the languages themselves, but I know enough to still feel horrified (sometimes)
It is almost scary how good some of the programmers are, here. I think that if they all designed an OS, it would be ridiculously amazing and more stable (though the TI-OS is pretty stable).
Agreed.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline NanoWar

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 140
  • Rating: +18/-6
    • View Profile
Re: The worst TI code I've ever seen
« Reply #19 on: September 19, 2011, 01:44:17 pm »
Writing or a instead of cp 0 doesnt make a good program. I use cp 0 for better readability. Compilers should take care of that, actually.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: The worst TI code I've ever seen
« Reply #20 on: September 19, 2011, 01:47:41 pm »
For most z80 programmers, or a is very readable, as is xor a. Assemblers shouldn't automatically optimize because sometimes you need to use "unoptimized" code on purpose (such as ld a,0 to preserve flags or to provide a byte for SMC)
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline tangrs

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 229
  • Rating: +98/-0
    • View Profile
    • tangrs blog
Re: The worst TI code I've ever seen
« Reply #21 on: September 30, 2011, 05:14:07 am »
Maybe it's deliberately obfuscated code?

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: The worst TI code I've ever seen
« Reply #22 on: September 30, 2011, 10:12:10 am »
The problem is that it's not obfuscated :P
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: The worst TI code I've ever seen
« Reply #23 on: September 30, 2011, 10:12:59 am »
Maybe it's deliberately obfuscated code?
Perhaps, but...
Actually, it seems just like TI to try and "protect" their code with something this stupid and heinous, but they don't seem smart enough to deliberately write bad code. I think they just produce things that make you give up all hope unintentionally. Or....
« Last Edit: September 30, 2011, 10:13:15 am by Freyaday »
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: The worst TI code I've ever seen
« Reply #24 on: September 30, 2011, 11:50:55 am »
Maybe it's deliberately obfuscated code?
Perhaps, but...
Actually, it seems just like TI to try and "protect" their code with something this stupid and heinous, but they don't seem smart enough to deliberately write bad code. I think they just produce things that make you give up all hope unintentionally. Or....
or make something called TI-NOspine that costs $230 that 'protects' it from all hardware hacks and development :P
Sig wipe!

Offline ralphdspam

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 841
  • Rating: +38/-1
  • My name is actually Matt.
    • View Profile
Re: The worst TI code I've ever seen
« Reply #25 on: October 03, 2011, 03:04:14 am »
Maybe it's deliberately obfuscated code?
They're shooting themselves in their feet, then.  :P
It's getting the code more attention than intended.
ld a, 0
ld a, a

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: The worst TI code I've ever seen
« Reply #26 on: October 03, 2011, 03:27:33 am »
Well, if you're writing on the asm level optimizations require a certain amount of interpretation, which an assembler is likely to miss, but a programmer should understand fairly easily. After all, they wrote the initial code.

*Auto-Optimizing C is simpler, since the commands arbitrate the registers and other hardware concerns into the stack.
« Last Edit: October 03, 2011, 03:27:57 am by willrandship »