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.


> 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.

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.


> 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.


Philip Guenther

Reply via email to