Re: Question about jumps
- From: "Dragontamer" <prtiglao@xxxxxxxxx>
- Date: 31 Aug 2006 08:54:24 -0700
Markus Pitha wrote:
randyhyde@xxxxxxxxxxxxx wrote:
Your problem, as others have pointed out, is that you're not to the
point yet where you understand the difference between the string
representation of an integer and the integer itself.
I understand it, but obviously it's in assembler language more complicated
than I thought, but it's my target to learn exactly these basic things.
Erm...
You can do this in Scheme, C, Lisp, Python, Perl, Haskell, and
Brain***
even.
The fact of the matter is that the most common "assembly language" way
is to link up with the C library and then use atoi or whatever.
But yeah; you can do this in C. In fact; there is an example
in the book "The C programming language" where they solve
this problem.
This has _nothing_ to do with assembly language.
stdout.put( "Enter an integer:" );
stdin.geti32(); // Read integer from stdin into EAX.
shl( 1, eax ); // Multiply EAX by two
stdout.put( "eax = " );
stdout.puti32( eax );
So why should I deal with assembler, when I could solve it with C-like
methods? That's not what I want to learn.
You can't touch eax in C.
Now you get to see the effect of the shl instruction without having to
learn all the stuff needed to write your own integer input and output
routines. Sure, at some point you ought to be able to write your own
input and output routines, but for right now the integer I/O routines
in the HLA stdlib are *perfect* for the job.
It's not my target to see what's happened when I type in a number and see
the result on stdout. That's what computer newbies are probably interested
in but I want to understand what the little gremlins in the background are
doing while this happens.
I just fail to see what HLA does that prevents this.
If you want to write your own itoa or atoi routine... assembly
is not the language to do that. Well; you _can_ of course;
just... atoi isn't a "little gremlin" at all.
For that matter; where do the "little gremlins" stop? I mean; all
you're
doing right now is calling the linux kernel. Aka: using the linux
kernel as a library. Where does "read" and "write" come from?
How far will you go before you're satisfied?
Most ironically of all is probably the fact that none of your assembly
code would work without the C code that built the Linux kernel.
--Dragontamer
.
- Follow-Ups:
- Re: Question about jumps
- From: Frank Kotler
- Re: Question about jumps
- From: Betov
- Re: Question about jumps
- References:
- Question about jumps
- From: Markus Pitha
- Re: Question about jumps
- From: Evenbit
- Re: Question about jumps
- From: Markus Pitha
- Re: Question about jumps
- From: randyhyde@xxxxxxxxxxxxx
- Re: Question about jumps
- From: Markus Pitha
- Question about jumps
- Prev by Date: Re: Displaying string
- Next by Date: Re: Question about jumps
- Previous by thread: Re: Question about jumps
- Next by thread: Re: Question about jumps
- Index(es):