Skip to content

Comment on Show HN: A (marginally) useful x86-64 ELF executable in 466 bytes

Comments

You can shrink it further by doing xorl reg, reg. On x86, the upper 32 bits are cleared for you when using 32 bit opcodes. No need to do a 64-bit reg, reg xor.

Instead of doing cmp $0, %eax, you can use test eax, eax - that's another low hanging fruit.

It seems that you could also preset a dedicated reg to 0 and another to 1, further shaving a few bytes.

Thanks for the suggestions! I'll definitely look into those. I'd been hoping posting on HN would result in being able to shave off yet a few more bytes.

Also learn the string instructions --- I can see plenty of places where a lodsb would help greatly.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.