1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3<head>
4<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
5<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.0.0 for Windows">
6<META http-equiv="Content-Style-Type" content="text/css">
7<title>CP_SetDivImm*</title>
8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css">
9</head>
10<body>
11<h1 align="left">CP_SetDivImm* <img src="../../image/NTR.gif"align="middle"><img src="../../image/TWL.gif" align="middle"></H1>
12<H2>Syntax</H2>
13<dl>
14  <dd>
15<CODE>#include &lt;nitro/cp.h&gt;</CODE><BR>
16  <BR>
17  <CODE>void CP_SetDivImm32_32( u32 numer, u32 denom );<br>
18  void CP_SetDivImm64_32( u64 numer, u32 denom );<br>
19  void CP_SetDivImm64_64( u64 numer, u64 denom ); </CODE></dd>
20</dl>
21<h2>Arguments</h2>
22<TABLE border="1" width="100%">
23  <TBODY>
24    <TR>
25      <TD width="13%"><EM><STRONG>numer</STRONG></EM></TD>
26      <TD width="87%">Numerator of fraction. Represents dividend of division here.</TD>
27    </TR>
28    <TR>
29      <TD width="13%"><EM><STRONG>denom</STRONG></EM></TD>
30      <TD width="87%">Denominator of fraction. Represents divisor of division here.</TD>
31    </TR>
32  </TBODY>
33</TABLE>
34<h2>Return Values</h2>
35<p>None.</p>
36<H2>Description</H2>
37<P>Sets parameters for division. It does not set the division mode but  merely stores the dividend and the divisor in  registers. The three division modes are shown below.</P>
38<TABLE border="1">
39  <TBODY>
40    <TR>
41      <TH>Division Mode</TH>
42      <TH>Calculation</TH>
43      <TH>Results</TH>
44      <TH>Calculation Cycles</TH>
45      <TH>CPU Cycle Conversion</TH>
46    </TR>
47    <TR>
48      <TD>CP_DIV_32_32BIT_MODE</TD>
49      <TD>32-bit divided by 32-bit</TD>
50      <TD>Quotient 32-bit, remainder 32-bit</TD>
51      <TD>18 cycles</TD>
52      <TD>36 cycles</TD>
53    </TR>
54    <TR>
55      <TD>CP_DIV_64_32BIT_MODE</TD>
56      <TD>64-bit divided by 32-bit</TD>
57      <TD>Quotient 64-bit, remainder 32-bit</TD>
58      <TD>34 cycles</TD>
59      <TD>68 cycles</TD>
60    </TR>
61    <TR>
62      <TD>CP_DIV_64_64BIT_MODE</TD>
63      <TD>64-bit divided by 64-bit</TD>
64      <TD>Quotient 64-bit, remainder 64-bit</TD>
65      <TD>34 cycles</TD>
66      <TD>68 cycles</TD>
67    </TR>
68  </TBODY>
69</TABLE>
70<P><B>Caution:</B> With the divider, sometimes the value is overwritten in the interrupt. If the division parameters are set up and an interrupt occurs during division when a divider is used, the original calculated result will be broken. Therefore, if you are using the divider in an interrupt, the status of the divider needs to be temporarily stored and restored using <code><A href="../CP_SaveContext.html">CP_SaveContext()</A></code> and <code><A href="../CP_RestoreContext.html">CP_RestoreContext()</A></code>, respectively. Status of the divider is also automatically saved/restored when threads are switched.</FONT></B></P>
71<BLOCKQUOTE><BR>
72<TABLE border="1">
73  <TBODY>
74    <TR>
75      <TD style="background-color : #eeeeee;"><B>Example:</B> Restore the status of the divider.<BR>
76      <BR>
77<PRE>intr_func( void )
78{
79  CPContext context;
80
81  CP_SaveContext( &amp;context );
82  CP_SetDiv32_32( 1000, 5 );
83  CP_WaitDiv();
84  result = CP_GetDivResult();
85  CP_RestoreContext( &amp;context );
86}</PRE></TD>
87    </TR>
88  </TBODY>
89</TABLE>
90</BLOCKQUOTE>
91<h2>Internal Operation</h2>
92<p>Stores values in <CODE>DIV_NUMER(0x4000290)</CODE> and <CODE>DIV_DENOM(0x4000298)</CODE> of the IO register.</p>
93<h2>See Also</h2>
94<p><A href="CP_SetDiv.html"><CODE>CP_SetDiv*</CODE></A>, <A href="CP_IsDivBusy.html"><CODE>CP_IsDivBusy</CODE></A>, <A href="CP_WaitDiv.html"><CODE>CP_WaitDiv</CODE></A>, <A href="CP_GetDivResult.html"><CODE>CP_GetDivResult*</CODE></A>, <A href="CP_GetDivRemainder.html"><CODE>CP_GetDivRemainder*</CODE></A><br></CODE></p>
95<H2>Revision History</H2>
96<P>2006/08/09 Added a note regarding use inside interrupts.<BR>2004/11/02 Corrected the IO register address used for internal operations.<BR> 2004/01/09 Added content.<BR> 2003/12/01 Initial version.</P>
97<hr><p>CONFIDENTIAL</p></body>
98</html>
99