Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I found the odd mix of GNU/AT&T and Intel syntax a little disorienting --- especially all the '%', which the author starts out using in the text but then decides to just suddenly stop using halfway through.

The flowchart view is extremely useful, and from my experience of having taught an Asm class before, in which students were required to do both compilation and decompilation, creating such a graphical representation of the program flow really helps to clarify when going from C to Asm and vice-versa. Lacking software to do it automatically, printing out the code and drawing lines works reasonably well.

That "challenge" function should puzzle anyone who knows even the slightest bit of Asm --- not because of its purpose, but because of how it does it. Subtracting one number and then adding another, is entirely equivalent to adding their sum; so that could be simplified to:

    call $+5
    pop eax
    sub eax, 5
    sub eax, [eax-15]
    ret
The "call $+5/pop" idiom for "where am I" is also used a lot in packers, so those who have such experience with unpacking will recognise it too. Look at enough Asm (particularly compiler output, but I doubt that example was generated by one) and you'll start to pick up on small inefficiencies/stupidities like this; it really tends to dampen your belief in how optimising compilers actually are in practice. ;-)


Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: