Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / fm / kernel / sparc / double.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: double.fth
4\
5\ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6\
7\ - Do no alter or remove copyright notices
8\
9\ - Redistribution and use of this software in source and binary forms, with
10\ or without modification, are permitted provided that the following
11\ conditions are met:
12\
13\ - Redistribution of source code must retain the above copyright notice,
14\ this list of conditions and the following disclaimer.
15\
16\ - Redistribution in binary form must reproduce the above copyright notice,
17\ this list of conditions and the following disclaimer in the
18\ documentation and/or other materials provided with the distribution.
19\
20\ Neither the name of Sun Microsystems, Inc. or the names of contributors
21\ may be used to endorse or promote products derived from this software
22\ without specific prior written permission.
23\
24\ This software is provided "AS IS," without a warranty of any kind.
25\ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
26\ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
27\ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
28\ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
29\ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
30\ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
31\ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
32\ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
33\ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
34\ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
35\ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
36\
37\ You acknowledge that this software is not designed, licensed or
38\ intended for use in the design, construction, operation or maintenance of
39\ any nuclear facility.
40\
41\ ========== Copyright Header End ============================================
42id: @(#)double.fth 1.3 04/02/02 10:01:53
43purpose:
44copyright: Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved
45copyright: Copyright 1985-1994 Bradley Forthware
46copyright: Use is subject to license terms.
47
48code (dlit) ( -- d )
49 tos sp push
50 \t16 ip 0 tos lduh
51 \t16 tos d# 16 tos slln ip 2 scr lduh tos scr tos add
5264\ \t16 tos d# 16 tos sllx ip 4 scr lduh tos scr tos add
5364\ \t16 tos d# 16 tos sllx ip 6 scr lduh tos scr tos add
54 \t32 ip tos lget
5564\ \t32 tos d# 32 tos sllx ip /l scr ld tos scr tos add
56 ip ainc
57 tos sp push
58 \t16 ip 0 tos lduh
59 \t16 tos d# 16 tos slln ip 2 scr lduh tos scr tos add
6064\ \t16 tos d# 16 tos sllx ip 4 scr lduh tos scr tos add
6164\ \t16 tos d# 16 tos sllx ip 6 scr lduh tos scr tos add
62 \t32 ip tos lget
6364\ \t32 tos d# 32 tos sllx ip /l scr ld tos scr tos add
64 ip ainc
65c;
66
67\ Double-precision arithmetic
68code dnegate ( d# -- d#' )
69( 0 L: ) mloclabel dneg1
70 sp 0 scr nget
71 %g0 scr scr subcc
72 %g0 tos tos subx
73 scr sp 0 nput
74c;
75
76code dabs ( dbl.lo dbl.hi -- dbl.lo' dbl.hi' )
77 tos %g0 %g0 subcc
78 ( 0 B: ) dneg1 0< brif
79 nop
80c;
81
82\ Words that need to be defined in high-level belong in fm/kernel/double.fth
83\ : dmax ( d1 d2 -- d3 ) 2over 2over d- nip 0< if 2swap then 2drop ;
84
85code d+ ( x1 x2 -- x3 )
86 sp 0 /n* sc1 nget \ x2.low
87 sp 2 /n* sc3 nget \ x1.low
88 sp 1 /n* sc2 nget \ x1.high
89 sp 2 /n* sp add \ Pop args
90 sc3 sc1 sc1 addcc \ x3.low
9132\ sc2 tos tos addx \ x3.high
9264\ sc2 tos tos add \ x3.high
9364\ u>= if annul tos 1 tos add
9464\ then
95 sc1 sp 0 nput \ Push result (x3.high already in tos)
96c;
97code d- ( x1 x2 -- x3 )
98 sp 0 /n* sc1 nget \ x2.low
99 sp 2 /n* sc3 nget \ x1.low
100 sp 1 /n* sc2 nget \ x1.high
101 sp 2 /n* sp add \ Pop args
102 sc3 sc1 sc1 subcc \ x3.low
10332\ sc2 tos tos subx \ x3.high
10464\ sc2 tos tos sub \ x3.high
10564\ u>= if annul tos 1 tos sub
10664\ then
107 sc1 sp 0 nput \ Push result (x3.high already in tos)
108c;