Philip Guenther escribis:
On Thu, Jul 24, 2008 at 5:55 PM, Jesus Sanchez <[EMAIL PROTECTED]> wrote:
I'm trying to learn some about x86 assembly language
for instrucctional purpose. I'm really a noob in this
things so I want to learn from the "dumb" point.

Perhaps you should bite off the task in smaller chunks.  There are a
bunch of things involved in process startup that you don't really need
to understand initially, much less work out from scratch when you're
still learning the instruction set.  Most people learn to swim in the
shallow end of swimming pools, instead of while trying to cross a
large river.
I would like to learn x86 assembly from the point of view of PCspim
(Xspim on *nix)
to the MIPS arch. Not to make usefull things, just to understand the
machine,
with spim (an emulator) you have a view of the registers, a debugger and
a very
very close point of view of what the machine is doing. I would like to
do something
similar with mi i386 machine, 'as' and 'ld'.

Every example I've found on the net doesn't works
for me. I only want to make a very very simple runnable
program with only a few "practical" instrucctions (something
like "put the eax register to 0x000000000) and things like
that, but I don't know how the OpenBSD kernel runs binary code
so everithing the shells returns to me is "fu** you noob" similar
messages, cause i'm not sending the right flags to "ld" and "as".

It's not clear (to me) what your goal is.

If you're just trying to learn the x86 instruction set, then why not
put your code in an __asm__() block inside a C program?  That lets the
compiler do all the heavy lifting.
I'm trying to do things without gcc at all. Just as (or nasm) and ld, so
inline
assembly isn't nice for me, only as last option to learn.
If you're trying to understand process startup, then you should start
by reading the output of "gcc -S", and maybe the ELF specification,
depending on what you're trying to learn.  Only after staring at that
should you start writing stuff.

As for invoking "as" and "ld", how about taking a look at what gcc
passes to "as" and "ld" when it invokes them when compiling a C
program?  'gcc' will show that when invoked with the -v option.
the ouput files of gcc -S are great, but still very complicated to me, I
want
to learn from a lower point. The ELF specification will be the next read.
On the gcc -v output, I saw a thing called "collect2" that I really
don't know
what does, I will research about it.

There is something critical I need to use to make my binary code
runnable on OpenBSD? I'm trying really simple things like put some
strings in memory and stuff like that, nothing hard to understand, not
even need to have a console text return.

The way I compile:

$ as --gstabs -o object.o source.s
$ ld -s -o program object.o

It's not just how you invoke 'as' and 'ld' but also what you put in
the assembly code.  For example, you need to include assembly
directives that tell 'as' that your code belongs in the text segment,
otherwise it won't be marked as executable when loaded into memory.
maybe that's the problem, my binary files aren't marked as runnable to
the shells.
After some basic research, 'objdump -s' seems to be a very nice tool for me.
I will try to apply some simple math algorithms to assembler code.

Thanks for your time.

Philip Guenther

Reply via email to