Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Nov 2014 12:33:33 -0200
From:      =?UTF-8?Q?fran=C3=A7ai_s?= <romapera15@gmail.com>
To:        freebsd-emulation@freebsd.org
Subject:   This topic is mainly for developers of FreeBSD that develop in machine code, until even in binary code.
Message-ID:  <CAK_6RweXftPPitkRmOkZQOYvaKrA1FNrfpgqcJLidwgATmZFGA@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
This subject is irresistible to me,I like so much of this issue that get
out tears out of my eyes.

This topic is mainly for developers of FreeBSD that develop in machine
code, until even in binary code.

A FreeBSD developer told me via private message that the  the most FreeBSD
developers don=E2=80=99t develop in machine code, in other words, the  mino=
rity
FreeBSD developers develop in machine code, until even in binary code.

He told me this:

"We either create a macro expands to something like ".word <foo> =E2=80=9C =
or
sometimes the .word <foo> is just hard coded inline when there=E2=80=99s on=
ly going
to be one of them. Sometimes we expose them both in assembly and in C code,
in which case what we do varies a bit to accommodate the different
language=E2=80=99s syntax. It is rare, but has happened, that we only expos=
e it to
C code.

Generally, though, we try to add support for the opcodes to gas so that we
get the constraint testing it does (making sure the opcode is supported at
the level you are compiling, making sure it isn=E2=80=99t in a delay slot o=
r
violating some other precondition for its use)."

"You pointed me at macros that defined operations in terms of opcodes the
assembler didn=E2=80=99t understand with the workaround being the assembler
directive using .word followed by by some hex value to encode the opcode."

"Most developers of FreeBSD don=E2=80=99t  write directly in machine code i=
n
FreeBSD development, and don=E2=80=99t care. Some developers use the marcos=
 that I
described sometimes when doing specific, low-level coding. A handful of
developers create the marcos directly or use the .word directives in their
work to make certain things work that cannot work otherwise.

People generally don=E2=80=99t write in raw machine opcodes. That is indepe=
ndent of
FreeBSD.

However, a few, specialized people will find the need to do it from time to
time. Usually because they are porting FreeBSD to a newer processor that
needs newer opcodes to do context switching, optimize interrupt handling,
code with a new type of cache coherency, etc. These people look up the
assembler in the docs from the vendor and then create the .word workaround
to make sure things work. If they have the time, they may add it to our
somewhat ancient gas assembler as well."

"Almost nobody writes directly in binary. There are some exceptions,
sometimes though."

The following link leads to tutorial that teaches programming Assembly in
to FreeBSD:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/x86.ht=
ml

Also exist tutorial that teaches programming in machine code to FreeBSD?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAK_6RweXftPPitkRmOkZQOYvaKrA1FNrfpgqcJLidwgATmZFGA>