one of those cool programs that you just have to share...

Coders forum. Discuss techniques, swap code snippets, ask for help etc. relating to all forms of software development.
User avatar
oktup
Baaaaa!
Baaaaa!
Posts: 1027
Joined: Tue Jan 21, 2003 1:44 am 0
Location: Cumbria
Contact:

Post by oktup »

20thCenturyBoy wrote:Here's the assembler for hell.com, all 256 bytes of it. As you can see you can get into Mode 13h in two lines!

Code: Select all

1516:0100 B013          MOV     AL,13
1516:0102 CD10          INT     10
1516:0104 BF28D3        MOV     DI,D328
1516:0107 BAC803        MOV     DX,03C8
1516:010A 66            DB      66
1516:010B 33C0          XOR     AX,AX

... etcetera ...

Are you sure that disassembly is correct? Wouldn't ...

Code: Select all

00000000 b013                           mov         al, 0x13
00000002 cd10                           int         0x10
00000004 bf28d3                         mov         di, d328
00000007 bac803                         mov         dx, 03c8
0000000a 6633c0                         xor         eax, eax
0000000d ee                             out         dx, al
0000000e 42                             inc         dx
0000000f b4a0                           mov         ah, 0xa0
00000011 b90004                         mov         cx, 0400
00000014 50                             push        ax
00000015 66c1c808                       ror         eax, 0x8
00000019 3c3f                           cmp         al, 0x3f
0000001b 7205                           jc          0x22
0000001d b03f                           mov         al, 0x3f
0000001f 80c401                         add         ah, 0x1
00000022 f6c103                         test        cl, 0x3
00000025 7401                           jz          0x28
00000027 ee                             out         dx, al
00000028 e2eb                           loop        0x15
0000002a bbf0ff                         mov         bx, fff0
0000002d b120                           mov         cl, 0x20
0000002f 8bc3                           mov         ax, bx
00000031 f7e8                           imul        ax, ax
00000033 ab                             stosw
00000034 43                             inc         bx
00000035 e2f8                           loop        0x2f
00000037 07                             pop         es
00000038 33ff                           xor         di, di
0000003a 80440f02                       add         byte ptr [si+0xf], 0x2
0000003e c7440270fe                     mov         word ptr [si+0x2], fe70
00000043 df440e                         fild        word ptr [si+0xe]
00000046 de7404                         fidiv       word ptr [si+0x4]
00000049 d9ff                           fcos
0000004b de4c5d                         fimul       word ptr [si+0x5d]
0000004e df5c0a                         fistp       word ptr [si+0xa]
00000051 c70480fd                       mov         word ptr [si], fd80
00000055 57                             push        di
00000056 56                             push        si
00000057 8b7c0e                         mov         di, [si+0xe]
0000005a 03ff                           add         di, di
0000005c ba0080                         mov         dx, 8000
0000005f 03fa                           add         di, dx
00000061 8b6c0a                         mov         bp, [si+0xa]
00000064 03d5                           add         dx, bp
00000066 c1fd0b                         sar         bp, 0xb
00000069 0faf6c02                       imul        bp, [si+0x2]
0000006d f6e6                           mul         al, dh
0000006f c1e808                         shr         ax, 0x8
00000072 f66406                         mul         al, [si+0x6]
00000075 50                             push        ax
00000076 b8ff01                         mov         ax, 01ff
00000079 2ac6                           sub         al, dh
0000007b 8bdf                           mov         bx, di
0000007d 8bf2                           mov         si, dx
0000007f c1fb0c                         sar         bx, 0xc
00000082 c1fe0c                         sar         si, 0xc
00000085 03db                           add         bx, bx
00000087 03f6                           add         si, si
00000089 8b8f48d3                       mov         cx, [bx-2cb8]
0000008d 8bdd                           mov         bx, bp
0000008f 038c48d3                       add         cx, [si-2cb8]
00000093 c1fb0c                         sar         bx, 0xc
00000096 03db                           add         bx, bx
00000098 038f48d3                       add         cx, [bx-2cb8]
0000009c 81c70002                       add         di, 0200
000000a0 83f968                         cmp         cx, 0x68
000000a3 7d0b                           jnl         0xb0
000000a5 03160201                       add         dx, [0102]
000000a9 032e0001                       add         bp, [0100]
000000ad 48                             dec         ax
000000ae 75cb                           jnz         0x7b
000000b0 c1e802                         shr         ax, 0x2
000000b3 59                             pop         cx
000000b4 02c5                           add         al, ch
000000b6 87ce                           xchg        si, cx
000000b8 5e                             pop         si
000000b9 2b5402                         sub         dx, [si+0x2]
000000bc d1f9                           sar         cx, 0x1
000000be c1fa0c                         sar         dx, 0xc
000000c1 3bca                           cmp         cx, dx
000000c3 7404                           jz          0xc9
000000c5 2c10                           sub         al, 0x10
000000c7 eb0d                           jmp         0xd6
000000c9 2b2c                           sub         bp, [si]
000000cb d1fb                           sar         bx, 0x1
000000cd c1fd0c                         sar         bp, 0xc
000000d0 3bdd                           cmp         bx, bp
000000d2 7406                           jz          0xda
000000d4 2c08                           sub         al, 0x8
000000d6 7302                           jnc         0xda
000000d8 33c0                           xor         ax, ax
000000da 5f                             pop         di
000000db aa                             stosb
000000dc 830404                         add         word ptr [si], 0x4
000000df 813c8002                       cmp         word ptr [si], 0280
000000e3 0f8c6eff                       jl          0x55
000000e7 83440204                       add         word ptr [si+0x2], 0x4
000000eb 817c029001                     cmp         word ptr [si+0x2], 0190
000000f0 0f8c5dff                       jl          0x51
000000f4 e460                           in          al, 0x60
000000f6 48                             dec         ax
000000f7 0f853dff                       jnz         0x38
000000fb b003                           mov         al, 0x3
000000fd cd10                           int         0x10
000000ff c3                             ret
... be correct?

:?:
matt
Sheepie Whore
Sheepie Whore
Posts: 14826
Joined: Mon Apr 22, 2002 4:07 pm 0
XBL Gamertag: gingerbeardman
PSN: wirehang
Location: here && there
Contact:

Post by matt »

This discussion is excellent!

matt
User avatar
failrate
Baaaaaa!
Baaaaaa!
Posts: 2354
Joined: Sun May 23, 2004 6:54 am 0
Location: Sandy Eggo
Contact:

Post by failrate »

Yar, circuitry has been increasingly more designed by software over the last few years. I frequently work with "generators", which are scripts designed to write other scripts. Additionally, evolutionary programming has been around for years.

So, as far as visual appeal, let's say you have a thumbs-up, thumbs-down button. The demoBot churns away, pops out a biscuit when it can run without fatal exception, and you take a gander. If it's nice, you give it the thumbs-up. Otherwise, thumbs-down, shit-canned. Thus, it may be feasible to give a stronger breeding preference to the successful ones. Don't have time to watch them all yourself, then pop out a multitude at a time, and post them on a website with a voting sytem :D
User avatar
Dvorak
Baaaaaa!
Baaaaaa!
Posts: 4560
Joined: Wed May 08, 2002 7:37 am 0
Yahoo Messenger: d3dxquaternion
Location: Germany

Post by Dvorak »

oktup wrote:Are you sure that disassembly is correct? Wouldn't ...

Code: Select all

corrected disassembly
... be correct?

:?:
Looks better, yes. :D
No DBs inside the code, and RET as last statement looks very convincing.
>take off sunglasses
Seamen and fishermen alike swear to have heard voices in the rising tide. Inhuman screams, some of them say.
User avatar
20thCenturyBoy
Baaaaa!
Baaaaa!
Posts: 1093
Joined: Fri Oct 01, 2004 8:16 am 0
Location: Perth, Australia

Post by 20thCenturyBoy »

Dvorak wrote:
oktup wrote:Are you sure that disassembly is correct? Wouldn't ...

Code: Select all

corrected disassembly
... be correct?

:?:
Looks better, yes. :D
No DBs inside the code, and RET as last statement looks very convincing.
Yup, it seems the debug command doesn't recognise 32-bit instructions or something. Ah well.
Mr Sheen
Baaa!
Baaa!
Posts: 182
Joined: Sat Nov 06, 2004 10:59 am 0

Post by Mr Sheen »

I've been poorly but I'm glad you lot got it. :D

Wouldn't it be really exciting to discover the first program!

I have a question cos I'm not very good with maths. If you consider the 256bytes as large number then you can place it in an array, so the very first program would be:

000000000000000000000000000(lotsmore)0001

and then 00000000000000000000000000000002

etc

is it possible to take an existing program and find its position in this array?

That way you could write a program that could discount huge chunks of stuff you know could possibly never execute, and maybe distribute ranges to other users.

I have been very interested in this approach for years, I wanted to do it with images but the scope of possibility was vast. It has some very weird philosophical issues attached to it that tend to get close to blowing my mind in that you "know" that this stuff exists already but discovering something is a bit weird- is it real or not?

I remember reading that Travis said that they didn't create their songs they existed already and they were just the channel that formalised them.

Either way, it would be amazing to discover these hidden programs...there really could be anything in that 256byte space, not just images generators but code breakers, in fact, tons of interesting programs!

Taking it to the extreme there's Doom 5 waiting to be discovered, there's probably a fully intelligent virtual being too. Maybe, somewhere in the 256bytes is a number generator that can generate gigabyte values for really large programs.

My head hurts.

Can we do something with this?
User avatar
ynohtna
Baaaa!
Baaaa!
Posts: 548
Joined: Sun Jun 01, 2003 11:35 am 0
Location: Brighton, England sometimes.
Contact:

Post by ynohtna »

You, my lad, need to read Godel, Escher, Bach: An Eternal Golden Braid by Douglas Hofstadter.
User avatar
piku
Sheepie Whore
Sheepie Whore
Posts: 20960
Joined: Wed Apr 24, 2002 10:44 am 0
Website: Http://Www.ncot.uk
Location: Wakefield
Contact:

Post by piku »

ynohtna wrote:You, my lad, need to read Godel, Escher, Bach: An Eternal Golden Braid by Douglas Hofstadter.
Possibly twice, and then a third time backwards just so you don't miss anything you didn't quite understand the first time ;)

Good book, tad mind boggling at times.
return (0);
User avatar
20thCenturyBoy
Baaaaa!
Baaaaa!
Posts: 1093
Joined: Fri Oct 01, 2004 8:16 am 0
Location: Perth, Australia

Post by 20thCenturyBoy »

Slightly off-topic, just reading Bill Bryson's "A Short History of Everything" which is full of mind-boggling numbers and statistics relating to the size of the Universe, space and time etc.

Eg statistics suggest that there are millions if not billions of Earth-like planets in the Universe capable of sustaining life. The problem is that the odds of any two of them being near to each other are astronomically small. That's near as in 10's of light years at best.

We really need to develop that trans-dimensional improbability drive :D
User avatar
Kemper_Boyd
Sheepie Whore
Sheepie Whore
Posts: 11967
Joined: Wed Jul 31, 2002 9:15 pm 0

Post by Kemper_Boyd »

Mr Sheen wrote: Taking it to the extreme there's Doom 5 waiting to be discovered, there's probably a fully intelligent virtual being too. Maybe, somewhere in the 256bytes is a number generator that can generate gigabyte values for really large programs.

My head hurts.

Can we do something with this?
Doom5 in 256 bytes? Not likely.

256 bytes is an enormous number. 2^2048 or roughly 3 * 10^616 if my
arithmetic is correct. Number of atoms in the universe? About 10^80.

If we said each instruction was 2 bytes and there are say 64 instructions
and only half of the instructions are valid following the preceeding one,
you'd have 32^128 valid programmes. About 10^192. That's a very big
number. :)

In reality the space is likely much larger. It wouldn't necessarily do
anything useful, there are far more 'nonsense' programmes than useful
ones.


As to a 256 byte programme generating a larger one. You'd could
generate a large programme but the chances of it being useful are
vanishingly small.

A 256 bit programme can take one of three approaches.

1. Exhaustively generate all gigabyte values.
This will spit out Doom5 after exhausting all 2^1073741824
permutations, the universe will cease to be before you've
even barely started.

2. Exhaustively generate all gigabyte valid programmes.
Better but as I explained above still bloody enormous.

3 Generate a specific programme.
There are 2^2048 inputs so at most they can map to 2^2048
different outputs. So for every programme you can spit out
there are 2^1073739776 other ones. The chances of you finding
Doom 5 by this method are... quite poor. :)

Take all numbers I've written here with a pinch of salt as I've
quite possibly buggered up, but they should be in the ballpark.
User avatar
ravuya
Baaaaaa!
Baaaaaa!
Posts: 4801
Joined: Fri Sep 12, 2003 4:17 am 0
XBL Gamertag: ravuya
PSN: ravuya
Yahoo Messenger: mr_seigen
Location: Inside your computer
Contact:

Post by ravuya »

Now I'm kind of curious. Even with inept set eliminations, someone could potentially produce a "distributed" system like this:

1. Each machine takes a "chunk" of 256-byte "possibility space"
2. They then generate the 256-bytes, runs it through "DEBUG" and some program is run on those bytes to determine if they produce any kind of program (perhaps in a virtual machine to detect a crash or something)
3. The results from the crash detector and the individual byte signatures are sent back to the central server

256-byte is a __lot__ bigger than most of the distributed key-attack stuff out there unfortunately.

Maybe we could start with something much smaller, like 64 byte programs -- there'd still be something useful there.

Edit: Um, shit. I just ran 256^256 through bc:
32317006071311007300714876688669951960444102669715484032130345427524\
65513886789089319720141152291346368871796092189801949411955915049092\
10950881523864482831206308773673009960917501977503896521067960576383\
84067568276792218642619756161838094338476170470581645852036305042887\
57589154106580860755239912393038552191433338966834242068497478656456\
94948561760353263220580778056593310261927084603141502585928641771167\
25943603718461857357598351152301645904403697613233287231227125684710\
82020972515710172693132346967854258065669793504599726835299863821552\
51663894373355436021354332296046453184786049521481935558536110595962\
30656
Eeeeee. 8O

64^256 isn't much better, but...
24103124269210325885801166060283141129120932479456889513596750390652\
57391591803200669085024107346049663448766280888004787862416978794958\
32496961298789077465145521333938162522477078207791768149967684554313\
73878200575973458579045991094613871220995079649978156413423006776294\
73355281617428411794163967785870370368969109221591943054232011562758\
45008057958785090099371489228347664663118151506380487337518226050624\
6992837898705971012525843324401232986857004760339316736
User avatar
Kemper_Boyd
Sheepie Whore
Sheepie Whore
Posts: 11967
Joined: Wed Jul 31, 2002 9:15 pm 0

Post by Kemper_Boyd »

The RC5-64 challenge was 2^64 so 18446744073709551616.
A mere 8 bytes.

Most serious cryptographers consider 2^128 to be more or less
untouchable 340282366920938463463374607431768211456.

256 bytes is a huge search space. :)
User avatar
ravuya
Baaaaaa!
Baaaaaa!
Posts: 4801
Joined: Fri Sep 12, 2003 4:17 am 0
XBL Gamertag: ravuya
PSN: ravuya
Yahoo Messenger: mr_seigen
Location: Inside your computer
Contact:

Post by ravuya »

Kemper_Boyd wrote:The RC5-64 challenge was 2^64 so 18446744073709551616.
A mere 8 bytes.

Most serious cryptographers consider 2^128 to be more or less
untouchable 340282366920938463463374607431768211456.

256 bytes is a huge search space. :)
Well, buggery. I guess then we would have to do some intelligent culling of "possibilities" to try and limit the search space.
User avatar
piku
Sheepie Whore
Sheepie Whore
Posts: 20960
Joined: Wed Apr 24, 2002 10:44 am 0
Website: Http://Www.ncot.uk
Location: Wakefield
Contact:

Post by piku »

Start with 1k programs... Everyone should be able to write something useful in 1k ;)

That way, if you can generate working programs, you've proved it's possible to come up with every possible program that could ever exist since making it work with larger programs is just a case of increasing the search space.

Or go for bitmap images. You could create a program that generates images sequentially and displays them on the screen. If you sat there long enough eventually images would appear. Limit the images to simple 1 bit images to begin with.
return (0);
User avatar
Kemper_Boyd
Sheepie Whore
Sheepie Whore
Posts: 11967
Joined: Wed Jul 31, 2002 9:15 pm 0

Post by Kemper_Boyd »

piku wrote:If you sat there long enough eventually images would appear. Limit the images to simple 1 bit images to begin with.
If you did it it sequentially you'll be looking at a 99.9% black screen for essentially forever.
Post Reply