Daily Shaarli

All links of one day in a single page.

July 2, 2014

Branch differently in x86 / x86-64 using only printable visible ASCII characters in the machine code - Programming Puzzles & Code Golf Stack Exchange
thumbnail

7 bytes

0000000: 6641 2521 2173 21 fA%!!s!

As 32 bit

00000000 6641 inc cx
00000002 2521217321 and eax,0x21732121

As 64 bit

00000000 6641252121 and ax,0x2121
00000005 7321 jnc 0x28

and clears the carry flag so the 64 bit version always jumps. For 64-bit the 6641 is the operand size override followed by rex.b so the operand size for the and comes out as 16 bit. On 32-bit the 6641 is a complete instruction so the and has no prefix and has a 32-bit operand size. This changes the number of immediate bytes consumed by the and giving two bytes of instructions that are only executed in 64-bit mode.

sandpile.org -- x86 architecture -- SIB byte
sandpile.org -- x86 architecture -- mod R/M byte
Colony Graphs

Colony graphs are a simple visualization of computer life forms. A process colony graph, or "ptree graph" for short, shows live processes and their parent and child relationships.