home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 October
/
VPR9710A.ISO
/
BENCH
/
DJ1SRC_K
/
105
/
UTILS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1997-05-02
|
3KB
|
129 lines
/* This is file UTILS.C */
/*
** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
**
** This file is distributed under the terms listed in the document
** "copying.dj", available from DJ Delorie at the address above.
** A copy of "copying.dj" should accompany this file; if not, a copy
** should be available from where this file was obtained. This file
** may not be distributed without a verbatim copy of "copying.dj".
**
** This file is distributed WITHOUT ANY WARRANTY; without even the implied
** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/* 1997/05/01 modified by Kimio Itoh(kitoh@nn.iij4u.or.jp)
for reduce binary size and for dead code elimination.
*/
/* History:130,1 */
#include "build.h"
extern jmp_buf back_to_debugger;
extern int can_longjmp;
extern int exception_handler(void);
extern void go32(void);
extern word32 __pascal ptr2linear(void far * ptr);
extern _do_memset32();
extern _do_memmov32();
extern _do_save_npx();
extern _do_load_npx();
NPX npx;
extern int was_exception;
TSS *utils_tss = &o_tss;
static void go_til_done(void)
{
while (1) {
go32();
if (was_exception) {
if (exception_handler())
if (can_longjmp)
longjmp(back_to_debugger, 1);
else
return;
} else
return;
}
}
void __pascal zero32(word32 vaddr)
{
TSS *old_ptr;
old_ptr = tss_ptr;
tss_ptr = utils_tss;
utils_tss->tss_eip = (word16) _do_memset32;
utils_tss->tss_eax = 0;
utils_tss->tss_ecx = 4096;
utils_tss->tss_es = g_core * 8;
utils_tss->tss_edi = vaddr;
go_til_done();
tss_ptr = old_ptr;
}
void __pascal memput(word32 vaddr, void far * ptr, word16 len)
{
TSS *old_ptr;
old_ptr = tss_ptr;
tss_ptr = utils_tss;
utils_tss->tss_eip = (word16) _do_memmov32;
utils_tss->tss_ecx = len;
utils_tss->tss_es = utils_tss->tss_ds = g_core * 8;
utils_tss->tss_edi = vaddr;
utils_tss->tss_esi = ptr2linear(ptr);
go_til_done();
tss_ptr = old_ptr;
}
void __pascal memget(word32 vaddr, void far * ptr, word16 len)
{
TSS *old_ptr;
old_ptr = tss_ptr;
tss_ptr = utils_tss;
utils_tss->tss_eip = (word16) _do_memmov32;
utils_tss->tss_ecx = len;
utils_tss->tss_es = utils_tss->tss_ds = g_core * 8;
utils_tss->tss_edi = ptr2linear(ptr);
utils_tss->tss_esi = vaddr;
go_til_done();
tss_ptr = old_ptr;
}
word8 __pascal peek8(word32 vaddr)
{
word8 rv;
memget(vaddr, &rv, 1);
return rv;
}
#if DEBUGGER
word32 __pascal peek32(word32 vaddr)
{
word32 rv;
memget(vaddr, &rv, 4);
return rv;
}
void __pascal poke32(word32 vaddr, word32 v)
{
memput(vaddr, &v, 4);
}
void save_npx(void)
{
TSS *old_ptr;
old_ptr = tss_ptr;
tss_ptr = utils_tss;
utils_tss->tss_eip = (word16) _do_save_npx;
utils_tss->tss_ds = utils_tss->tss_es = g_rdata * 8;
go_til_done();
tss_ptr = old_ptr;
}
#endif