|
|
Up |
|
|
  |
Author: Joel SalomonJoel Salomon Date: Feb 20, 2007 15:56
My system doesn’t seem to like it when I call NaN(2):
cpu%% cat tnan.c
#include
#include
void
main(int, char**)
{
double d = NaN();
print("d = %%f\n", d);
exits(0);
}
cpu%% 8c -FVw tnan.c
cpu%% 8l tnan.8
cpu%% 8.out
8.out 55798: suicide: sys: fp: invalid operation fppc=0x10a4 status=0x8081 pc=0x00001028
cpu%% acid 55798
/proc/55798/text:386 plan 9 executable
|
| Show full article (0.75Kb) |
|
| | 8 Comments |
|
  |
Author: Joel C. SalomonJoel C. Salomon Date: Feb 20, 2007 16:00
On 2/20/07, Joel Salomon gmail.com> wrote:
> My system doesn't seem to like it when I call NaN(2):
A simpler test case:
#include
#include
void
main(int, char**)
{
NaN(); // ☹
exits(0);
}
--Joel
|
| |
|
| | 6 Comments |
|
  |
Author: Joel SalomonJoel Salomon Date: Feb 20, 2007 16:21
Playing with acid a bit:
cpu%% cat tnan.c
#include
#include
void
main(int, char**)
{
NaN(); // ☹
exits(0);
}
cpu%% 8c -FTVw tnan.c
cpu%% 8l -o tnan tnan.8
cpu%% tnan
tnan 55986: suicide: sys: fp: invalid operation fppc=0x108d status=0x8081 pc=0x00001028
cpu%% acid -l acme 55986
/proc/55986/text:386 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/acme
/sys/lib/acid/386
acid: stk()
At pc:0x00001028:main+0x8 /usr/chesky/src/hak/lex/tnan.c:7
main()
called from _main+0x31 /sys/src/libc/386/main9.s:16
acid: regs()...
|
| Show full article (1.79Kb) |
| 5 Comments |
|
  |
Author: erik quanstromerik quanstrom Date: Feb 20, 2007 17:12
fwiw, i think the gas construction syntax is this:
dd 44 24 04 fldl 0x04(%%esp,1)
this might be an alignment problem. but that's a wild guess.
you could rewrite NaN in assembler and adjust the stack frame
by hand.
you need a processor manual.
- erik
|
| |
| 4 Comments |
|
  |
Author: Joel SalomonJoel Salomon Date: Feb 20, 2007 18:35
> this might be an alignment problem. but that's a wild guess.
I think not:
acid: SP
0x00000044
> you could rewrite NaN in assembler and adjust the stack frame
> by hand.
I could. It’s just hard to believe I’m the first to run across this
problem with NaN(2).
> you need a processor manual.
Have a few at home. Trouble is, I’m at school now.
> fwiw, i think the gas construction syntax is this:
>
> dd 44 24 04 fldl 0x04(%%esp,1)
FLD, got it. I’m trying to get acid to dump the hex bytes of the
FMOVD instruction so I can confirm that these are the same, but I’m not finding it in the manual.
--Joel
|
| |
| 3 Comments |
|
  |
Author: erik quanstromerik quanstrom Date: Feb 20, 2007 20:23
after a bit of actual thought, i think that NaN
is supposed to generate a note. if you do catch
the note, the program should work fine.
e.g.
#include
#include
void
note(void *, char *s)
{
if(strncmp(s, "sys: fp: ", 8) == 0)
noted(NCONT);
noted(NDFLT);
}
void
main(void)
{
double d;
|
| Show full article (0.37Kb) |
| 2 Comments |
|
  |
Author: Joel C. SalomonJoel C. Salomon Date: Feb 20, 2007 20:37
On 2/20/07, erik quanstrom coraid.com> wrote:
> after a bit of actual thought, i think that NaN
> is supposed to generate a note. if you do catch
> the note, the program should work fine.
This is distinct from sNaN/qNaN, right?
--Joel
|
| |
| no comments |
|
  |
Author: Joel C. SalomonJoel C. Salomon Date: Feb 20, 2007 21:19
On 2/20/07, erik quanstrom coraid.com> wrote:
> after a bit of actual thought, i think that NaN
> is supposed to generate a note. if you do catch
> the note, the program should work fine.
That was it; thanks.
--Joel
|
| |
| no comments |
|
  |
|
|
  |
Author: Russ CoxRuss Cox Date: Feb 20, 2007 21:51
On 2/20/07, Joel Salomon gmail.com> wrote:
> My system doesn't seem to like it when I call NaN(2):
That is the default behavior. See getfcr(2). In particular,
if you add
setfcr(getfcr()&~FPINVAL);
to your program then you can carry NaNs around willy-nilly
without causing exceptions.
On 2/20/07, Joel Salomon gmail.com> wrote:
>> this might be an alignment problem. but that's a wild guess.
>
> I think not:
> acid: SP
> 0x00000044
This tells you that SP's "address" is 0x44. (The registers appear to
have memory addresses starting at 0 in acid.) If you want to find
out what SP is, you have to dereference it, as in *SP.
|
| Show full article (0.94Kb) |
| no comments |
|
|