e., a number,
operation sign or equal sign. If the character is not one of those, ignore the character, and enable another
read from the keyboard.
5 If the character is a number, see if the previous character was a number. If so, then this is the next digit in
a multidigit number. In that case, multiply the previous number by 10, add the new number to it, and store
the result in a known memory location.
Before you can add the new number, however, you must decode the ASCII and convert the character
into a binary number. A commonly used ???trick??? is simply to subtract 48 from the coded value of the number
(e.g., if the number is 3, subtracting 48 from 51, the encoding, returns the binary numeric value 3).
On the other hand, if this is the first digit in a number, just decode the ASCII and store the binary value
in a memory location set aside by the program for one of the operands.
6 If the character is one of the operation signs, store the sign in a memory location set aside for storing the
operator. The program will refer to this later, after the program receives an equal sign.
7 If the character is an equal sign, load the operands saved in memory into CPU registers, retrieve the
operator character, and, depending on the operator, jump to the instruction(s) to perform the arithmetic
operation on the contents of the registers.
Pages:
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257