Date: Mon, 13 Oct 2014 08:54:37 -0600 From: Warner Losh <imp@bsdimp.com> To: =?iso-8859-1?Q?fran=E7ai_s?= <romapera15@gmail.com> Cc: freebsd-drivers@freebsd.org Subject: Re: How the FreeBSD developers solve problems that are not resolved by Assembly? Message-ID: <A05B87BF-7A27-4270-BBA8-8EB6567682B8@bsdimp.com> In-Reply-To: <CAK_6RwcXLDFfDMWn%2BA%2Bjcap3C8jV=G7ZWfY9cr-9mv5h3z4=og@mail.gmail.com> References: <CAK_6RwcXLDFfDMWn%2BA%2Bjcap3C8jV=G7ZWfY9cr-9mv5h3z4=og@mail.gmail.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] On Oct 13, 2014, at 6:50 AM, françai s <romapera15@gmail.com> 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 FreeBSD developers solve problems that are not resolved by Assembly? More or less the same way. We either create a macro expands to something like ".word <foo> “ or sometimes the .word <foo> is just hard coded inline when there’s only 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’s syntax. It is rare, but has happened, that we only expose 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’t in a delay slot or violating some other precondition for its use). Warner [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJUO+etAAoJEGwc0Sh9sBEA5/sQAKiV+3YkNVc3qxPKoFo6RqBC KEd6f38YKBTA4DrqwZ1AsU7Y8/U66lsyYKFXkWvmLhE+eqV0pvquXBQ3+AN+eDRN Rjsb4kMKgkp5x3FqA6lW+yS9Z+Z8UucbBXfbv4TGjY8qZ1jW/Xx8L08sAmCXtde0 bfpVqlipR7hlfXtSycVtqDB4Si92RdclRPqmH6AFn5/yP6ZbQ1SR0cwzMn/mEupc Hsxe8TC1cepPI5brnRNkr55jZJsbi51y/+AFD0GZN80WmgJRAkJikd8pyc5hunTB z4TEI8/bYHRQ0uRmS1ElBLPo94xwSaxsdkgdqdVRQbh831c09oxQwU+Ayc1MkEqH UHXNRocjzDnnM0dk/xfeBzNCpk3c4slxZgQytNOW/rgPDnCNL7LuZh5Yz/rKARU9 mupbtSCVpO4scAG4tJHoV0NpMo6PUo6qZvnbm8Q0Q9jEm9T9L2ytfGRojxG+vOdX 8KEEeP4zf7butECHH+aawpi0TMTwB6wBB619hqdeh8RDjcQDYc8fY+UxWXJMjCO8 dWFELzwzjZr9KEdzz7BfNk7yxJg2xPSYUzvdzWt5l9wSediC9kFtrdrna68EO2e3 LhQaHqxXzzVx0viur2K8yM47ojwXBdMoFLHSHNtR5qvYukbn0nT0BKlGwakMwyK1 ncTDcj2O5w2Y5aHFPKpe =C24h -----END PGP SIGNATURE-----help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?A05B87BF-7A27-4270-BBA8-8EB6567682B8>
