From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,97188312486d4578 X-Google-Attributes: gidfc89c,public X-Google-Thread: 109fba,baaf5f793d03d420 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,97188312486d4578 X-Google-Attributes: gid103376,public X-Google-Thread: 1014db,6154de2e240de72a X-Google-Attributes: gid1014db,public From: "Alf P. Steinbach" Subject: Re: What's the best language to start with? [was: Re: Should I learn C or Pascal?] Date: 1996/08/12 Message-ID: <320E742A.7288@online.no>#1/1 X-Deja-AN: 173585404 references: <01bb846c$e51df220$87ee6fce@timpent.airshields.com> <4ug4eh$qn8@zeus.orl.mmc.com> <01bb86f5$f7f8ae40$32ee6fce@timhome2> <4uk67k$ii2@solutions.solon.com> <01bb87d2$1752b9c0$87ee6fce@timpent.airshields.com> content-type: text/plain; charset=us-ascii organization: Telenor Online mime-version: 1.0 newsgroups: comp.lang.c,comp.lang.c++,comp.unix.programmer,comp.lang.ada x-mailer: Mozilla 2.0 (Win95; I) Date: 1996-08-12T00:00:00+00:00 List-Id: Tim Behrendsen wrote: > > Peter Seebach wrote in article > > Are you quite sure? I'd assume that assemblers would let you enter > constants > > in at least the three commonly used bases, and I would be completely > > unsurprised if there were occasionally two ways of spelling a given > operation, > > perhaps allowing for a distinction which no longer exists. > > Of course you can enter constants in different bases, but > that doesn't affect the code that's generated. The entire > *point* of assembler is to be a 1-to-1 corresponence. Otherwise, > it would be a HLL. Sorry to intrude again after I opted out when the discussion polarized (I've been lurking in the shadows, though). But this is sort of funny. The assembler language I now know best is x86 for early x86 processors (386). Modern x86 assembly does *not* correspond 1-to-1 to machine code, as P.S. correctly points out. But for the wrong reasons! Many high-level constructs and ideas have migrated down to assembler languages, like the concepts of defining datatypes, symbolic constants, routines with typed parameter lists, if-then-else and other flow-control constructs, and so on, including direct support for OOP in Borland's TASM assembler. A modern assembler program has a syntactical structure much the same as HLL program -- however, the programmer is free to write everything as one long, grey mass of pure instructions with the structure embedded as jump instructions and so on, just as you can in C. For the first fumbling steps, this gray mass is the relevant subset. The differences from programming in a HLL are mainly (this is opinion): - Limited type-checking. The student who has really crashed a machine a few times will probably understand the point of typechecking. Likewise, he/she may gain a better understanding of things like bitsets, direct versus twos-complement form binary, and simple static datastructures in general. - The top level of the memory hierarchy -- processor registers -- is exposed, and under the control of the program. A high-level language hides the registers and allocates them automatically. This is good for understanding what "sequential" really means. - Memory addressing is exposed and naked to the eye, although some assemblers (esp. Micro$oft) try to be confusing about this. This is very good for understanding (A) variables, (B) parameter passing, (C) pointers, in order from simple to difficult to the newbie. - You *can* have complete control over the instructions and other contents ending up in the executable/library/whatever. - You have access to absolutely everything the machine can do. That is, you use assembler not for efficiency or code size but to achieve something impossible or completely impractical in a HLL. This includes writing linkage stubs, interrupt handlers (esp. requiring indirect jumps), detecting 16/32-bit code segment, etc. Now, as I've stated earlier, I think it's silly to try to keep knowledge from students. Anyone who does is not a real educator, but rather the opposite. On the other hand, I do not think students should start learning only assembler. One argument here is that students are motivated by what they can achieve of practical results. For example, popping up a "Hello, world" message box in Windows 3.1 required 40-50 lines of assembler, and not exactly newbie assembler, but only 4 lines in Pascal. - Alf