Re: How the DragonflyBSD developers solve problems that are not resolved by Assembly?

Matthew Dillon <[email protected]> Mon, 20 Oct 2014 20:41:54 -0700
Newsgroups gmane.os.dragonfly-bsd.kernel
Message-ID <CAOZ7CpDGG95FwhMFddXzR+PsOQYbNBpA-TpRfFe5ivvZToJ6yQ@mail.gmail.com>
Both FreeBSD and DragonFly developers in the past have simply use .byte
assembly directives to lay down opcodes with no assembly equivalents.  For
example, in asmacros.h there is:

#define NON_GPROF_RET               .byte 0xc3

Which is used in assembly files for situations where the various RETs have
been #defined to be other things for profiling.

This is a last resort usually.  It has been used for a few floating point
ops here and there in the past, and ultimately the assembly gains the
needed opcodes and they can be replaced with the proper name.  I don't
think there is a whole lot of it in the current code bases.

-Matt

On Mon, Oct 20, 2014 at 4:10 PM, françai s <[email protected]> wrote:

> I think that the only case where you have to resort to writing binary
> code manually
> is when the assembler cannot output the desired code for some reason.
> If I recall correctly, there is only one such case in the HelenOS
> sources:
>
>
> http://trac.helenos.org/browser/mainline/kernel/arch/mips32/include/debug.h?rev=mainline%2C1446.3.1
>
> Here they manually encode the opcodes of five special debugging
> instructions for the MSIM MIPS simulator (these instructions are not
> part of the standard MIPS ISA, thus the assembler does not know them).
>
> But the developers of FreeBSD not write binary code manually.
>
> How the DragonflyBSD developers solve problems that are not resolved
> by Assembly?
>