398
|
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
|
|
2 <HTML
|
|
3 ><HEAD
|
|
4 ><TITLE
|
|
5 >Numbers and Expressions</TITLE
|
|
6 ><META
|
|
7 NAME="GENERATOR"
|
|
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
|
|
9 REL="HOME"
|
|
10 TITLE="LW Tool Chain"
|
|
11 HREF="index.html"><LINK
|
|
12 REL="UP"
|
|
13 TITLE="LWASM"
|
|
14 HREF="c43.html"><LINK
|
|
15 REL="PREVIOUS"
|
|
16 TITLE="Symbols"
|
|
17 HREF="x169.html"><LINK
|
|
18 REL="NEXT"
|
|
19 TITLE="Assembler Directives"
|
|
20 HREF="x182.html"></HEAD
|
|
21 ><BODY
|
|
22 CLASS="SECTION"
|
|
23 BGCOLOR="#FFFFFF"
|
|
24 TEXT="#000000"
|
|
25 LINK="#0000FF"
|
|
26 VLINK="#840084"
|
|
27 ALINK="#0000FF"
|
|
28 ><DIV
|
|
29 CLASS="NAVHEADER"
|
|
30 ><TABLE
|
|
31 SUMMARY="Header navigation table"
|
|
32 WIDTH="100%"
|
|
33 BORDER="0"
|
|
34 CELLPADDING="0"
|
|
35 CELLSPACING="0"
|
|
36 ><TR
|
|
37 ><TH
|
|
38 COLSPAN="3"
|
|
39 ALIGN="center"
|
|
40 >LW Tool Chain</TH
|
|
41 ></TR
|
|
42 ><TR
|
|
43 ><TD
|
|
44 WIDTH="10%"
|
|
45 ALIGN="left"
|
|
46 VALIGN="bottom"
|
|
47 ><A
|
|
48 HREF="x169.html"
|
|
49 ACCESSKEY="P"
|
|
50 >Prev</A
|
|
51 ></TD
|
|
52 ><TD
|
|
53 WIDTH="80%"
|
|
54 ALIGN="center"
|
|
55 VALIGN="bottom"
|
|
56 >Chapter 3. LWASM</TD
|
|
57 ><TD
|
|
58 WIDTH="10%"
|
|
59 ALIGN="right"
|
|
60 VALIGN="bottom"
|
|
61 ><A
|
|
62 HREF="x182.html"
|
|
63 ACCESSKEY="N"
|
|
64 >Next</A
|
|
65 ></TD
|
|
66 ></TR
|
|
67 ></TABLE
|
|
68 ><HR
|
|
69 ALIGN="LEFT"
|
|
70 WIDTH="100%"></DIV
|
|
71 ><DIV
|
|
72 CLASS="SECTION"
|
|
73 ><H1
|
|
74 CLASS="SECTION"
|
|
75 ><A
|
|
76 NAME="AEN174"
|
|
77 >3.5. Numbers and Expressions</A
|
|
78 ></H1
|
|
79 ><P
|
|
80 > Numbers can be expressed in binary, octal, decimal, or hexadecimal. Binary
|
|
81 numbers may be prefixed with a "%" symbol or suffixed with a "b" or "B".
|
|
82 Octal numbers may be prefixed with "@" or suffixed with "Q", "q", "O", or
|
|
83 "o". Hexadecimal numbers may be prefixed with "$", "0x" or "0X", or suffixed
|
|
84 with "H". No prefix or suffix is required for decimal numbers but they can
|
|
85 be prefixed with "&" if desired. Any constant which begins with a letter
|
|
86 must be expressed with the correct prefix base identifier or be prefixed
|
|
87 with a 0. Thus hexadecimal FF would have to be written either 0FFH or $FF.
|
|
88 Numbers are not case sensitive. </P
|
|
89 ><P
|
|
90 > A symbol may appear at any point where a number is acceptable. The
|
|
91 special symbol "*" can be used to represent the starting address of the
|
|
92 current source line within expressions. </P
|
|
93 ><P
|
|
94 >The ASCII value of a character can be included by prefixing it with a
|
|
95 single quote ('). The ASCII values of two characters can be included by
|
|
96 prefixing the characters with a quote (").</P
|
|
97 ><P
|
|
98 > LWASM supports the following basic binary operators: +, -, *, /, and %.
|
|
99 These represent addition, subtraction, multiplication, division, and
|
|
100 modulus. It also supports unary negation and unary 1's complement (- and ^
|
|
101 respectively). It is also possible to use ~ for the unary 1's complement
|
|
102 operator. For completeness, a unary positive (+) is supported though it is
|
|
103 a no-op. LWASM also supports using |, &, and ^ for bitwise or, bitwise and,
|
|
104 and bitwise exclusive or respectively. </P
|
|
105 ><P
|
|
106 > Operator precedence follows the usual rules. Multiplication, division, and
|
|
107 modulus take precedence over addition and subtraction. Unary operators take
|
|
108 precedence over binary operators. Bitwise operators are lower precdence
|
|
109 than addition and subtraction. To force a specific order of evaluation,
|
|
110 parentheses can be used in the usual manner. </P
|
|
111 ><P
|
|
112 > As of LWASM 2.5, the operators && and || are recognized for boolean and and
|
|
113 boolean or respectively. They will return either 0 or 1 (false or true).
|
|
114 They have the lowest precedence of all the binary operators. </P
|
|
115 ></DIV
|
|
116 ><DIV
|
|
117 CLASS="NAVFOOTER"
|
|
118 ><HR
|
|
119 ALIGN="LEFT"
|
|
120 WIDTH="100%"><TABLE
|
|
121 SUMMARY="Footer navigation table"
|
|
122 WIDTH="100%"
|
|
123 BORDER="0"
|
|
124 CELLPADDING="0"
|
|
125 CELLSPACING="0"
|
|
126 ><TR
|
|
127 ><TD
|
|
128 WIDTH="33%"
|
|
129 ALIGN="left"
|
|
130 VALIGN="top"
|
|
131 ><A
|
|
132 HREF="x169.html"
|
|
133 ACCESSKEY="P"
|
|
134 >Prev</A
|
|
135 ></TD
|
|
136 ><TD
|
|
137 WIDTH="34%"
|
|
138 ALIGN="center"
|
|
139 VALIGN="top"
|
|
140 ><A
|
|
141 HREF="index.html"
|
|
142 ACCESSKEY="H"
|
|
143 >Home</A
|
|
144 ></TD
|
|
145 ><TD
|
|
146 WIDTH="33%"
|
|
147 ALIGN="right"
|
|
148 VALIGN="top"
|
|
149 ><A
|
|
150 HREF="x182.html"
|
|
151 ACCESSKEY="N"
|
|
152 >Next</A
|
|
153 ></TD
|
|
154 ></TR
|
|
155 ><TR
|
|
156 ><TD
|
|
157 WIDTH="33%"
|
|
158 ALIGN="left"
|
|
159 VALIGN="top"
|
|
160 >Symbols</TD
|
|
161 ><TD
|
|
162 WIDTH="34%"
|
|
163 ALIGN="center"
|
|
164 VALIGN="top"
|
|
165 ><A
|
|
166 HREF="c43.html"
|
|
167 ACCESSKEY="U"
|
|
168 >Up</A
|
|
169 ></TD
|
|
170 ><TD
|
|
171 WIDTH="33%"
|
|
172 ALIGN="right"
|
|
173 VALIGN="top"
|
|
174 >Assembler Directives</TD
|
|
175 ></TR
|
|
176 ></TABLE
|
|
177 ></DIV
|
|
178 ></BODY
|
|
179 ></HTML
|
|
180 > |