xref: /illumos-gate/usr/src/cmd/eqn/over.c (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
1*779fc935Sceastha /*
2*779fc935Sceastha  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3*779fc935Sceastha  * Use is subject to license terms.
4*779fc935Sceastha  */
5*779fc935Sceastha 
67c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
77c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
87c478bd9Sstevel@tonic-gate 
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
117c478bd9Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
127c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
137c478bd9Sstevel@tonic-gate  */
147c478bd9Sstevel@tonic-gate 
157c478bd9Sstevel@tonic-gate #include "e.h"
167c478bd9Sstevel@tonic-gate 
17*779fc935Sceastha void
boverb(int p1,int p2)18*779fc935Sceastha boverb(int p1, int p2)
19*779fc935Sceastha {
207c478bd9Sstevel@tonic-gate 	int h, b, treg, d;
217c478bd9Sstevel@tonic-gate 
227c478bd9Sstevel@tonic-gate 	treg = oalloc();
237c478bd9Sstevel@tonic-gate 	yyval = p1;
247c478bd9Sstevel@tonic-gate #ifndef NEQN
257c478bd9Sstevel@tonic-gate 	d = VERT(EM(0.3, ps));
267c478bd9Sstevel@tonic-gate 	h = eht[p1] + eht[p2] + d;
27*779fc935Sceastha #else	/* NEQN */
287c478bd9Sstevel@tonic-gate 	d = VERT(1);
297c478bd9Sstevel@tonic-gate 	h = eht[p1] + eht[p2];
30*779fc935Sceastha #endif	/* NEQN */
317c478bd9Sstevel@tonic-gate 	b = eht[p2] - d;
32*779fc935Sceastha 	if (dbg)
33*779fc935Sceastha 		printf(".\tb:bob: S%d <- S%d over S%d; b=%d, h=%d\n",
347c478bd9Sstevel@tonic-gate 		    yyval, p1, p2, b, h);
357c478bd9Sstevel@tonic-gate 	nrwid(p1, ps, p1);
367c478bd9Sstevel@tonic-gate 	nrwid(p2, ps, p2);
377c478bd9Sstevel@tonic-gate 	printf(".nr %d \\n(%d\n", treg, p1);
387c478bd9Sstevel@tonic-gate 	printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, treg, treg, p2);
397c478bd9Sstevel@tonic-gate #ifndef NEQN
407c478bd9Sstevel@tonic-gate 	printf(".nr %d \\n(%d+\\s%d.5m\\s0\n", treg, treg, EFFPS(ps));
41*779fc935Sceastha #endif	/* NEQN */
427c478bd9Sstevel@tonic-gate 	printf(".ds %d \\v'%du'\\h'\\n(%du-\\n(%du/2u'\\*(%d\\\n",
437c478bd9Sstevel@tonic-gate 	    yyval, eht[p2]-ebase[p2]-d, treg, p2, p2);
447c478bd9Sstevel@tonic-gate #ifndef	NEQN
45*779fc935Sceastha 	printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\*(%d\\\n",
467c478bd9Sstevel@tonic-gate 	    p2, p1, -(eht[p2]-ebase[p2]+d+ebase[p1]), p1);
47*779fc935Sceastha 	printf("\\h'-\\n(%du-\\n(%du/2u+.1m'\\v'%du'\\l'\\n"
48*779fc935Sceastha 	    "(%du-.2m'\\h'.1m'\\v'%du'\n", treg, p1, ebase[p1]+d, treg, d);
49*779fc935Sceastha #else	/* NEQN */
50*779fc935Sceastha 	printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\*(%d\\\n",
517c478bd9Sstevel@tonic-gate 	    p2, p1, -eht[p2]+ebase[p2]-ebase[p1], p1);
527c478bd9Sstevel@tonic-gate 	printf("\\h'-\\n(%du-\\n(%du-2u/2u'\\v'%du'\\l'\\n(%du'\\v'%du'\n",
537c478bd9Sstevel@tonic-gate 	    treg, p1, ebase[p1], treg, d);
54*779fc935Sceastha #endif	/* NEQN */
557c478bd9Sstevel@tonic-gate 	ebase[yyval] = b;
567c478bd9Sstevel@tonic-gate 	eht[yyval] = h;
577c478bd9Sstevel@tonic-gate 	lfont[yyval] = rfont[yyval] = 0;
587c478bd9Sstevel@tonic-gate 	ofree(p2);
597c478bd9Sstevel@tonic-gate 	ofree(treg);
607c478bd9Sstevel@tonic-gate }
61