1 /* 2 3 Copyright 2021, dettus@dettus.net 4 5 Redistribution and use in source and binary forms, with or without modification, 6 are permitted provided that the following conditions are met: 7 8 1. Redistributions of source code must retain the above copyright notice, this 9 list of conditions and the following disclaimer. 10 11 2. Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 26 27 */ 28 29 #ifndef VM68K_DATATYPES_H 30 #define VM68K_DATATYPES_H 31 // the purpose of this file is to provide the shared datatypes needed for the virtual machine 32 #ifdef __sgi__ 33 typedef unsigned char tVM68k_bool; 34 typedef unsigned char tVM68k_ubyte; 35 typedef unsigned short tVM68k_uword; 36 typedef unsigned int tVM68k_ulong; 37 typedef unsigned long long tVM68k_uint64; 38 39 typedef signed char tVM68k_sbyte; 40 typedef signed short tVM68k_sword; 41 typedef signed int tVM68k_slong; 42 typedef signed long long tVM68k_sint64; 43 44 45 #else 46 #include <stdint.h> 47 48 49 // first of all: the standard data types. 50 typedef uint_least8_t tVM68k_bool; 51 typedef uint_least8_t tVM68k_ubyte; 52 typedef uint_least16_t tVM68k_uword; 53 typedef uint_least32_t tVM68k_ulong; 54 typedef uint_least64_t tVM68k_uint64; 55 56 57 typedef int_least8_t tVM68k_sbyte; 58 typedef int_least16_t tVM68k_sword; 59 typedef int_least32_t tVM68k_slong; 60 typedef int_least64_t tVM68k_sint64; 61 #endif 62 63 64 65 // then a couple of enumerations. to make the sourcecode a little bit easier to read. 66 typedef enum _tVM68k_types {VM68K_BYTE=0,VM68K_WORD=1,VM68K_LONG=2,VM68K_UNKNOWN=3} tVM68k_types; 67 typedef enum _tVM68k_addrmodes { VM68K_AM_DATAREG=0, // Dn 68 VM68K_AM_ADDRREG=1, // An 69 VM68K_AM_INDIR=2, // (An) 70 VM68K_AM_POSTINC=3, // (An)+ 71 VM68K_AM_PREDEC=4, // -(An) 72 VM68K_AM_DISP16=5, // (d16,An) 73 VM68K_AM_INDEX=6, // (d8,An,Xn) 74 VM68K_AM_EXT=7} 75 tVM68k_addrmodes; 76 typedef enum _tVM68k_addrmode_ext { VM68K_AMX_W=0, // (xxx),W 77 VM68K_AMX_L=1, // (xxx),L 78 VM68K_AMX_data=4, // #<data> 79 VM68K_AMX_PC=2, // (d16,PC) 80 VM68K_AMX_INDEX_PC=3} // (d8,PC,Xn) 81 tVM68k_addrmode_ext; 82 83 // the internal structures 84 typedef struct _tVM68k 85 { 86 tVM68k_ulong magic; // just so that the functions can identify a handle as this particular data structure 87 tVM68k_ulong pcr; // program counter 88 tVM68k_uword sr; // status register. 89 // bit 0..4: CVZNX 90 tVM68k_ulong a[8]; // address register 91 tVM68k_ulong d[8]; // data register 92 tVM68k_ubyte *pMem; // pointer to the memory 93 tVM68k_ulong memsize; // TODO: check for violations. 94 95 /////// VERSION PATCH 96 tVM68k_ubyte version; 97 } tVM68k; 98 99 ////// this structure holds the state after the instruction has been decoded. 100 ////// the reason i put it in here is to trace the changes. 101 typedef struct _tVM68k_next 102 { 103 tVM68k_ulong pcr; // program counter 104 tVM68k_bool override_sr; 105 tVM68k_uword sr; 106 tVM68k_bool cflag; 107 tVM68k_bool vflag; 108 tVM68k_bool zflag; 109 tVM68k_bool nflag; 110 tVM68k_bool xflag; 111 // bit 0..4: CVZNX 112 tVM68k_ulong a[8]; // address register 113 tVM68k_ulong d[8]; // data register 114 115 ////// memory queue 116 tVM68k_types mem_size; 117 tVM68k_ulong mem_addr[16]; 118 tVM68k_ulong mem_value[16]; 119 tVM68k_ubyte mem_we; 120 121 } tVM68k_next; 122 123 #endif 124