| 1 | #include <stdio.h> |
| 2 | #include <string.h> |
| 3 | #include <stdlib.h> |
| 4 | |
| 5 | #ifndef HW_TYPES_H |
| 6 | #define HW_TYPES_H |
| 7 | // #pragma pack(1) |
| 8 | |
| 9 | struct hw16_bits { |
| 10 | unsigned int b9:1 __attribute__ ((packed)); |
| 11 | unsigned int b10:1 __attribute__ ((packed)); |
| 12 | unsigned int b11:1 __attribute__ ((packed)); |
| 13 | unsigned int b12:1 __attribute__ ((packed)); |
| 14 | unsigned int b13:1 __attribute__ ((packed)); |
| 15 | unsigned int b14:1 __attribute__ ((packed)); |
| 16 | unsigned int b15:1 __attribute__ ((packed)); |
| 17 | unsigned int b16:1 __attribute__ ((packed)); |
| 18 | unsigned int b1:1 __attribute__ ((packed)); |
| 19 | unsigned int b2:1 __attribute__ ((packed)); |
| 20 | unsigned int b3:1 __attribute__ ((packed)); |
| 21 | unsigned int b4:1 __attribute__ ((packed)); |
| 22 | unsigned int b5:1 __attribute__ ((packed)); |
| 23 | unsigned int b6:1 __attribute__ ((packed)); |
| 24 | unsigned int b7:1 __attribute__ ((packed)); |
| 25 | unsigned int b8:1 __attribute__ ((packed)); |
| 26 | } __attribute__ ((packed)); |
| 27 | |
| 28 | struct hw16_tape { |
| 29 | unsigned int low:6 __attribute__ ((packed)); |
| 30 | unsigned int mid:6 __attribute__ ((packed)); |
| 31 | unsigned int high:4 __attribute__ ((packed)); |
| 32 | }; |
| 33 | |
| 34 | struct hw16_bytes { |
| 35 | unsigned char low __attribute__ ((packed)); |
| 36 | unsigned char high __attribute__ ((packed)); |
| 37 | }; |
| 38 | |
| 39 | struct hw16_otype { |
| 40 | unsigned int space1:6 __attribute__ ((packed)); |
| 41 | unsigned int t0_subtype:6 __attribute__ ((packed)); |
| 42 | unsigned int type:4 __attribute__ ((packed)); |
| 43 | }; |
| 44 | |
| 45 | typedef struct { |
| 46 | unsigned int space3:6 __attribute__ ((packed)) __attribute__ ((packed)); //Erster Block |
| 47 | unsigned int S:6 __attribute__ ((packed)); |
| 48 | unsigned int T:4 __attribute__ ((packed)); |
| 49 | unsigned int space1:8 __attribute__ ((packed)); // Zweiter Block |
| 50 | unsigned int N:6 __attribute__ ((packed)); |
| 51 | unsigned int space2:2 __attribute__ ((packed)); |
| 52 | } head0; |
| 53 | typedef head0 head0_0; |
| 54 | |
| 55 | typedef struct { |
| 56 | unsigned int space3:6 __attribute__ ((packed)); //Erster Block |
| 57 | unsigned int S:6 __attribute__ ((packed)); |
| 58 | unsigned int T:4 __attribute__ ((packed)); |
| 59 | } head0_23; |
| 60 | typedef head0_23 head0_2; |
| 61 | typedef head0_23 head0_3; |
| 62 | |
| 63 | |
| 64 | typedef struct { |
| 65 | unsigned int A1:6 __attribute__ ((packed)); |
| 66 | unsigned int N:6 __attribute__ ((packed)); |
| 67 | unsigned int T:4 __attribute__ ((packed)); |
| 68 | unsigned int I:8 __attribute__ ((packed)); |
| 69 | unsigned int A2:8 __attribute__ ((packed)); |
| 70 | } head12; |
| 71 | typedef head12 head1; |
| 72 | typedef head12 head2; |
| 73 | |
| 74 | typedef struct { |
| 75 | unsigned int A1:6 __attribute__ ((packed)); |
| 76 | unsigned int space1:6 __attribute__ ((packed)); |
| 77 | unsigned int T:4 __attribute__ ((packed)); |
| 78 | unsigned int space2:8 __attribute__ ((packed)); |
| 79 | unsigned int A2:8 __attribute__ ((packed)); |
| 80 | } head34; |
| 81 | typedef head34 head3; |
| 82 | typedef head34 head4; |
| 83 | |
| 84 | typedef struct { |
| 85 | unsigned int A:6 __attribute__ ((packed)); |
| 86 | unsigned int OP:4 __attribute__ ((packed)); |
| 87 | unsigned int T2:1 __attribute__ ((packed)); |
| 88 | unsigned int F:1 __attribute__ ((packed)); |
| 89 | unsigned int T:4 __attribute__ ((packed)); |
| 90 | } head57; |
| 91 | typedef head57 head5; |
| 92 | typedef head57 head7; |
| 93 | |
| 94 | typedef struct { |
| 95 | unsigned int A1:6 __attribute__ ((packed)); |
| 96 | unsigned int space1:6 __attribute__ ((packed)); |
| 97 | unsigned int T:4 __attribute__ ((packed)); |
| 98 | unsigned int B:8 __attribute__ ((packed)); |
| 99 | unsigned int A2:8 __attribute__ ((packed)); |
| 100 | } head6; |
| 101 | |
| 102 | |
| 103 | typedef union{ |
| 104 | unsigned int value __attribute__ ((packed)); |
| 105 | |
| 106 | struct { |
| 107 | unsigned int type:3; //Immer 0 |
| 108 | unsigned int space:5; |
| 109 | unsigned int data:16; |
| 110 | } generic; |
| 111 | |
| 112 | struct{ |
| 113 | unsigned int one:1; |
| 114 | unsigned int R:2; |
| 115 | unsigned int ADDRESS:15; |
| 116 | unsigned int OP:4; |
| 117 | unsigned int T:1; |
| 118 | unsigned int F:1; |
| 119 | }op_known_address; |
| 120 | |
| 121 | struct{ |
| 122 | unsigned int two:3; |
| 123 | unsigned int SYMBOL_NUMBER:14; |
| 124 | unsigned int zero:1; |
| 125 | unsigned int OP:4; |
| 126 | unsigned int T:1; |
| 127 | unsigned int F:1; |
| 128 | }op_symbolic_address; |
| 129 | |
| 130 | struct { |
| 131 | unsigned int four:3; |
| 132 | unsigned int ADDRESS:16; |
| 133 | unsigned int R:2; |
| 134 | unsigned int space:1; |
| 135 | unsigned int T:1; |
| 136 | unsigned int F:1; |
| 137 | } known_address; |
| 138 | |
| 139 | struct { |
| 140 | unsigned int six:3; |
| 141 | unsigned int SYMBOL_NUMBER:14; |
| 142 | unsigned int space:5; |
| 143 | unsigned int T:1; |
| 144 | unsigned int F:1; |
| 145 | } symbolic_address; |
| 146 | |
| 147 | }type_0_4_data; |
| 148 | |
| 149 | |
| 150 | |
| 151 | typedef union { |
| 152 | struct hw16_bits bits __attribute__ ((packed)); |
| 153 | struct hw16_bytes bytes __attribute__ ((packed)); |
| 154 | struct hw16_tape tape __attribute__ ((packed)); |
| 155 | struct hw16_otype blocktype __attribute__ ((packed)); |
| 156 | unsigned short value __attribute__ ((packed)); |
| 157 | } hw16; |
| 158 | |
| 159 | enum {BT_DATA,BT_STOP}; |
| 160 | |
| 161 | typedef struct { |
| 162 | int size; |
| 163 | int type; |
| 164 | hw16 *data; |
| 165 | unsigned char * raw_data; |
| 166 | } datablock; |
| 167 | |
| 168 | |
| 169 | #endif |