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/number.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/number.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 ; (addr -- n ) Numeric IO
61 ; R( -- )
62 ; convert a word to a number, throw exception -1 on error
63 VE_NUMBER:
64 .db $06, &quot;number&quot;,0
65 .dw VE_HEAD
66 .set VE_HEAD = VE_NUMBER
67 XT_NUMBER:
68 .dw DO_COLON
69 PFA_NUMBER:
70 ; sign flag
71 .dw XT_DOLITERAL
72 .dw 1 ; ( -- addr 1)
73 .dw XT_ZERO ; ( -- addr 1 0)
74 .dw XT_ROT ; ( -- 1 0 addr)
75 .dw XT_COUNT ; ( -- 1 0 addr' len)
76 .dw XT_ZERO
77 .dw XT_DODO
78 .dw PFA_NUMBER6
79 PFA_NUMBER1: ; ( n addr -- )
80 .dw XT_DUP
81 .dw XT_I
82 .dw XT_PLUS
83 .dw XT_CFETCH
84 ; now check for +/- signs
85 .dw XT_DUP
86 .dw XT_DOLITERAL
87 .dw $2d ; '-'
88 .dw XT_EQUAL
89 .dw XT_DOCONDBRANCH
90 .dw PFA_NUMBER2
91 .dw XT_DROP
92 ; replace the sign flag
93 .dw XT_ROT
94 .dw XT_DROP
95 .dw XT_DOLITERAL
96 .dw -1
97 .dw XT_ROT
98 .dw XT_ROT
99 .dw XT_DOBRANCH
100 .dw PFA_NUMBER4
101 PFA_NUMBER2:
102 .dw XT_BASE
103 .dw XT_FETCH
104 .dw XT_DIGIT
105 .dw XT_EQUALZERO
106 ; check for non number characters and stop converting if found
107 .dw XT_DOCONDBRANCH
108 .dw PFA_NUMBER3
109 .dw XT_DOLITERAL
110 .dw -13
111 .dw XT_THROW
112 PFA_NUMBER3:
113 .dw XT_ROT
114 .dw XT_BASE
115 .dw XT_FETCH
116 .dw XT_MUL
117 .dw XT_PLUS
118 .dw XT_SWAP
119 PFA_NUMBER4:
120 .dw XT_DOLOOP
121 .dw PFA_NUMBER1
122 PFA_NUMBER6:
123 .dw XT_DROP
124 ; incorporate sign into number
125 .dw XT_SWAP
126 .dw XT_LESSZERO
127 .dw XT_DOCONDBRANCH
128 .dw PFA_NUMBER5
129 .dw XT_NEGATE
130 PFA_NUMBER5:
131 .dw XT_EXIT
132 </pre>
133  
134 <p>
135 <input type=button onClick="history.back()" value="Back">
136 <input type=button onClick="history.forward()" value="Forward">
137 <a href="../WordList.en.html">Jump to Vocabulary</a>
138 </p>
139  
140 </div>
141  
142 <!-- AUTOINCLUDE START "Page/Footer.en.ihtml" DO NOT REMOVE -->
143 <!-- ============== FOOTER ============== -->
144 <div class="Footer">
145 <script type="text/javascript">
146 <!--
147 SetRelativePath("../../../../");
148 DrawFooter();
149 // -->
150 </script>
151 <noscript>
152 <p><b> JavaScript is required for including of the footer </b></p>
153 </noscript>
154 </div>
155 <!-- AUTOINCLUDE END -->
156  
157 </body>
158 </html>