RE: A89: Which is better?


[Prev][Next][Index][Thread]

RE: A89: Which is better?




Yes like he said extreme.
(*(void(**)(void*,void*,long))(*(long*)0xc8+618*4))((void*)0x4c00,buffer,384
0); seems extreme to me. Maybe you have used something like that a few
times. Even then, Ill bet you could find some assembly code that is 10 times
worse then that. Just because it is all on one line doesn't make it harder
to understand then something that takes 200 short lines of coding (yes I
know that example doesn't take 200 lines of assembly). Do you even remember
where we started this argument, conversation, whatever? Ya it was a newbie
programmer asking which would be easier to learn to program C or assembly.
Not what code can you screw up the most to make it look complicated. He is
never going to use
(*(void(**)(void*,void*,long))(*(long*)0xc8+618*4))((void*)0x4c00,buffer,384
0);   (well not in the near future at least). If he ever does use something
like that code he will be an expert programmer and it won't mean diddly
squat.

-Brady



-----Original Message-----
From: owner-assembly-89@lists.ticalc.org
[mailto:owner-assembly-89@lists.ticalc.org]On Behalf Of Zeljko Juric
Sent: Wednesday, May 31, 2000 11:52 AM
To: assembly-89@lists.ticalc.org
Subject: Re: A89: Which is better?



Hi!

> Zeljko, your examples, which you call "good code", and not what I
> would call good code. Perhaps you mean "efficient code." Good code,
> according to my deffinition, is first and foremost code that makes
> sense. Maintainabilibty would be second, portability third, and
> efficiency perhaps fourth. When you are worried about efficiency,
> why not use inline assembly rather than unreadable C? I guess I
> have to concede that those cases may be easier to understand in
> assembly, but I consider them extreme cases.

You are mainly right ;-) I wrote my last message more for fun than
for serious discussing. But, I must quote again: if you want to do

pea 3840
pea $4c00
pea buffer
move.l $c8,a0
move.l (a0,618*4),a0
jsr (a0)

in C, and if inline assembler is not implemented, you MUST write
something like

(*(void(**)(void*,void*,long))(*(long*)0xc8+618*4))((void*)0x4c00,buffer,384
0);

There is no way to avoid this. This is not matter of "good" and
"bad" code. This is mainly the ONLY possible code (except, maybe, it
is possible to split this line into 2 or more lines, which are
also not very clear). Anyway, it is much more crypt than ASM code :-)

Zeljko




References: