diff options
author | Ian C <ianc@noddybox.co.uk> | 2006-09-03 22:27:04 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2006-09-03 22:27:04 +0000 |
commit | 5ae0f154bd925c050e37b572ea30b51b09e8b569 (patch) | |
tree | 2af3ddbf5d93463a33161701f516dc0431c18390 | |
parent | 81295d66b59af1ca7cbd91f63c897d6f60b015b6 (diff) |
Extra sanity checks on start-up.
-rw-r--r-- | z80.h | 7 | ||||
-rw-r--r-- | z80_decode.c | 10 | ||||
-rw-r--r-- | z80_private.h | 1 |
3 files changed, 14 insertions, 4 deletions
@@ -44,20 +44,21 @@ typedef struct Z80 Z80; typedef unsigned long Z80Val; -/* 8-bit type +/* 8-bit type. The emulation will exit with code 2 if this isn't 8 bits. */ typedef unsigned char Z80Byte; -/* 8-bit signed type +/* 8-bit signed type. The emulation will exit with code 2 if this isn't 8 bits. */ typedef signed char Z80Relative; -/* 16-bit type +/* 16-bit type. The emulation will exit with code 2 if this isn't 16 bits. */ typedef unsigned short Z80Word; + /* Memory */ typedef Z80Byte Z80Memory[0x10000]; diff --git a/z80_decode.c b/z80_decode.c index 4b6929c..81760ae 100644 --- a/z80_decode.c +++ b/z80_decode.c @@ -27,6 +27,7 @@ */ #include <stdlib.h> +#include <limits.h> #include "z80.h" #include "z80_private.h" @@ -71,6 +72,8 @@ void Z80_InitialiseInternals(void) Z80Word f; Z80Reg r; + /* Check endianness + */ r.w=0x1234; if (r.b[0] == 0x12) @@ -88,6 +91,13 @@ void Z80_InitialiseInternals(void) exit(1); } + /* Check variable sizes + */ + if (CHAR_BIT!=8 || sizeof(Z80Word)!=2) + { + exit(2); + } + /* Initialise flag tables */ for(f=0;f<256;f++) diff --git a/z80_private.h b/z80_private.h index 58b9584..2797a8a 100644 --- a/z80_private.h +++ b/z80_private.h @@ -42,7 +42,6 @@ /* ---------------------------------------- TYPES */ - typedef union { Z80Word w; |