Przemoc's techblog

cross-site thinking

Fibonacci in x86 assembler and the scene

My friend gave me once (long time ago) a programming task. Write as short as possible function (in terms of binary form) in x86 32-bit assembler for finding n-th Fibonacci number. No particular calling convention was required. I’ve quite easily found satisfactory 16 bytes solution. I’ve used xadd instruction for conciseness (as a name suggest, its result is identical to xchg + add), but losing portability (486+ required). He saved one more byte by using cdq instruction (that converts signed eax to signed edx:eax) for zeroing edx register in one byte. Funny thing is that his first version, which was sent for asmpak inclusion, was exactly like my final one.

Above nasm-compatible snippet is pretty self-explanatory. There is a good reason for not using ebx that I didn’t know then. According to System V Application Binary Interface Intel386 Architecture Processor Supplment it is one of five registers (ebp, ebx, edi, esi, esp) belonging to the calling function, i.e. called function must preserve them. But to conform it further to cdecl calling convention you would have to add pop ecx and push ecx (2 bytes: 59 51) at the beginning of the function, because arguments are pushed onto the stack.

I like assembler for its low-level capabilities. It’s the only language giving you the full control over what instructions will be executed in CPU. It is also the third language I’ve ever touched in my whole programming career. Back then (15 years ago?) assembly language wasn’t the best target after Basic and Pascal, but it required me to think almost like a processor which was refreshing, entertaining and of course educational.

Nowadays assembler is rarely used to create applications for x86/x86-64 architecture. It is still useful for fine-tuning hot code paths (e.g. compression, especially optimized for different CPUs) though. Deep understanding of assembly language is also crucial for reverse engineering of viruses, rootkits, malware and other software pests. There is also a crack scene and surroundings, tightly connected with RE along with many wise, intelligent and clever people. Cracking per se is not an evil act. It really requires many skills, thorough software (and often hardware) knowledge and analytical thinking. But evil can be further action, i.e. what you do afterward. There are always white hats and black hats. Even if one group is more noticeable than the other one, it doesn’t mean you can treat them all as thugs…

Polish crack scene seems dead. This is sad, because it gathered many skilled RE-oriented guys (and girls?) in its time of glory. Once I started a thread in OSnews.pl forum (sorry, Polish only) asking readers-potential-(ex)crackers/reverse-engineers what is going on with all these great people. One month ago (but I spotted it a few hours ago) somebody impersonating ex-AAoCG member (AAoCG was one of the most widely known Polish cracking teams) responded with his theory of why the scene is dead. To make this short, lack of social work to promote its values and some mix of egoism, vanity and omnipresent commercialism. Sounds likely, isn’t it? But one thing shocked me. I wanted to believe, due to my infant naivety w.r.t. this subject, that black hats have their own ideals too and, while we may not understand (or rather disagree with) their way of life, they’re just giving results of their work for free. If it’s not true for all of them, then which behavior is more common? Are black sheep among them actually gray?

Polish cracking scene had ctrl-d – Polish page with cracking and RE news. There was also an asmpak – nice set of assembler snippets – which is no longer available. Don’t worry, I have a copy of its last version from 2004.05.01.

asmpak 000Ch: asmpak000Ch.rar

Rule #0 of the internet: you have to constantly backup it!

Filed under  //   assembler   polish crack scene   x86  

Rouse e by post, i.e. why I am here at Posterous?

Posterous is getting more and more attention lately. It’s not that surprising. Why? This might be the best blogging platform in the near future. Remember my words. So what about the present time? No need to worry, because Posterous is already a top-notch product. That’s why I’ve chosen it for my techblog. Details? Sure, have a look at some.

Nowadays blogging via email is nothing special. There are some plug-ins for common blog software, there is tumblr beside Posterous and possibly some other services capable of email-driven communication but unknown to me. Who was the first with the great idea of posting using emails? I have no clue, but it doesn’t matter. Important thing is that Posterous focuses “on the best email experience” and the team behind it thinks, just like me, “email is the best way to publish online”. It’s not an add-on, it’s the main feature. I like mail much better than any IMs/chats/microblogs, because usually it ends with well-rounded text, at least often better than by using other ways of writing. Quality is an important part of the communication and I hate when it is forgotten or silently ignored.

I really dislike HTML formatted emails and I am not the only one with such attitude. Lack of proper formatting in plain-text was big problem of Posterous. It has been resolved with introducing markdown support, so one obstacle less. Another one was lack of static pages, but it is also a past already – thanks to unveiling the pages (with recent improvements). Techblog usually requires some syntax highlighting. Posterous chose CodeRay and it is not the best possible choice, but still a good one. It is wisely integrated into markdown syntax. There is also automatic embedding of GitHub Gist – just use the URL of snippet. Nice, isn’t it?

Users have here a lot more useful features. Scheduling posts for the future, private posts, custom domain name support, easy video sharing, posting an image gallery by emailing a zip file, control over download links, commenting via email and bunch of other options related to working with other sites. If you have a blog already and want to migrate, then visit switch page. Importing from many blog and posting services is supported to smooth your transition.

There are still some small potatoes though. Markdown has syntax for embedding images in-place:

![alt-text](link-to-image title-of-image alignment)

Posterous should support using images attached to emails by placing their names in link-to-image part. Allowing defining how big the thumbnail should be used (e.g. by adding 4th parameter: thumbnail-width) and preventing resizing by default if image is put alone in its own paragraph also would be very useful. I think it should not require ((nogallery)), because not all images are always intended to be used inline. They could be used to create usual gallery at the end if there is no ((nogallery)) in mail subject or just be placed one after the other at the end if ((nogallery)) is present.

Another thing is the commenting system. It is not the most important feature and Posterous crew is all the time concerned about overall system, so current engine is not polished as it could be. Supporting use of dedicated solution, IntenseDebate to be precise, would be another big improvement. At the same time it would allow the team moving to polishing other elements of this great blogging service. Simple win-win, right?

I sent these (and one more) proposals to help@posterous.com and received information that some of my suggestions will be passed to the team.

We’re looking into improving the commenting system and working on polishing things up. Look for a few updates soon! To stay up to date on our happenings, check out the official Posterous blog at http://blog.posterous.com.

I will, definitely! And you? In the meantime:

Rouse electrons by post with bloody brilliant Posterous!

Filed under  //   posterous