/*
 * tstexmem.c  21 Dec 83  Craig Milo Rogers at USC/ISI
 *	Added tests for peek(), poke(), etc.
 * tstgetaddr.c  25 Oct 83
 *	Test the getaddr() function.
 *
 *	This program tests the subroutines in exmem.  The tests are
 * best run under a debugger, to verify their correctness.
 */

#include "stdio.h"

#include "truth.h"
#include "beauty.h"

#include "exmem.h"

long lvar;			/* Test variables. */
short svar;
u_char cvar;

main(argc, argv)
int argc;			/* Number of command arguments. */
char *argv[];			/* Pointers to command arguments. */
{
    p_addr ladr;		/* Gets addresses. */
    p_addr sadr;
    p_addr cadr;

    printf("argv = 0x%lx\n", getaddr(argv));

    lvar = 0x12345678;		/* Store known values in test vars. */
    svar = 0x1234;
    cvar = 0x12;

    printf("Address of lvar = 0x%lx\n", ladr = getaddr(&lvar));
    printf("Address of svar = 0x%lx\n", sadr = getaddr(&svar));
    printf("Address of cvar = 0x%lx\n", cadr = getaddr(&cvar));

    printf("lvar = 0x%lx\n", lpeek(ladr));
    printf("svar = 0x%x\n", peek(sadr));
    printf("cvar = 0x%x\n", cpeek(cadr));

    lpoke(ladr, (long)0x11223344);
    printf("new lvar = 0x%lx\n", lpeek(ladr));
    poke(sadr, 0x1122);
    printf("new svar = 0x%x\n", peek(sadr));
    cpoke(cadr, 0x11);
    printf("new cvar = 0x%x\n", cpeek(cadr));
}
