Machine language Hello-World in 120 bytes

Posted by Nikolaus Gradwohl Wed, 25 Feb 2009 04:37:00 GMT

a while ago i read the really cool tutorial on programming a pdp11. after typing the "hello world" example into the simulator, i startet to search for instructions how to write the machine code for the pdp11 myself.

after a while coding in raw octal numbers, i wanted to take it to the next level and searched for a way to write machine code by hand for my linux box

So i downloaded Intel Architecture Software Developer's Manual, Volume 2: Instruction Set Reference Manual and wrote a shell script that can be used to dump the raw machine code into a file. of course my dualcore-pentium-mega-bla processor in far more sophisticated than the pdp11 cpu was. so it can't be programmed in octal numbers - i used hexadezimal numbers :-)

execute the shellscript and pipe it into a file

sh dump.sh > hello

make it executable and - TATAAAA - a hello world programm in 120 bytes (including the elf header - which adds 80 bytes all by himself)

# write a elf header in the file
echo -ne "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00"
echo -ne "\x02\x00\x03\x00\x01\x00\x00\x00\x54\x80\x04\x08\x34\x00\x00\x00"
echo -ne "\x80\x00\x00\x00\x00\x00\x00\x00\x34\x00\x20\x00\x01\x00\x28\x00"
echo -ne "\x03\x00\x02\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x80\x04\x08"
echo -ne "\x00\x80\x04\x08\x6f\x00\x00\x00\x6f\x00\x00\x00\x05\x00\x00\x00"
echo -ne "\x00\x10\x00\x00"


echo -ne "\x31\xc0"  # clear eax
echo -ne "\x50"  # push 0 on the stack
echo -ne "\x68rld\x0a"  # push the string onto the stack in reverse order, 4 bytes a time
echo -ne "\x68o Wo"
echo -ne "\x68Hell"

echo -ne "\x89\xe1"  # move stackpointer to ecx ( the start of our string )
echo -ne "\xb0\x04"  # move 4 to al ( eax is already 0 because auf line one )
echo -ne "\x33\xc3\xb3\x01"  # xor ebx and move 1 to bl
echo -ne "\x32\xc2\xb2\x0c"  # xor edx and move 12 onto dl (length of the string )
echo -ne "\xcd\x80"  # int 0x80
echo -ne "\xb0\x01"  # move 1 into al
echo -ne "\xcd\x80"  # int 0x80

Tags , , ,  | 1 comment | no trackbacks

Tweet This! submit to reddit Digg!

blender links

Posted by Nikolaus Gradwohl Mon, 23 Feb 2009 04:11:00 GMT

This week i played a bit with blender. here are the links and books i found useful.

Links

the main blender site

http://www.blender.org

a tutorial showing how to integrate pythonscripts in the blender game engine

http://blenderbuilt.com/index.php?option=com_content&task=view&id=54&Itemid=103

a blender wikibook

Blender Wiki book

a blender modelling tutorial

http://biorust.com/index.php?page=tutorial_detail&tutid=77&lang=en

Books

Introducing Character Animation with Blender

Bounce, Tumble, and Splash!: Simulating the Physical World with Blender 3D

Tags ,  | no comments | no trackbacks

Tweet This! submit to reddit Digg!

processing ical-flowers-2.0

Posted by Nikolaus Gradwohl Sun, 15 Feb 2009 07:15:00 GMT

I made a new version of the ical flowers sketch i wrote in dezember. This time it doesn't only show a flower for every event in my calender, it also shows

  • the current weather (using the rubyweather library)
  • the current temperature outside
  • the min/max temperature outside
  • the current temperature inside ( using my arduino i2c thermometer sketch)
  • the sky color changes depending on the current time

ical-flowers screen1

ical-flowers screen2

the system consists of a ruby-proxy, an arduino sketch and a processing sketch.

the ruby proxy starts a web-server on port 2000. It fetches the current weather using the rubyweather gem, fetches the events from the configured caldav calenders, and fetches the current temperature from the arduino using ruby-serial

the arduino sketch is basicaly the same as in this blog post. the only change is that the arduino only sends the temperature when the host sends a 'C' over the serial line

the processing sketch finally fetches the data via http from the proxy and displays it ( using my icap4p library. the screen is updated every 1/2 hour using the method described here

the code can be downloaded here

it's published under the LGPL

have fun :-)

Tags , , , , , , , ,  | no comments | no trackbacks

Tweet This! submit to reddit Digg!

How to build a Download-Bot

Posted by Nikolaus Gradwohl Tue, 10 Feb 2009 17:26:00 GMT

a while ago i posted images of my download-bots. this december my parents used them as their xmas-tree decoration.

now i have written some instruction to enable my dear reader to build his own download-bot - prefereably while downloading a big file.

i use 2 strip of wood one 2cm x 4cm, and the second one 1cm x 0.5cm

  • cut a 2 cm long block from the bigger strip for the head
  • cut a 4.5cm long pice from the bigger strip for the body
  • cut 4 2.5cm long pices from the smaller strip for arms and feet
  • cut a 1 cm long pice from the smaller pice for the nec
  • now glue the pices together following the instruction graphic bellow.
  • put 2 pins into the head as antennas
  • and finally draw a funny face on the head block

instruction1

é voilà - a download-bot!

instruction2

i really would like to see a comment if you have build your own bot

Tags  | no comments | no trackbacks

Tweet This! submit to reddit Digg!

ruby symbols vs string vs constant

Posted by Nikolaus Gradwohl Tue, 10 Feb 2009 02:13:00 GMT

on saturday i was asked by a ruby-newbie (sorry - i had to write it :-) ) whats the difference between a symbol, a string and a constant in ruby. even tough there are realy, realy many articles about ruby symbols ( a google search for "ruby symbols" results in 1,340,000 hits - so this is the 1,340,001 aricle covering the topic) there is obviously still some confusion out there. So i try my own definition here.

Read more...

Tags ,  | no comments | no trackbacks

Tweet This! submit to reddit Digg!

What's new in Python 3.0

Posted by Nikolaus Gradwohl Mon, 09 Feb 2009 17:48:03 GMT

i have played a bit with python3.0 and this are the things that catched my eye:

  • the new print syntax
  • the exception-handling
  • decorators
  • the new io module
  • classes in python

are no complete list of changes between 2.5 and 3.0 - and don't want to be. they are just a list of thing's i noticed. Some of them are already present in python 2.6 but i newver used that release - so i don't realy know.

Read more...

Tags  | no comments

Tweet This! submit to reddit Digg!

Treemonster

Posted by Nikolaus Gradwohl Sun, 08 Feb 2009 11:53:48 GMT

a friend of mine found another monster - this one tried to camouflage as a tree

treemonster

Tags ,  | no comments

Tweet This! submit to reddit Digg!

abstract art generator

Posted by Nikolaus Gradwohl Fri, 06 Feb 2009 17:29:01 GMT

my latest processing-sketch is a generator for abstract art.

just click on the applet to generate a new image

abstract art generator

Tags ,  | 1 comment

Tweet This! submit to reddit Digg!

Processing links

Posted by Nikolaus Gradwohl Thu, 05 Feb 2009 17:02:00 GMT

http://www.processing.org/ the mother of all processing sites :-)

http://www.arduino.cc/ a language and a microcontroller board that that go very well with processing

http://mobile.processing.org/ a mobile phone edition of porcessing

http://www.openvisuals.org/ a site showing how to visualize data using processing

http://www.openprocessing.org/ a site collection processing sketches

http://www.processingblogs.org/ a processing meta blog

http://www.rmx.cz/monsters/ a collection of black'n'white monsters - coded in processing (one of them has been written by me :-) )

http://www.local-guru.net/blog/tag/processing my own site

two really great art collections using processing

http://www.complexification.net/gallery/

http://abandonedart.org/

some artists using processing

http://www.flight404.com/blog/?cat=1

http://www.toxi.co.uk/

http://www.benfry.com/

http://www.groupc.net/

Books:

make things talk

visualizing data

Processing: A Programming Handbook for Visual Designers and Artists

Tags  | 1 comment

Tweet This! submit to reddit Digg!

Door Monster

Posted by Nikolaus Gradwohl Thu, 05 Feb 2009 03:52:32 GMT

A while ago, a hook on our bathroom door fell down. First we thought it was because of some loose screws. but today i found out the real reason - there was a monster lurking behind it!

doormonster

Tags ,  | no comments

Tweet This! submit to reddit Digg!

Older posts: 1 2