Rev Author Line No. Line
4985 kaklik 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <title> words/umslashmod.asm </title>
6 <meta name="keywords" content="amforth programming language Forth ATmega ATMEL">
7 <meta name="description" content="amforth - laguage Forth for ATMEL ATmega">
8 <!-- AUTOINCLUDE START "Page/Head.en.ihtml" DO NOT REMOVE -->
9 <link rel="StyleSheet" href="../../../../Web/CSS/MLAB.css" type="text/css" title="MLAB Basic Style">
10 <link rel="StyleSheet" href="../../../../Web/CSS/MLAB_Print.css" type="text/css" media="print">
11 <link rel="shortcut icon" type="image/x-icon" href="../../../../Web/PIC/MLAB.ico">
12 <script type="text/javascript" src="../../../../Web/JS/MLAB_Menu.js"></script>
13 <!-- AUTOINCLUDE END -->
14 </head>
15  
16 <body lang="en">
17  
18 <!-- AUTOINCLUDE START "Page/Header.en.ihtml" DO NOT REMOVE -->
19 <!-- ============== HEADER ============== -->
20 <div class="Header">
21 <script type="text/javascript">
22 <!--
23 SetRelativePath("../../../../");
24 DrawHeader();
25 // -->
26 </script>
27 <noscript>
28 <p><b> JavaScript is required for including of the header </b></p>
29 </noscript>
30 </div>
31 <!-- AUTOINCLUDE END -->
32  
33 <!-- AUTOINCLUDE START "Page/Menu.en.ihtml" DO NOT REMOVE -->
34 <!-- ============== MENU ============== -->
35 <div class="Menu">
36 <script type="text/javascript">
37 <!--
38 SetRelativePath("../../../../");
39 DrawMenu();
40 // -->
41 </script>
42 <noscript>
43 <p><b> JavaScript is required for including of the menu </b><p>
44 </noscript>
45 </div>
46 <!-- AUTOINCLUDE END -->
47  
48 <!-- ============== TEXT ============== -->
49 <div class="Text">
50  
51 <h1> words/umslashmod.asm </h1>
52  
53 <p>
54 <input type=button onClick="history.back()" value="Back">
55 <input type=button onClick="history.forward()" value="Forward">
56 <a href="../WordList.en.html">Jump to Vocabulary</a>
57 </p>
58  
59 <pre>
60 ; ( ud u2 -- rem quot) Arithmetics
61 ; R( -- )
62 ; unsigned division ud / u2 with remainder
63 VE_UMSLASHMOD:
64 .db $06, &quot;um/mod&quot;,0
65 .dw VE_HEAD
66 .set VE_HEAD = VE_UMSLASHMOD
67 XT_UMSLASHMOD:
68 .dw PFA_UMSLASHMOD
69 PFA_UMSLASHMOD:
70 movw temp4, tosl
71  
72 ld temp0, Y+
73 ld temp1, Y+
74 ld temp2, Y+
75 ld temp3, Y+
76  
77 ;; unsigned 32/16 -&gt; 16r16 divide
78  
79 PFA_UMSLASHMODmod:
80  
81 ; set loop counter
82 ldi temp6,$10
83  
84 PFA_UMSLASHMODmod_loop:
85 ; shift left, saving high bit
86 clr temp7
87 lsl temp0
88 rol temp1
89 rol temp2
90 rol temp3
91 rol temp7
92  
93 ; try subtracting divisor
94 cp temp2, temp4
95 cpc temp3, temp5
96 cpc temp7,zerol
97  
98 brcs PFA_UMSLASHMODmod_loop_control
99  
100 PFA_UMSLASHMODmod_subtract:
101 ; dividend is large enough
102 ; do the subtraction for real
103 ; and set lowest bit
104 inc temp0
105 sub temp2, temp4
106 sbc temp3, temp5
107  
108 PFA_UMSLASHMODmod_loop_control:
109 dec temp6
110 brne PFA_UMSLASHMODmod_loop
111  
112 PFA_UMSLASHMODmod_done:
113 ; put remainder on stack
114 st -Y,temp3
115 st -Y,temp2
116  
117 ; put quotient on stack
118 movw tosl, temp0
119 jmp DO_NEXT
120 </pre>
121  
122 <p>
123 <input type=button onClick="history.back()" value="Back">
124 <input type=button onClick="history.forward()" value="Forward">
125 <a href="../WordList.en.html">Jump to Vocabulary</a>
126 </p>
127  
128 </div>
129  
130 <!-- AUTOINCLUDE START "Page/Footer.en.ihtml" DO NOT REMOVE -->
131 <!-- ============== FOOTER ============== -->
132 <div class="Footer">
133 <script type="text/javascript">
134 <!--
135 SetRelativePath("../../../../");
136 DrawFooter();
137 // -->
138 </script>
139 <noscript>
140 <p><b> JavaScript is required for including of the footer </b></p>
141 </noscript>
142 </div>
143 <!-- AUTOINCLUDE END -->
144  
145 </body>
146 </html>