This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 10 Jan 2009 02:24:04 pm    Post subject:

What's the most obfuscated code you can come with in z80 that performs a simple task (draw 8*8 sprite, do some simple arithmetic, etc.)?

Edit:
One rule, it must be able to run NoStub.


Last edited by Guest on 10 Jan 2009 02:24:55 pm; edited 1 time in total
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 10 Jan 2009 03:30:08 pm    Post subject:

A = B + C

Code:
ld a,b
and c
add a,a
ld d,a
ld a,b
xor c
add a,d


Should work. Razz


Last edited by Guest on 10 Jan 2009 03:47:29 pm; edited 1 time in total
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 10 Jan 2009 03:38:27 pm    Post subject:

A=B+C

LD A,B
AND C
or A\ RL A
LD B,A
XOR C
ADD A,B

yes, this does actualy work Dry
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 10 Jan 2009 03:42:12 pm    Post subject:

darkstone knight wrote:
A=B+C

LD A,B
AND C
or A\ RL A
LD B,A
XOR C
ADD A,B

yes, this does actualy work Dry

No it doesn't. Razz Try with B=1 and C=0.
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 10 Jan 2009 03:45:39 pm    Post subject:

LD A,B
AND C
or A\ RL A
LD H,A
LD A,B
XOR C
ADD A,H

minor correction >.>

(btw, this is how adding 2 numbers whit logic switches work.. kinda)
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 11 Jan 2009 04:26:56 pm    Post subject:

A = -C


Code:
 or $FF
 xor c
 inc a
Back to top
elfprince13
Retired


Super Elite (Last Title)


Joined: 11 Apr 2005
Posts: 3500

Posted: 12 Jan 2009 11:44:44 am    Post subject:

*I* think it would be more fun to try and obfuscate TI-Basic and make people guess what its for.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 12 Jan 2009 12:37:14 pm    Post subject:

At the very least, I think there should be a defined goal for the obfuscated code. A=B+C is a good start. Maybe later someone could write obfuscated code for something cooler like drawing a line.

My entry for an obfuscated A=B+C:

di
(this may well be unnecessary)
ld a, c
srl a
srl b
ld r, a
djnz $
ld a, r
rla
srl c
adc a, -4


Last edited by Guest on 11 Jul 2010 06:46:27 pm; edited 1 time in total
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 12 Jan 2009 01:17:42 pm    Post subject:

does that actualy work?
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 12 Jan 2009 01:32:40 pm    Post subject:

Wouldn't you like to know?

It worked for me when I tried it on an emulator.
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 12 Jan 2009 04:41:20 pm    Post subject:

ah, i made a mistake on the djnz...

nevermind..
Back to top
Galandros


Active Member


Joined: 29 Aug 2008
Posts: 565

Posted: 12 Jan 2009 05:09:28 pm    Post subject:

Load from memory:

Code:
ld hl,data
xor a
add a,(hl)


random generator Neutral

Code:
ld bc,FFh
ld hl,pointsometioscode;(somewhere in TI-OS or data)
ld de,pointsometioscode
tryagain:
ld a,r
cpir
ld a,b
or c
jr z,tryagain
sbc hl,de
ld a,l



This serve?
DarkerLine was the best (or worst, depends) in my opinion...
EDIT: corrected nick


Last edited by Guest on 12 Jan 2009 05:11:10 pm; edited 1 time in total
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 13 Jan 2009 04:36:04 am    Post subject:

you should use random numbers based on the checksum of the graph buffer Very Happy
Back to top
Galandros


Active Member


Joined: 29 Aug 2008
Posts: 565

Posted: 13 Jan 2009 12:34:28 pm    Post subject:

darkstone knight wrote:
you should use random numbers based on the checksum of the graph buffer Very Happy
I love it. And also shadowtext! :biggrin:

And I had a great idea to confuse even more things. I will do it some day. Razz


Last edited by Guest on 13 Jan 2009 12:36:39 pm; edited 1 time in total
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 13 Jan 2009 03:44:35 pm    Post subject:

by the way, what is the fastest checksum code?
Back to top
FloppusMaximus


Advanced Member


Joined: 22 Aug 2008
Posts: 472

Posted: 13 Jan 2009 04:33:44 pm    Post subject:

That would have to depend on what you're doing.

For a simple 8-bit checksum I don't see any way to improve on

Code:
   xor a
loop:
   add a,(hl)
   inc hl
   djnz loop

(unless of course you know that L + B < 257, in which case use "inc l" instead of "inc hl".)

If you want to add up more than 256 bytes, it will be faster if you use a double loop rather than a 16-bit counter:

Code:
   dec bc
   inc b
   inc c
   ld a,b
   ld b,c
   ld c,a
   xor a
loop:
   add a,(hl)
   inc hl
   djnz loop
   dec c
   jp nz,loop


If you want a 16-bit result, use the carry flag (I haven't fully convinced myself that this is the fastest possible, but it's the best I can think of):

Code:
   xor a
   ld d,a
loop:
   add a,(hl)
   jr nc,noincr
   inc d
noincr:
   inc hl
   djnz loop
Back to top
cjgone
Aw3s0m3


Active Member


Joined: 24 May 2006
Posts: 693

Posted: 14 Jan 2009 01:34:13 am    Post subject:

Oh man, i'm so freakin' brutal at obfuscation.

Look at this


Code:
add a,b ; very verbose addition


Oh yeaa...
Back to top
bananaman
Indestructible


Calc Guru


Joined: 12 Sep 2005
Posts: 1124

Posted: 14 Jan 2009 07:15:54 am    Post subject:

Aaaahhhhh, but we were trying to do A=B+C

Code:
ld a,b
add a,c ; a=b+c
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 14 Jan 2009 06:11:03 pm    Post subject:

which would make cjgone's very obfuscated indeed.
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 15 Jan 2009 03:09:15 am    Post subject:

isnt the checksum the amount of set bits in a number?

10010000 becomes 2..
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    » Goto page 1, 2  Next
» View previous topic :: View next topic  
Page 1 of 2 » All times are UTC - 5 Hours

 

Advertisement