On Thu, 28 Feb 2002 00:15:16 +0200 (EET), Cristian Burneci wrote:
> Could the push ax /pop ds sequence appear due to the fact that "mov
> ds,ax" does not exist anymore in case of 286+ ?
Why not ? All the X86s are backward compatible with 086 (and 088).
Mov DS,AX works fine on this PIII.;-)
Also, I should remind that the code sequence being discussed above
was not in a "Hello" program, but in a "Reboot" program to reduce
some of the confusion that this boring stuff must generate.<G>.
> In the mean time here are 2 more relevant examples about how much the code
> can be optimized (or non-optimized) by the C compiler (and the author of
> the program). Sorry again folks, if I annoy you, please just don't read
> any further.
And I have to comment that the examples Cristian has provided here and
in a previous message obviously make a case AGAINST "C" by a programmer
familiar with that language. Possibly SO familiar that they are even
worse than the average "joe" would do.
But they provide me with the ammunition to ask:
"What would be the motivation for anyone ever TRYing to learn "C" ?"
Could it be a feeling that bits and bytes and electronics are more
complicated than words ?
*
> Example 1
> ==========
> #include <stdio.h>
> void main (void)
> {
> unsigned char *sir = "Hello World\n";
> while (*sir!= '\0')
> putchar (*sir++);
> }
> }
> Example 2
> =========
> Uses a static variable. Even if
> it is not necessary, the compiler takes care of "sir" at every iteration.
> The recipe is the same, though:
> #include <stdio.h>
> unsigned char *sir = "Hello World\n";
> void main (void)
> {
> while (*sir!= '\0')
> putchar (*sir++);
> }
*
The source code doesn't look QUITE the same, but they are both still
Greek to me.
Now here is the source code in ASM for my version: (with ;comments)
*
MOV DX,0109 ;Load DX with a pointer to the start of the string.
MOV AH,09 ;Load AH with spec. to print a "$" terminated string.
INT 21 ;Deliver unto DOS the specification and do the job.
INT 20 ;Leave this and return to command prompt.
Hello world CRLF$ ;The string - which starts at address 0109.
*
To a newbie this will also look like Greek. However, the syntax rules
are trivial in comparison to the "C" source, which the newbie would
soon find out if he tried to learn both at the same time. <G>
And in learning ASM the newbie will (MUST) learn about the hardware
while the higher level language (C, Pascal, Forth, APL, Basic, Fortran
etc.) is just another exercise in grammar with no connection to the
root of the job. IMO.<g>
In deference to Richard, I know it would be a great deal of work to
write a browser from scratch in ASM. It may be impossible. It would
certainly LOOK like an impossibly large job.
- Clarence Verge.
-- Using Arachne 1.66 on DSL.