Hardware Reference
In-Depth Information
Suppose labels m , n , and gcd represent three memory locations and the memory locations
(2 bytes) starting with the label gcd hold the greatest common divisor of two numbers stored at
memory locations starting with labels m and n . By adding the following instruction sequence,
the relationship among m , n , and gcd can be displayed on the PC monitor screen when the pro-
gram is executed on a demo board with D-Bug12 monitor:
CR
equ
$0D
LF
equ
$0A
printf
equ
$EE88
ldd
gcd
pshd
ldd
n
pshd
ldd
m
pshd
ldd
#prompt
jsr
[printf,PCR]
leas
6,sp
promptdb “The greatest common divisor of %d and %d is %d”,CR,LF,0
This example is probably not easy to follow. In reality, this example is equivalent to the
following C statement:
printf(“The greatest common divisor of %d and %d is %d\n”, m, n, gcd);
This function call has four parameters: the first parameter is a pointer to the formatting
string and should be placed in D (done by the ldd #prompt instruction). The other parameters ( m ,
n , and gcd ) should be pushed into the stack in the order from right to left. There are three for-
matting characters corresponding to these three variables to be output.
int far GetCmdLine(char *CmdLineStr, int CmdLineLen);
Pointer address: $EE8A
This function is used to obtain a line of input from the user. GetCmdLine() accepts input from
the user one character at a time by calling getchar(). As each character is received it is echoed
back to the user terminal by calling putchar() and placed in the character array pointed to by
CmdLineStr. A maximum of CmdLineLen 2 1 characters may be entered. Only printable ASCII
characters are accepted as input with the exception of the ASCII backspace character ($08) and
the ASCII carriage return ($0D). All other nonprintable ASCII characters are ignored by the
function.
The ASCII backspace character ($08) is used by the GetCmdLine() function to delete the
previously received character from the command line buffer. When GetCmdLine() receives
the backspace character, it will echo the backspace to the terminal, print the ASCII space
character ($20), and then send a second backspace character to the terminal device. At the
same time, the character is deleted from the command line buffer. If a backspace charac-
ter is received when there are no characters in CmdLineStr, the backspace character is
ignored.
The reception of an ASCII carriage return character ($0D) terminates the reception of char-
acters from the user. The carriage return is not placed in the command line buffer. Instead, a
NULL character ($00) is placed in the next available buffer location.
 
Search WWH ::




Custom Search