The title says it all.
List some things that can't be done with C, but can be done with ASM.
Posted on 2006-10-20 23:13:21 by belhifet
Binary rotate (ror,rol)
Posted on 2006-10-20 23:57:12 by Homer
Write a bootloader?

and anyway, 'What can C do that ASM can't?'
Posted on 2006-10-21 02:44:29 by sinsi
That's a good question and that got me thinking alot.
Posted on 2006-10-21 02:48:30 by roticv
Write 1/3 of the code and data for you, via macros. C can't do it - it's macros are primitive.

Helps you find bugs much faster.
Posted on 2006-10-21 03:49:19 by Ultrano
I've always thought of C as a sort-of "Super Macro" assembler anyway...
Posted on 2006-10-21 04:01:20 by sinsi

Binary rotate (ror,rol)

a = (a << 1) | ((a & 0xFFFFFFF7) >> 31);

Translates to a single ROL in VC2005. Yeah, it's ugly and non-portable, but it can be done :). I guess some template magic and traits stuff can make it portable, though. And of course the places where you need to do this kind if stuff you usually know the integer size, and can thus define a specific type so it will be portable...

A bootloader is a good example of somethign that's not practical to do in C, though.

Ultrano: the C macro system is a joke... and has caused a lot more grief than it has done good things (at least on windows... the PlatformSDK is an atrocity). You can do damn powerful things with templates, though... and dunno about "Helps you find bugs much faster." - a knowledge of assembly can do that, though. But this will depend on the person debugging...
Posted on 2006-10-21 08:30:21 by f0dder
overflow checking

for example try to arithmetic average (hope it's right word) in C. And not this buggy version: ;)

int x;
int y;
int aa = (x+y)/2

common "solution":

int x;
int y;
long long aa = ((long long)x+(long long)y)/2;

because you have builtin support for 64bit types. But what about AA of long long then? And again, this is not a solution

in assembly:
mov eax, dword 
mov edx, dword
add eax, dword
adc edx, dword
rcr edx, 1
rcr eax, 1

sure there are many workarounds for it... but...
do you want few extra lines/macro for EVERY arithmetic operation that needs to be checked? You can check value before all operations, but sometimes it is extremely hard to find all places where it can overflow, and sometimes it's not possible.

For example remember bug with too big picture crashing windoze... ;)
Posted on 2006-10-21 10:17:39 by vid
self-modifiying implemention of shellsort algorithm could be very difficult in C, but brilliant in asm
PS: There is a excellent example of that at the art of programming(volume 3)
Posted on 2006-10-21 12:28:12 by Dite
Self-modifying code can make code slow... dunno about that specific example, though. But yeah, self-modifying code isn't something you can reliably do in C :)
Posted on 2006-10-21 15:12:03 by f0dder