|
Part 2ýBuilding on the Basics
by Ed Sutter
Start ý The
Ethernet Interface ý The Command Line Interface
ý "Get Your Tokens Here" ý One
Last Topic About CLI ý Executable Scripts
ý Application-to-Monitor Hook-Up ý The
Moncom() Function ý The Monconnect() Function
ý Letýs Regroup ý Xmodem
and Tftp ý OK, Iým Done! ý Sources
and PDF
THE MONCONNECT() FUNCTION
So, the application knows where this moncom()
function is in monitor space because a pointer to this function is
stored in a well-known address. Now, other functions in application
space can use this function to "connect" the application
to the monitor. This is where monConnect() comes in. This function
takes as one of its arguments the well-known address shown in Listing
12.
Both the moncom() function in
the monitor and the monConnect() function in the application
compile with the same monlib.h file. This header file contains
all of the GETMONFUNC_XXX definitions. The application calls
monConnect and this connects the function pointers _rputchar,
_getchar, and _gotachar to the corresponding rputchar,
getchar, and gotachar functions in the monitorýs space.
At this point, the application could just use those function pointers,
however, it would be nicer for the application to have functions (not
pointers) to access the monitor code. This allows the function to
wrap the monitor access with a semaphore or some other lockout mechanism,
prior to entering monitor code space. This also provides protection
to the monitor because it might be used in a multitasking environment.
Listing 13 is the code in the application
space that can be used to call the monitor for rputchar. All
of the mon_ interface functions are similar.
|
int
mon_putchar(unsigned
char c)
{
int ret;
if (_monlock)
_monlock();
ret = _rputchar(c);
if (_monunlock)
_monunlock();
return(ret);
}
|
| Listing 13ýThis
code can be used to call the monitor for rputchar. |
The monitor lockout functions are optional
and would be set up using the second and third arguments of the monConnect
function.
PREVIOUS
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ýCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |