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