9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "andrey mirtchovski" <mirtchovski@gmail.com>
To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu>
Subject: Re: [9fans] Arithmetic on Plan 9
Date: Wed, 25 Jul 2007 10:25:28 -0600	[thread overview]
Message-ID: <14ec7b180707250925r27e6b8f1vdc53a2dc4430432f@mail.gmail.com> (raw)
In-Reply-To: <20070725155155.GA2324@polynum.com>

i may not be qualified to answer all those questions for you, but i'll
try my best. i was dealing with FP exceptions last week and
consequently may have some of the answers:

> 1) Is there a Plan 9 policy concerning the "notes" (exceptions) on
> arithmetic operations, both integer and float?

i don't think there's anything about integers, but float exception
behaviour can be controlled via the getfcr/setfcr routines described
in getfcr(2). that man page will also tell you how to figure out
whether a particular machine supports those.

in my particular case the code I was porting defined NaN as a constant
and threw an exception whenever it ran. one particular quirk that i
observed was that an exception was thrown regardless of whether I
defined a silent or a non-silent NaN... my "solution" was simply to
turn off FPINVAL via setfcr(). if you're porting via ape, as i was
doing, the best solution is to get the little bits of assembly that
constitute the *fcr routines, compile them with 8a and link them
against the

> 2) Concerning float, if the FPU is a (from the ISA point of
> view) separate entity, are registers put in a known state on process
> entry?

yes. here are the floating point registers of a brand spanking new process:

parr% acid /bin/links
/bin/links:386 plan 9 executable

/sys/lib/acid/port
/sys/lib/acid/386
acid: new()
18031: system call	_main	SUBL	$0xc,SP
18031: breakpoint	main+0x3	MOVL	$_IO_stream+0x40(SB),AX
acid: fpr()
F0	0
F1	0
F2	0
F3	0
F4	0
F5	0
F6	0
F7	0
control	0x0000
status	0x0000
tag	0x0000
ip offset	0x00000000
cs selector	0x0000
opcode	0x81f3
data operand offset	0x0000
operand selector	0x0000


> 3) Is there some high level arithmetic homogeneous behavior between
> machines---a IEEE754 behavior even on machines lacking a compliant FPU,
> or lacking a FPU?

i believe the answer is No.

> 4) Is there a way, via C, to handle extended precision on IEEE754, or is
> assembly required (even if the assembler does not provide directly the
> symbolic opcodes, embedding directly the values is possible)?
>


not sure if that's what you're asking exactly, but from getfcr(2):

          Precision is
          controlled by installing in fcr, under mask FPPMASK, one of
          the values FPPEXT (extended precision), FPPSGL (single pre-
          cision), and FPPDBL (double precision).

hope that helps.


  parent reply	other threads:[~2007-07-25 16:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-25 15:51 tlaronde
2007-07-25 15:57 ` [9fans] " tlaronde
2007-07-25 16:25 ` andrey mirtchovski [this message]
2007-07-25 18:22   ` [9fans] " tlaronde
2007-07-25 22:52   ` tlaronde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14ec7b180707250925r27e6b8f1vdc53a2dc4430432f@mail.gmail.com \
    --to=mirtchovski@gmail.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).