News for hackers. Stuff that matters.
Re:Int 80h (2001) by mschuster91 on Sunday August 21, 2016 @05:58PM (#12332906)
> I have no idea where people get the idea that one line of C equals 10 lines of asm.

Because coding in asm takes more than just the raw instructions.

x86 doesn't have many registers so you're shifting around stuff across registers and memory all the time, not to mention stack setup/teardown and the error checking (e.g. div0, overflow) you are supposed to do after operations.

Re:Int 80h (2001) by gens on Sunday August 21, 2016 @06:25PM (#12332989)
C doesn't check for overflows..

I also disagree with "shifting around stuff across registers and memory all the time". An "average" function doesn't really have all that many variables and x86 has 8 GP registers (16 on amd64). You don't even have to declare variables, you just take a register (and/or a location in memory) and use it as you wish.

I'm now sitting here thinking what can be done in C that would end up being a lot of instructions, and i can't think of anything. Going over an array does not, neither does recursion (recursion is just syntactic sugar in the end). What else.. i can't think of anything. Macros ? But macros are cheating in this comparison (not to mention that the flat assembler has actual macros, that are extremely powerful)

Re:Int 80h (2001) by userbinator on Sunday August 21, 2016 @06:57PM (#12333111)
C doesn't check for overflows..

This is one of the things where (x86) Asm is definitely easier: divide overflows naturally cause an exception which will get handled automatically, and add/subtract/multiply overflows can be checked with one extra (JO or JC) instruction. In C, this is all undefined behaviour.

I'm now sitting here thinking what can be done in C that would end up being a lot of instructions, and i can't think of anything.

Crypto algorithms come to mind, but like you said, macros can take care of that easily... and on this page is an AES-256 CFB implementation in Asm that is around the same size of source as others in C (but much smaller binary):

http://reimagery.com/fsfd/encrypt.htm