26286 total geeks with 3498 solutions
Recent challengers:
 Welcome, you are an anonymous user! [register] [login] Get a yourname@osix.net email address 

Articles

GEEK

User's box
Username:
Password:

Forgot password?
New account

Shoutbox
MaxMouse
It's Friday... That's good enough for me!
CodeX
non stop lolz here but thats soon to end thanks to uni, surely the rest of the world is going good?
stabat
how things are going guys? Here... boring...
CodeX
I must be going wrong on the password lengths then, as long as it was done on ECB
MaxMouse
lol... the key is in hex (MD5: of the string "doit" without the "'s) and is in lower case. Maybe i should have submitted this as a challenge!

Donate
Donate and help us fund new challenges
Donate!
Due Date: May 31
May Goal: $40.00
Gross: $0.00
Net Balance: $0.00
Left to go: $40.00
Contributors


News Feeds
The Register
More than half of
Windows 8 users
just treat it like
Windows 7
Press exposure of
Federal data
security hole leads
to legal threats
Big Brother
security tech gets
$20m
Speaking in Tech:
Portland hipsters
gagging for
yesterday"s web
tool
Citrix halfway to
Avalon with
XenDesktop 7
desktop and app
virtualizer
Sony"s board
debates breaking up
with
Spider-Man
Skyscape bags
biggest deal on
G-Cloud EVER
Watch out, chaps,
it"s another
storage sync "n"
share produ-ARRRGH
Eric Schmidt:
"Google IS a
capitalist
country... er,
company"
Juniper, Seagate
stuff cash down
Cloudscaling"s
OpenStack trousers
Slashdot
Scientists Find
Vitamin C Kills
Drug-Resistant
Tuberculosis
German IT Firm
Seeks Autistic
Workers
Violent Galactic
Clash May Solve
Cosmic Mystery
The Canadian
Government"s War On
Science
MariaDB vs. MySQL:
A Performance
Comparison
Will Robots Take
Over the Data
Center?
Eric Schmidt:
Google Will
Continue Investing
In UK Even If Taxes
Raised
OSI President
Questions WebM
Patent License
Compatibility with
Open Source
Ask Slashdot: What
Makes a Great
Hackathon?
Thousands of
Whistle Blowers
Vulnerable After
Anonymous Hacks
SAPS
Article viewer

Disassembly of a Highly Optimised Fractal Generator



Written by:Geek_Freek
Published by:SAJChurchey
Published on:2005-11-26 05:33:00
Topic:Assembly
Search OSI about Assembly.More articles by Geek_Freek.
 viewed 12140 times send this article printer friendly

Digg this!
    Rate this article :
A short explaination of fractals, a simple algorithm and Disassembly of this amazing 31 byte fractal generator.

Well i got sier.com file when i was looking for fractal generators.

Let me start of with Fractals

FRACTALS

Wikipedia defines it as :

A fractal is a geometric object which is rough or irregular on all scales of length, and so which appears to be 'broken up' in a radical way.

The Sierpinski Triangle(and how its related to Pascal's Triangle)

Well, if you were to plot the Pascals triangle, substitute every odd number with a black dot and every even number with a white dot... you'll end up with the Sierpinski triangle.


Algorithm to generate Sierpinski's Triangle
  • 1 : Choose any three arbitary points A,B,C
  • 2 : Select any random point D lying in the triangle ABC.
  • 3 : Select any E = random_point(A or B or C).
  • 4 : D = midpoint b/w D and E
  • 5 : Mark D with dark point.
  • 6 : Goto 3


I suggest you see this if you haven't already. Lets get down to disassembling it.

Disassembly of Sier.com
1:  ; This file is generated by The Interactive Disassembler (IDA)
2:  ; Freeware version
3:  ; Copyright (c) 2000 by DataRescue sa/nv, http://www.datarescue.com
4:  ; File Name : D:ASMSIER.COM
5:  ; Format : MS-DOS COM-file
6:  ; Base Address: 1000h Range: 10100h-1011Fh Loaded length: 1Fh
7:  
8:  ; Segment type: Pure code
9:  seg000 segment byte public 'CODE'
10:          assume cs:seg000
11:          org 100h
12:          assume es:nothing, ss:nothing, ds:seg000
13:  
14:  ;-Subroutine-------------------------
15:  
16:          public start
17:  start proc near
18:          mov ax, 13h
19:          int 10h ; - VIDEO - SET VIDEO MODE
20:                      ; AL = mode
21:          mov bx, 3
22:          mov si, 0A0A0h
23:          mov ds, si
24:          assume ds:nothing
25:  
26:  loc_0_10D: ; CODE XREF: start+17j
27:          mov cx, 0C8Bh ; loc_0_10D + 1 = mox cx,[si]
28:          xor ch, [bx+si]
29:          mov [si-13Eh], ch
30:          dec si
31:          jnz near ptr loc_0_10D+1
32:          int 16h ; KEYBOARD - READ CHAR FROM BUFFER, WAIT IF EMPTY
33:                      ; Return: AH = scan code, AL = character
34:          xchg ax, bx
35:          int 10h ; - VIDEO - SET VIDEO MODE
36:                      ; AL = mode
37:          retn
38:  start endp
39:  
40:  seg000 ends
41:  
42:  
43:          end start
44:  



Heres what I figured
  • We move A0A0 to SI.. which is the video buffer
  • Only during initialization (line 27) works as mov cx,0C8Bh. Then onwards it is used as mov cx,
  • [SI]
  • The next point to mark is figured out using line 28 and 29. I dont understand how the XORing works. Leave a comment if you do.
  • Line 29 seems to be marking the point.


Conclusion
I have no idea who the author of the program is. It is nonetheless a work of art. If you find a way to compress it further, you have my respect. Also I have not understood exactly how the point to be marked is found, and it isn't according to the algorithm I listed earlier (or is it?). The XOR seems to be a shortcut to generate this point. BX remains fixed at 3. SI is decremented every loop.

Leave a comment if you figure anything of this mystery.

Geek
(c)Anil Gulecha

Did you like this article? There are hundreds more.

Comments:
telekinetic
2005-11-29 12:08:17
I once wrote a program to draw a Sierpinski's triangle, but it was a recursive implementation. This is pretty impressive though.
Anonymous
2005-11-30 07:30:17
ANYONE figured the lines 28,29??
santa
2005-12-03 12:50:59
hum..... far too geeky for me.
yonatan
2005-12-31 07:03:35
xor stuff works like this I think

putpixel( somex, somey ); // low point in triangle - mov cx, 0C8Bh

for( y = maxy; y; y-- ) {
for( x = maxx; x; x-- ) {
if( getpixel( x+1, y ) XOR getpixel( x-1, y ) ) {
putpixel( x, y-1 );
}
}
}


yonatan
2005-12-31 07:05:04
damn.. I meant like this..


putpixel( somex, somey ); // low point in triangle - mov cx, 0C8Bh

for( y = maxy; y; y-- ) {
   for( x = maxx; x; x-- ) {
      if( getpixel( x+1, y ) XOR getpixel( x-1, y ) ) {
         putpixel( x, y-1 );
      }
   }
}
Anonymous
2006-01-19 00:25:07
The XOR is to generate the triangle line by line (it doesn't use the midway method). On the first line you put a black pixel. The second line is the first line put through an XOR with the 2 neighbouring pixels being the inputs. See cellular automata for more information
anilg
2006-01-19 09:09:42
Hmm.. thanks.. i'll look into it and add to the article accordingly.

Thanks again
anilg
2006-01-19 09:21:37
And while i understand the stuff and integrate it:

http://www.dms.umontreal.ca/~andrew/Binomial/cellautom.html
Anonymously add a comment: (or register here)
(registration is really fast and we send you no spam)
BB Code is enabled.
Captcha Number:


Blogs: (People who have posted blogs on this subject..)
jackier
jackier on Mon 13th Oct 10am
111
sefo
Sneak - encryption on Fri 17th Nov 12pm
I'm developing the win32 version of sneak: http://snarkles.net/scripts/sneak/sneak. php The ASM source code is available on cyberarmy svn (for members only - free) Check the forum for details: http://www.cyberarmy.net/forum/sneak/mes sages/295244.
sefo
Geek Toolbar on Mon 13th Nov 8am
This a very simple and small toolbar I wrote in my spare time. I use the same set of tools very often and I find it very annoying to look for them in the start menu, on the desktop or in explorer. http://www.osix.net/modules/folder/index .php?tid=134
sefo
BinScan and Alternate Data Stream on Thu 27th Jul 9am
BinScan I created this tool to quickly identify modifications in the PE, use of a TLS callback and Alternate Data Streams. -> Some modifications done in the PE structure of an executable can prevent debuggers or other tools to open the executable.
sefo
Wmf Creator on Wed 26th Jul 7am
Now that the blog is online, I'll be able to share two or three tools I wrote. The first one I'd like to share is WMF Creator. I already put a link in the comments of my article: Wmf Exploit but I thought it would look nicer here. This tool will tak

Test Yourself: (why not try testing your skill on this subject? Clicking the link will start the test.)
Reverse Engineering by Geek_Freek

A test to check your assembly and reversing skills.
Assembly Language - non compiler specific by TroPe

You can test your assembly knowledge by taking this test. It starts out relatively easy, but gets progressively hards very quickly! If you know assembly, or just want to see what you DONT know about assembly, this test is for you. A more advanced assembly


     
Your Ad Here
 
Copyright Open Source Institute, 2006