From: sparky4 Date: Tue, 12 Jun 2018 18:52:29 +0000 (-0500) Subject: added regestry dump function and added it to ps.exe for testing reason X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=d48c3f2da3fb828320dc2817d5ab0e5848d07905;p=16.git added regestry dump function and added it to ps.exe for testing reason --- diff --git a/16/portable.h b/16/portable.h new file mode 100755 index 00000000..5acb46dc --- /dev/null +++ b/16/portable.h @@ -0,0 +1,166 @@ +/*============================================================================ + + portable.h v1.00 Written by Scott Robert Ladd. + + _MSC_VER Microsoft C 6.0 and later + _QC Microsoft Quick C 2.51 and later + __TURBOC__ Borland Turbo C, Turbo C++, and Borland C++ + __BORLANDC__ Borland C++ + __ZTC__ Zortech C++ and Symantec C++ + __SC__ Symantec C++ + __WATCOM__ WATCOM C + __POWERC Mix Power C + + Revised: + 09/14/93 Fred Cole Moved MK_FP() macro to end of file to avoid + redefinition error when dos.h gets included + at the in/outport definitions for __TURBOC__ + 09/15/93 Thad Smith Add conditional code for TC 2.01 + Fix findfirst/findnext support for ZTC 3.0 + 10/15/93 Bob Stout Revise find first/next support + 04/03/94 Bob Stout Add Power C support, FAR +============================================================================*/ + + +/* prevent multiple inclusions of this header file */ + +#if !defined(PORTABLE_H) +#define PORTABLE_H + +/* +** Correct far pointer syntax +*/ + +#if defined(__POWERC) || (defined(__TURBOC__) && !defined(__BORLANDC__)) + #define FAR far +#else + #define FAR _far +#endif + +/*---------------------------------------------------------------------------- + Directory search macros and data structures + + DOSFileData MS-DOS file data structure + FIND_FIRST MS-DOS function 0x4E -- find first file matchine spec + FIND_NEXT MS-DOS function 0x4F -- find subsequent files +----------------------------------------------------------------------------*/ + +/* make sure the structure is packed on byte boundary */ + +#if defined(_MSC_VER) || defined(_QC) || defined(__WATCOM__) + #pragma pack(1) +#elif defined(__ZTC__) + #pragma ZTC align 1 +#elif defined(__TURBOC__) && (__TURBOC__ > 0x202) + #pragma option -a- +#endif + +/* use this structure in place of compiler-defined file structure */ + +typedef struct { + char reserved[21]; + char attrib; + unsigned time; + unsigned date; + long size; + char name[13]; + } DOSFileData; + +/* set structure alignment to default */ + +#if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC__) + #pragma pack() +#elif defined (__ZTC__) + #pragma ZTC align +#elif defined(__TURBOC__) && (__TURBOC__ > 0x202) + #pragma option -a. +#endif + +/* include proper header files and create macros */ + +#if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC) + #include "direct.h" + #define FIND_FIRST(spec,attr,buf) _dos_findfirst(spec,attr,\ + (struct find_t *)buf) + #define FIND_NEXT(buf) _dos_findnext((struct find_t *)buf) +#elif defined (__TURBOC__) + #include "dir.h" + #define FIND_FIRST(spec,attr,buf) findfirst(spec,(struct ffblk *)buf,attr) + #define FIND_NEXT(buf) findnext((struct ffblk *)buf) +#elif defined (__ZTC__) + #include "dos.h" + #define FIND_FIRST(spec,attr,buf) _dos_findfirst(spec,attr,\ + (struct find_t *)buf) + #define FIND_NEXT(buf) _dos_findnext((struct find_t *)buf) +#endif + +/*---------------------------------------------------------------------------- + I/O Port Macros + + IN_PORT read byte from I/O port + IN_PORTW read word from I/O port + OUT_PORT write byte to I/O port + OUT_PORTW write word to I/O port +----------------------------------------------------------------------------*/ + +#if defined(__TURBOC__) + #include "dos.h" + #define IN_PORT(port) inportb(port) + #define IN_PORTW(port) inport(port) + #define OUT_PORT(port, val) outportb(port, val) + #define OUT_PORTW(port, val) outport(port, val) +#else + #include "conio.h" + + #define IN_PORT(port) inp(port) + #define IN_PORTW(port) inpw(port) + #define OUT_PORT(port, val) outp(port, val) + #define OUT_PORTW(port, val) outpw(port, val) + +/*---------------------------------------------------------------------------- + Borland pseudo register macros + + These macros replace references to Borland's pseudo register + variables and geninterrup() funciton with traditional struct + REGS/int86 references. +----------------------------------------------------------------------------*/ + +#if !defined(__TURBOC__) + #include "dos.h" + + extern union REGS CPURegs; + + #define _AX CPURegs.x.ax + #define _BX CPURegs.x.bx + #define _CX CPURegs.x.cx + #define _DX CPURegs.x.dx + + #define _AH CPURegs.h.ah + #define _AL CPURegs.h.al + #define _BH CPURegs.h.bh + #define _BL CPURegs.h.bl + #define _CH CPURegs.h.ch + #define _CL CPURegs.h.cl + #define _DH CPURegs.h.dh + #define _DL CPURegs.h.dl + + #define geninterrupt(n) int86(n,&CPURegs,&CPURegs); + #define O_DENYALL 0x10 + #define O_DENYWRITE 0x20 + #define O_DENYREAD 0x30 + #define O_DENYNONE 0x40 +#endif + +#endif + +/*---------------------------------------------------------------------------- + Pointer-related macros + + MK_FP creates a far pointer from segment and offset values +----------------------------------------------------------------------------*/ + +#if !defined(MK_FP) + #define MK_FP(seg,off) ((void FAR *)(((long)(seg) << 16)|(unsigned)(off))) +#endif + +#endif diff --git a/src/lib/16_head.c b/src/lib/16_head.c index b015902a..68b0645e 100755 --- a/src/lib/16_head.c +++ b/src/lib/16_head.c @@ -215,3 +215,119 @@ void hres (void) int 10h } } + +#define REGIDUMP_HEX +#define REGIDUMP_DUMPFLAGS +//#define REGIDUMP_USE_CAPS //uncomment to use the assembly +//regester dump~ +void regidump() +{ + //GENERAL PURPOSE + unsigned short _ax,_bx,_cx,_dx; + unsigned short _cflag; + unsigned char _al,_ah,_bl,_bh,_cl,_ch,_dl,_dh; + + unsigned short _bp,_si,_di,_sp; + + unsigned short _cs,_ds,_es,_ss; //SEGMENT +// unsigned short _ip; //SPECIAL PURPOSE + _ax=_bx=_cx=_dx=_si=_di=_bp=_sp=_cs=_ds=_es=_ss=_cflag=0; + _ah=_al=_bh=_bl=_ch=_cl=_dh=_dl=0; + +#ifndef REGIDUMP_USE_CAPS + __asm { + mov _ax,ax + mov _bx,bx + mov _cx,cx + mov _dx,dx + + mov _si,si + mov _di,di + + /*mov _ip,ip + + mov _cf,cf + mov _pf,pf + mov _af,af + mov _zf,zf + mov _sf,sf + mov _tf,tf + mov _if,if + mov _df,df + mov _of,of*/ + } +#else +_ax=_AX; +_bx=_BX; +_cx=_CX; +_dx=_DX; + +_si=_SI; +_di=_DI; + +_ah=_AH; +_al=_AL; +_bh=_BH; +_bl=_BL; +_ch=_CH; +_cl=_CL; +_dh=_DH; +_dl=_DL; +#endif + _cflag=_CFLAG; + __asm { + mov _bp,bp + mov _sp,sp + + mov _cs,cs + mov _ds,ds + mov _es,es + mov _ss,ss + } +// printf("integer values: ax=%04d bx=%04d cx=%04d dx=%04d\n", a, b, c, d); +// printf("unsigned values:ax=%04u bx=%04u cx=%04u dx=%04u\n", a, b, c, d); + printf("================================================================================"); + printf("16 bit 8088 register values\n"); + printf("================================================================================"); + printf("general purpose:\n"); +#ifndef REGIDUMP_HEX + printf(" ax=%04u\n bx=%04u\n cx=%04u\n dx=%04u\n\n", _ax, _bx, _cx, _dx); + printf(" si=%04u\n di=%04u\n bp=%04u\n sp=%04u\n", _si, _di, _bp, _sp); +#else + printf(" ax=%04x\n bx=%04x\n cx=%04x\n dx=%04x\n\n", _ax, _bx, _cx, _dx); + printf(" si=%04x\n di=%04x\n bp=%04x\n sp=%04x\n", _si, _di, _bp, _sp); +#endif + printf(" ---------------------------------------\n"); + + + + printf("segment:\n"); +#ifndef REGIDUMP_HEX + printf(" cs=%04u\n ds=%04u\n es=%04u\n ss=%04u\n", _cs, _ds, _es, _ss); +#else + printf(" cs=%04x\n ds=%04x\n es=%04x\n ss=%04x\n", _cs, _ds, _es, _ss); +#endif + printf(" ---------------------------------------\n"); + + + + printf("cflags:\n"); +/* printf(" ip=%04u\n\n", _ip); + printf(" cf=%04u\npf=%04u\naf=%04u\nzf=%04u\nsf=%04u\ntf=%04u\nif=%04u\ndf=%04u\nof=%04u\n", _cf, _pf, _af, _zf, _sf, _tf, _if, _df, _of); + printf(" ---------------------------------------\n");*/ +#ifdef REGIDUMP_DUMPFLAGS +#ifndef REGIDUMP_HEX +// printf(" ip=%04u\n\n", _IP); +// printf(" cf=%04u\npf=%04u\naf=%04u\nzf=%04u\nsf=%04u\ntf=%04u\nif=%04u\ndf=%04u\nof=%04u\n", _CF, _PF, _AF, _ZF, _SF, _TF, _IF, _DF, _OF); +#else +// printf(" ip=%04x\n\n", _IP); +// printf(" cf=%04x\npf=%04x\naf=%04x\nzf=%04x\nsf=%04x\ntf=%04x\nif=%04x\ndf=%04x\nof=%04x\n", _CF, _PF, _AF, _ZF, _SF, _TF, _IF, _DF, _OF); + printf("cflag: "BYTE_TO_BINARY_PATTERN""BYTE_TO_BINARY_PATTERN"\n", BYTE_TO_BINARY(_cflag>>8), BYTE_TO_BINARY(_cflag)); +#endif + printf("dx: "BYTE_TO_BINARY_PATTERN""BYTE_TO_BINARY_PATTERN"\n", BYTE_TO_BINARY(_dx>>8), BYTE_TO_BINARY(_dx)); + printf(" ---------------------------------------\n"); +#endif + + printf("for more info see\n http://stackoverflow.com/questions/9130349/how-many-registers-are-there-in-8086-8088\n"); + printf("================================================================================"); +} diff --git a/src/lib/16_head.h b/src/lib/16_head.h index 27472230..0a71c965 100755 --- a/src/lib/16_head.h +++ b/src/lib/16_head.h @@ -170,6 +170,7 @@ extern union REGS CPURegs; #define _DX CPURegs.x.dx #define _SI CPURegs.x.si +#define _DI CPURegs.x.di #define _AH CPURegs.h.ah #define _AL CPURegs.h.al @@ -180,6 +181,8 @@ extern union REGS CPURegs; #define _DH CPURegs.h.dh #define _DL CPURegs.h.dl +#define _CFLAG CPURegs.x.cflag + #define geninterrupt(n) int86(n,&CPURegs,&CPURegs); @@ -197,6 +200,22 @@ int US_CheckParm(char *parm,char **strings); byte dirchar(byte in); void print_mem(void const *vp, size_t n); void hres (void); +void regidump(); + +//from https://stackoverflow.com/questions/111928/is-there-a-printf-converter-to-print-in-binary-format +//printf("Leading text "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(byte)); +//For multi-byte types +//printf("m: "BYTE_TO_BINARY_PATTERN" "BYTE_TO_BINARY_PATTERN"\n", BYTE_TO_BINARY(m>>8), BYTE_TO_BINARY(m)); +#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c" +#define BYTE_TO_BINARY(byte) \ + (byte & 0x80 ? '1' : '0'), \ + (byte & 0x40 ? '1' : '0'), \ + (byte & 0x20 ? '1' : '0'), \ + (byte & 0x10 ? '1' : '0'), \ + (byte & 0x08 ? '1' : '0'), \ + (byte & 0x04 ? '1' : '0'), \ + (byte & 0x02 ? '1' : '0'), \ + (byte & 0x01 ? '1' : '0') #define PRINT_OPAQUE_STRUCT(p) print_mem((p), sizeof(*(p))) diff --git a/src/lib/doslib b/src/lib/doslib index ae5d9881..9a52516a 160000 --- a/src/lib/doslib +++ b/src/lib/doslib @@ -1 +1 @@ -Subproject commit ae5d98814539f01c57bb012f7e5c7652011988da +Subproject commit 9a52516ac236cb67e1a8f0d9b06bd3f2120a8311 diff --git a/src/ps.c b/src/ps.c index 64da4428..e63ea9dd 100755 --- a/src/ps.c +++ b/src/ps.c @@ -26,4 +26,5 @@ void main() // in //player //mv + regidump(); }