News for hackers. Stuff that matters.
Re:The Art of Picking Intel Registers (2003) by userbinator on Monday April 23, 2018 @07:48AM (#16902530)
I've done a few challenges like that[1] but seeing that the smallest so far is over 300 bytes makes me think most of those 300 bytes are not actual code but program header overhead, because it should be doable in much fewer bytes of actual code. Once you've done these challenges a few times, you can easily estimate a rough size:

The template is 48 bytes. Add 16 bytes for an [offset,char] table. Maybe another 30 bytes (let's be generous and round that up to 32) for code to pull the commandline parameter, do the indexing and template modification, write the output, and exit. 96 bytes of code. Add 64 bytes of minimal ELF headers[2] and you're still well below 200 bytes.

I don't have an environment at the moment that doesn't do ELF files, so I just tried it with 16-bit DOS and ended up at... 95 bytes:

https://pastebin.com/C7vDfFbR

I wasn't trying very hard so someone will probably find an even smaller version, and it was just for fun since it doesn't meet the rules anyway.

[1] http://www.hugi.scene.org/compo/compoold.htm

[2] http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm...

Re:The Art of Picking Intel Registers (2003) by dbrgn on Monday April 23, 2018 @09:19AM (#16903133)
Thanks for the links! Most of the submitted approaches don't even mess with the ELF binary structure. But even if you don't do that, there's a lot you can learn by optimizing (sometimes doing something with more instructions instructions actually result in a smaller binary because of shorter opcodes).

It was the first time I really messed around with x86 assembly and I learned a lot during the progress :)

Edit: Wording

Edit2: Also note that for this challenge you need to submit NASM assembly, and not the resulting binary. So you can't resort to hex editing the binary itself.

Re:The Art of Picking Intel Registers (2003) by jsjohnst on Monday April 23, 2018 @08:15AM (#16902677)