34 lines
2.0 KiB
C
34 lines
2.0 KiB
C
enum {
|
|
REGISTER_0_64, REGISTER_1_64, REGISTER_2_64, REGISTER_3_64, REGISTER_4_64, REGISTER_5_64, REGISTER_6_64, REGISTER_7_64,
|
|
REGISTER_8_64, REGISTER_9_64, REGISTER_A_64, REGISTER_B_64, REGISTER_C_64, REGISTER_D_64, REGISTER_E_64, REGISTER_F_64,
|
|
REGISTER_0_32, REGISTER_1_32, REGISTER_2_32, REGISTER_3_32, REGISTER_4_32, REGISTER_5_32, REGISTER_6_32, REGISTER_7_32,
|
|
REGISTER_8_32, REGISTER_9_32, REGISTER_A_32, REGISTER_B_32, REGISTER_C_32, REGISTER_D_32, REGISTER_E_32, REGISTER_F_32,
|
|
REGISTER_0_16, REGISTER_1_16, REGISTER_2_16, REGISTER_3_16, REGISTER_4_16, REGISTER_5_16, REGISTER_6_16, REGISTER_7_16,
|
|
REGISTER_8_16, REGISTER_9_16, REGISTER_A_16, REGISTER_B_16, REGISTER_C_16, REGISTER_D_16, REGISTER_E_16, REGISTER_F_16,
|
|
REGISTER_0_8, REGISTER_1_8, REGISTER_2_8, REGISTER_3_8, REGISTER_4_8, REGISTER_5_8, REGISTER_6_8, REGISTER_7_8,
|
|
REGISTER_8_8, REGISTER_9_8, REGISTER_A_8, REGISTER_B_8, REGISTER_C_8, REGISTER_D_8, REGISTER_E_8, REGISTER_F_8,
|
|
REGISTER_0_8X, REGISTER_1_8X, REGISTER_2_8X, REGISTER_3_8X,
|
|
REGISTER_COUNT
|
|
};
|
|
|
|
static void (* encode [FORMAT_COUNT] [INSTRUCTION_COUNT]) (int instruction, int left, int right);
|
|
|
|
static int data [16] = { 0 };
|
|
|
|
static void data_push (int byte) { data [0]++; data [data [0]] = byte; }
|
|
static void data_pop (void) { data [data [0]] = 0X00; data [0]--; }
|
|
static int data_look (int look) { return (data [look]); }
|
|
static int data_size (void) { return (data [0]); }
|
|
static void data_free (void) { data [0] = 0; }
|
|
|
|
static void data_echo (void) {
|
|
char byte [4] = " ";
|
|
int i;
|
|
|
|
for (i = 0; i != data [0]; ++i) {
|
|
byte [0] = "0123456789ABCDEF" [data [i + 1] / 16];
|
|
byte [1] = "0123456789ABCDEF" [data [i + 1] % 16];
|
|
echo (byte);
|
|
}
|
|
}
|