Talk About Network

Google





Programming > Assembly Language > Re: I pee in th...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 37 of 65 Topic 5073 of 5194
Post > Topic >>

Re: I pee in the open

by Frank Kotler <fbkotler@[EMAIL PROTECTED] > Jul 14, 2008 at 04:58 PM

Herbert Kleebauer wrote:
> Frank Kotler wrote:
>> Herbert Kleebauer wrote:
> 
> 
>>> to C so you can do graphics in a C program without any graphics
>>> library.
>> Before you waste your time, explain to me how this would be "better".
> 
> Better than what? C better than assembler? Or no library better than 
> a graphics library.

C better than assembly. Library vs no library is a separate issue. 
(though relevant to the original topic, perhaps)

> 10 years ago I wrote a jpeg viewer for encrypted multi-jpeg
> files.

Cool! (judging just from the description of what it does)

> Look at the source code and you will know why for this  program
 > C is better than assembler

Probably not a good idea to assume what I will "know"... or not.

> ( ftp://137.193.64.130/jpeg/pfp.zip ).

Ahhh, okay... "access denied, too many anonymous users" a lot. Then, you 
need a "pub/" in there...

Unzips into current directory.

UPPERCASE FILENAMES.

....already, I'm annoyed, before I even get to the relevant part. I *try* 
not to let this cloud my judgement...

> All OS specific code is in a separate file (currently for DOS and
> for Windows)

Okay, I see "win.c"... "WIN.C", mean. I guess "CRYP.C" is the dos one(?) 
- seems to be where "main" lives, anyway... (I can't even find the 
goddam "_start" label or other entrypoint in C! Oh, that's right, it's 
"hidden"...) In the MAKEPFP/SOURCE directory I see .asm.... I mean 
".MAC" files...

Then I see stuff like (random snippet):

  if (encrypt)
     {p=head; while (*p) putc(*p++,out);
      for (i=0; i<8; i++) dat[i]=i;
      crypt(dat,key2i); modify(key2,key2i);
      for (j=0;j<8;j++) putc(dat[j],out);

      dat[0]=dat[1]=dat[2]=dat[3]=0;
      dat[4]=(size>>24);
      dat[5]=(size>>16);
      dat[6]=(size>> 8);
      dat[7]=(size    );
      crypt(dat,key2i); modify(key2,key2i);
      for (j=0;j<8;j++) putc(dat[j],out);
      size=(size+7)&0xfffffff8;
     }
  while ((i=getc(in))!=EOF)
   {dat[0]=i;
    for (j=1;j<8;j++) dat[j]=getc(in);
    if (decrypt) crypt(dat,key1); modify(key1,key1i);
    if (encrypt) crypt(dat,key2i); modify(key2,key2i);
    for (j=0;j<8;j++) put_byte(dat[j]);
   }
  ende(0,0);
}

What is it I'm supposed to "know" from looking at this, Herbert? I can 
puzzle out what it does, I guess (I *can* read C, to an extent - I just 
don't "like" to). For the sake of argument, suppose we've got an asm 
version of this exact code. (tried gcc -S but gcc isn't having any) 
Granted, it (too!) will be pretty incomprehensible at first glance. 
Longer, almost certainly ("taller"). If we allow the same number of 
comments as you use, we'd want really "meaningful" names for variables, 
functions, labels... "modify" might want to explain to us in what way 
it's being modified, for example. I like "short" executables, but I 
don't extend that to source code. You (and Rosario) like "terse" labels 
(letter 'a', numeral '1' looks an awful lot like "al", 'rio!). I'm 
coming to the opinion that "overly verbose" is a lot "better" than 
overly "terse".

I'd argue that we'd see what we're asking the CPU to do better in the 
assembly version. There may be redundant, detoured, or otherwise 
"useless" code that isn't obvious in the C version - depends on the 
compiler, *and* what it's being asked to do (you're good at this latter 
part). Perhaps we see "what's this doing for me" better in C - depends a 
lot on how the asm is written/commented, IMO.

Are you referring to the fact that you've got multiple object files? 
Most assemblers will do that. In view of our discussions of 
"bike"/"motorbike" and "assembler"/"macro assembler", I should make 
clear that I'm talking about a "linkable object file emitting macro 
assembler" (not necessarily Nasm specifically, but "like that")

With a suitably powerful "macro assembler", we could make the "asm" code 
*look* a lot like the C code. Would that be "better" than "plain asm", 
in your opinion?

What am I supposed to "see" that I'm missing?

> and it's still on the to-do list to make one for Linux.

I wouldn't discourage you from doing that! I might not "participate", 
even "follow along" - jpegs are pretty far "down" (as in "later") on my 
TODO list - but I think it's an excellent idea!

> I don't like it to depend on the existence of libraries if
> this isn't absolutely necessary.

It's *never* absolutely necessary! Hellishly impractical to get along 
without 'em sometimes (and perhaps pointless). But it's "possible"... if 
you want to... badly enough...

> I know that I need a X server 

Yeah... there's the frame buffer device, svgalib... Richard Cooper, aka 
PJ, showed us "softer", which does graphics by manipulating ****ts. Vga 
only, but one *could* provide separate routines for each card sup****ted. 
"No one in his right mind" would do it that way. But that's 
discrimination! :)

> (but that should be available on nearly any Linux with a GUI) but
> anything else can directly be done in the user program.  

Agreed.

>> Does the phrase "sick C religion" ring a bell? :)

Perhaps I should explain the "in group" joke. Old-timers will recall 
that before clax, there was comp.lang.asm... plagued with a guy who used 
that expression. I remembered it as "you only see what your sick C 
religion allows you to see", but Phil reminded me that the actual quote 
was "you only what your sick C religion allows you to see" - 
consistently, apparently "cut and past". Some folks who should have 
known better continued to reply to him... "lest the newbies be misled". 
And that's why clax is moderated...

I withdraw "sick". I still think that the belief that C is "inherently 
superior" to asm (or any other language - there are more than two 
combatants - and as Chuck points out, the "sickness" is in thinking of 
them as "combatants") might count as a "religion".

> No, I only know a "sick assembly religion". A C programmer 
> will go down to assembly if appropriate,

Uhhh, not all C programmers *know* assembly. A "good" programmer might 
object to being called a "C programmer" - he'd know several languages, 
and use the "most appropriate" - according to whatever criteria he damn 
well pleases (that's the nice part of being the programmer!). A 
"professional" programmer might have to use what the boss wants... 
unless he *is* the boss...

> some assembly
> programmer on the other side seem to think, a HLL is 
> completely useless.

Nothing's *completely* useless. We always need something to wipe our ass 
with, if nothing else. *I* don't argue that C is useless. (almost "a 
necessity" if we want cross-architecture ****tability, and it makes 
cross-platform ****tability more convenient) I *do* argue with the notion 
that C is "inherently superior" to assembly.

Best,
Frank
 




 65 Posts in Topic:
I pee in the open
Evenbit <nbaker2328@[E  2008-07-09 16:53:06 
Re: popen
"Rod Pemberton"  2008-07-09 20:56:51 
Re: popen
Evenbit <nbaker2328@[E  2008-07-09 19:58:21 
Re: popen
"Rod Pemberton"  2008-07-11 02:52:12 
Re: popen
Frank Kotler <fbkotler  2008-07-13 00:30:59 
Re: popen
"Wolfgang Kern"  2008-07-13 12:26:35 
Re: I pee in the open
Frank Kotler <fbkotler  2008-07-10 02:28:37 
Re: popen
"Rod Pemberton"  2008-07-10 06:21:23 
Re: I pee in the open
dickey <dickey@[EMAIL   2008-07-10 12:28:50 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-10 22:40:17 
Re: popen
"Rod Pemberton"  2008-07-11 02:51:50 
Re: popen
"Wolfgang Kern"  2008-07-11 10:20:05 
Re: popen
Frank Kotler <fbkotler  2008-07-13 00:02:24 
Re: I pee in the open
Frank Kotler <fbkotler  2008-07-12 23:29:49 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-10 22:46:01 
Re: popen
Evenbit <nbaker2328@[E  2008-07-10 23:04:28 
Re: popen
"Rod Pemberton"  2008-07-11 02:52:30 
Re: I pee in the open
dickey <dickey@[EMAIL   2008-07-11 04:29:55 
Re: popen
Evenbit <nbaker2328@[E  2008-07-11 10:26:00 
Re: popen
"Rod Pemberton"  2008-07-12 04:30:09 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-11 11:07:14 
Re: popen
Evenbit <nbaker2328@[E  2008-07-11 22:50:36 
Re: popen
"Wolfgang Kern"  2008-07-12 10:12:07 
Re: popen
Evenbit <nbaker2328@[E  2008-07-11 23:40:34 
Re: popen
"Rod Pemberton"  2008-07-12 04:30:18 
Re: popen
Evenbit <nbaker2328@[E  2008-07-12 06:04:15 
Re: popen
"Rod Pemberton"  2008-07-12 12:17:53 
Re: I pee in the open
Robert Redelmeier <red  2008-07-12 14:38:08 
Re: popen
Evenbit <nbaker2328@[E  2008-07-12 17:23:12 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-12 17:50:34 
Re: I pee in the open
Robert Redelmeier <red  2008-07-13 15:28:01 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-12 23:18:34 
Re: I pee in the open
Robert Redelmeier <red  2008-07-13 15:43:23 
Re: I pee in the open
Herbert Kleebauer <kle  2008-07-13 10:55:11 
Re: I pee in the open
Frank Kotler <fbkotler  2008-07-13 11:13:18 
Re: I pee in the open
Herbert Kleebauer <kle  2008-07-13 23:14:26 
Re: I pee in the open
Frank Kotler <fbkotler  2008-07-14 16:58:07 
Re: I pee in the open
Herbert Kleebauer <kle  2008-07-15 03:26:44 
Re: I pee in the open
"Wolfgang Kern"  2008-07-15 11:14:58 
Re: I pee in the open
"rio" <a@[EM  2008-07-15 14:01:18 
Re: I pee in the open
Herbert Kleebauer <kle  2008-07-25 21:19:28 
Re: I pee in the open
Herbert Kleebauer <kle  2008-07-28 21:27:18 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-13 12:21:39 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-13 12:29:56 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-13 15:52:23 
Re: I pee in the open
"Rod Pemberton"  2008-07-14 03:57:23 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-14 13:52:24 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-14 14:18:56 
Re: I pee in the open
Evenbit <nbaker2328@[E  2008-07-15 15:59:33 
Re: I pee in the open
"Rod Pemberton"  2008-07-16 02:25:36 
Re: I pee in the open
Robert Redelmeier <red  2008-07-16 13:08:26 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-15 19:04:35 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-19 13:07:45 
Re: I pee in the open
"Rod Pemberton"  2008-07-19 18:50:56 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-19 20:00:51 
Re: I pee in the open
"Rod Pemberton"  2008-07-20 14:46:04 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-20 19:21:50 
Re: I pee in the open
"Rod Pemberton"  2008-07-21 04:18:17 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-20 21:06:28 
Re: I pee in the open
Robert Redelmeier <red  2008-07-22 23:18:19 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-21 13:19:49 
Re: I pee in the open
"Rod Pemberton"  2008-07-21 19:49:34 
Re: I pee in the open
"Rod Pemberton"  2008-07-22 17:53:28 
Re: I pee in the open
Chuck Crayne <ccrayne@  2008-07-21 20:53:52 
Re: I pee in the open
NathanCBaker@[EMAIL PROTE  2008-08-02 10:41:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 17:02:02 PST 2009.