* [9fans] acid - i386 floating point register issue ?
@ 2007-01-05 20:34 Philip Dye
2007-01-05 22:21 ` Russ Cox
0 siblings, 1 reply; 2+ messages in thread
From: Philip Dye @ 2007-01-05 20:34 UTC (permalink / raw)
To: 9fans
On an i386, I am unable to get acid to properly report the values in the
floating point registers.
Could someone please explain what I am doing wrong ?
Thank you,
Philip Dye
- - - - -
Simple example:
#include <u.h>
#include <libc.h>
void main ( void )
{
double x ;
x = atof("3.5") ;
print("===== main x = %g\n",x) ;
exits(nil) ;
}
Use:
example : acid 8.out
8.out:386 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/386
acid: new()
7118: system call _main SUBL $0x48,SP
7118: breakpoint main+0x3 MOVL $.string(SB),AX
acid: asm(main)
main 0x00001020 SUBL $0x1c,SP
main+0x3 0x00001023 MOVL $.string(SB),AX
main+0x8 0x00001028 MOVL AX,0x0(SP)
main+0xb 0x0000102b CALL atof(SB)
main+0x10 0x00001030 FMOVDP F0,x+0x14(SP)
main+0x14 0x00001034 MOVL $.string+0x4(SB),AX
main+0x19 0x00001039 MOVL AX,0x0(SP)
main+0x1c 0x0000103c FMOVD x+0x14(SP),F0
main+0x20 0x00001040 FMOVDP F0,0x4(SP)
main+0x24 0x00001044 CALL print(SB)
main+0x29 0x00001049 ADDL $0x1c,SP
main+0x2c 0x0000104c RET
_main 0x0000104d SUBL $0x48,SP
acid: bpset(main+0x10)
acid: cont()
7118: breakpoint main+0x10 FMOVDP F0,x+0x14(SP)
acid: fpr()
F0 0.
F1 0.
F2 0.
F3 0.
F4 0.
F5 0.
F6 0.
F7 0.
control 0x0272
status 0x3900
tag 0x3fff
ip offset 0x00001743
cs selector 0x0023
opcode 0xe907
data operand offset 0xeee8
operand selector 0x001b
acid: print("===== ACID F0 = ",*(F0\F),"\n")
===== ACID F0 = 0
acid: cont()
===== main x = 3.5
7118: breakpoint main+0x14 MOVL $.string+0x4(SB),AX
<stdin>:9: (error) msg: pid=7118 startstop: process exited
- - - - -
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [9fans] acid - i386 floating point register issue ?
2007-01-05 20:34 [9fans] acid - i386 floating point register issue ? Philip Dye
@ 2007-01-05 22:21 ` Russ Cox
0 siblings, 0 replies; 2+ messages in thread
From: Russ Cox @ 2007-01-05 22:21 UTC (permalink / raw)
To: philip.dye, Fans of the OS Plan 9 from Bell Labs
> On an i386, I am unable to get acid to properly report the values in the
> floating point registers.
>
> Could someone please explain what I am doing wrong ?
You are doing nothing wrong (or at least almost nothing).
As for the rest of the system:
- libmach has the wrong size for the 386 floating point register file.
- libmach has the addresses of the floating point registers backward
(i.e., F0 and F7 swapped, F1 and F6 swapped, etc.)
- /sys/lib/acid/386's fpr() is trying to format the registers as fmt 'g',
whatever that means, when in fact it should be using '3',
which means the 80-bit little endian IEEE floating point.
in fact, fpr shouldn't say a format at all, since the floating
point registers already have the right format by default.
- acid implements the '3' format but does not recognize it in
acid programs (e.g., as fmt(x, '3') or x\3.
All these problems are now fixed on sources.
So your typescript should have said *(F0\3) or just *F0,
but was otherwise correct:
% acid 8.out
8.out:386 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/386
/usr/rsc/lib/acid
acid: new()
1252595: system call _main SUBL $0x48,SP
1252595: breakpoint main+0x3 MOVL $.string(SB),AX
acid: bpset(main+0x10)
acid: cont()
1252595: breakpoint main+0x10 FMOVDP F0,x+0x14(SP)
acid: *F0
3.5
acid: fpr()
F0 3.5
F1 0
F2 0
F3 0
F4 0
F5 0
F6 -183.464
F7 0
control 0x0272
status 0x3900
tag 0x3fff
ip offset 0x0000174f
cs selector 0x0023
opcode 0xe907
data operand offset 0xeee8
operand selector 0x001b
acid:
Russ
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-01-05 22:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-05 20:34 [9fans] acid - i386 floating point register issue ? Philip Dye
2007-01-05 22:21 ` Russ Cox
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).