Then store the result back in the memory location for operand 1,
construct the character string to send as the result, and send the result back to the display.
Here??™s how the program constructs the characters to send to the display:
a If the result is greater than 9, then the result will require more than one character, so divide the result by
10 until further division results in a number less than 1.
b Add 48 to the integer result to encode it as ASCII.
c Load the interface register in the computer with the character, and issue the I/O instruction to have the
first character sent to the display.
d Wait (loop again) until the character is sent, and acknowledged by the display via the flag being set on
the display interface.
e Having sent the most significant digit, subtract the appropriate value from the result and repeat the
formatting and output operations until the entire character string result is sent to the display.
8 Reenable the keyboard interface to read the next character.
What a lot of work! And many programs need to read from the keyboard and write to the display! And
many programs need to decode strings of numeric characters, and also to encode numbers into character strings!
We don??™t want every programmer reinventing this code, and making similar mistakes over and over again.
Pages:
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258