-
Notifications
You must be signed in to change notification settings - Fork 5
/
run.c
648 lines (585 loc) · 20.9 KB
/
run.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include "run.h"
#include "opcode.h"
struct inst_param
{
union
{
struct
{
uint16_t r2 : 4;
uint16_t r1 : 4;
uint16_t opcode : 8;
} f2_param;
struct
{
uint32_t address: 12;
uint32_t e : 1; // must be 0
uint32_t p : 1;
uint32_t b : 1;
uint32_t x : 1;
uint32_t i : 1;
uint32_t n : 1;
uint32_t opcode : 6;
} f3_param;
struct
{
uint32_t address: 20;
uint32_t e : 1; // must be 1
uint32_t p : 1;
uint32_t b : 1;
uint32_t x : 1;
uint32_t i : 1;
uint32_t n : 1;
uint32_t opcode : 6;
} f4_param;
uint32_t val;
} param;
bool extend;
};
typedef void (*inst_handler_t) (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_STA (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_STL (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_STCH (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_STX (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_LDA (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_LDB (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_LDT (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_LDX (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_LDCH (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_JSUB (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_JEQ (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_J (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_JGT (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_JLT (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_RSUB (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_COMP (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_COMPR (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_TD (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_RD (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_WD (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_CLEAR (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static void _h_TIXR (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set);
static bool load_mem (struct memory_manager *memory_manager, const struct run_register_set *reg_set,
struct inst_param inst_param, uint32_t *value, size_t bytes, bool jump_op);
static bool store_mem (struct memory_manager *memory_manager, const struct run_register_set *reg_set,
struct inst_param inst_param, uint32_t value, size_t bytes);
static bool load_reg (struct run_register_set *reg_set, int reg_no, uint32_t *reg_val);
static bool store_reg (struct run_register_set *reg_set, int reg_no, uint32_t reg_val);
int run (struct memory_manager *memory_manager, const struct debug_manager *debug_manager,
struct run_register_set *reg_set, bool *is_running)
{
// 1. PC로 부터 opcode를 읽는다.
// 2. opcode마다 추가적으로 0~3바이트를 더 읽고,
// - opcode -> instruction format number table 작성
// 3. debug_manager에게 bp check를 요청한다.
// 3-1. bp에 걸릴 경우, run을 멈춤.(반환)
// 3-2. bp에 안걸릴 경우 계속 진행.
// 4. instruction을 수행한다.
// - opcode -> instruction handler table 작성.
// 5. 다시 1부터 반복.
enum opcode_format opcode_format_table[256] =
{
[0x00] = OPCODE_FORMAT_3_4,
[0x68] = OPCODE_FORMAT_3_4,
[0x74] = OPCODE_FORMAT_3_4,
[0x04] = OPCODE_FORMAT_3_4,
[0x50] = OPCODE_FORMAT_3_4,
[0x0C] = OPCODE_FORMAT_3_4,
[0x14] = OPCODE_FORMAT_3_4,
[0x10] = OPCODE_FORMAT_3_4,
[0x54] = OPCODE_FORMAT_3_4,
[0x48] = OPCODE_FORMAT_3_4,
[0x30] = OPCODE_FORMAT_3_4,
[0x34] = OPCODE_FORMAT_3_4,
[0x38] = OPCODE_FORMAT_3_4,
[0x3C] = OPCODE_FORMAT_3_4,
[0x28] = OPCODE_FORMAT_3_4,
[0xE0] = OPCODE_FORMAT_3_4,
[0xD8] = OPCODE_FORMAT_3_4,
[0x4C] = OPCODE_FORMAT_3_4,
[0xDC] = OPCODE_FORMAT_3_4,
[0xB4] = OPCODE_FORMAT_2,
[0xA0] = OPCODE_FORMAT_2,
[0xB8] = OPCODE_FORMAT_2
};
inst_handler_t inst_handler_table[256] =
{
[0x00] = _h_LDA,
[0x68] = _h_LDB,
[0x74] = _h_LDT,
[0x04] = _h_LDX,
[0x50] = _h_LDCH,
[0x0C] = _h_STA,
[0x14] = _h_STL,
[0x10] = _h_STX,
[0x54] = _h_STCH,
[0x48] = _h_JSUB,
[0x30] = _h_JEQ,
[0x34] = _h_JGT,
[0x38] = _h_JLT,
[0x3C] = _h_J,
[0x28] = _h_COMP,
[0xE0] = _h_TD,
[0xD8] = _h_RD,
[0x4C] = _h_RSUB,
[0xDC] = _h_WD,
[0xB4] = _h_CLEAR,
[0xA0] = _h_COMPR,
[0xB8] = _h_TIXR
};
int ret;
bool is_continue = *is_running;
if (*is_running)
{
printf ("[Info] Continuous Running.\n");
}
else
{
uint32_t PC = reg_set->PC;
memset (reg_set, 0, sizeof (*reg_set));
reg_set->PC = PC;
reg_set->L = 0x00FFFFFF;
}
*is_running = true;
while (reg_set->PC != 0x00FFFFFF)
{
uint8_t opcode;
uint32_t inst_val = 0;
uint8_t mem_val;
int inst_size;
memory_get (memory_manager, reg_set->PC, &mem_val);
inst_val = mem_val;
opcode = mem_val & 0xFC;
//fprintf (stderr, "[DEBUG] running opcode %02X, PC = %08X, SW = %08X\n", mem_val, reg_set->PC, reg_set->SW);
switch (opcode_format_table[opcode])
{
case OPCODE_FORMAT_1:
inst_size = 1;
break;
case OPCODE_FORMAT_2:
memory_get (memory_manager, reg_set->PC + 1, &mem_val);
inst_size = 2;
inst_val = (inst_val << 8) + mem_val;
break;
case OPCODE_FORMAT_3_4:
memory_get (memory_manager, reg_set->PC + 1, &mem_val);
inst_val = (inst_val << 8) + mem_val;
memory_get (memory_manager, reg_set->PC + 2, &mem_val);
inst_val = (inst_val << 8) + mem_val;
inst_size = 3;
if (inst_val & (1 << 12))
{
memory_get (memory_manager, reg_set->PC + 3, &mem_val);
inst_val = (inst_val << 8) + mem_val;
++inst_size;
}
break;
default:
return -1;
}
uint32_t bp;
if (!is_continue && debug_bp_check (debug_manager, reg_set->PC, reg_set->PC + inst_size, &bp))
{
// bp에 걸림.
printf ("Stop at checkpoint[%04X]\n", bp);
return 0;
}
struct inst_param inst_param = {
.extend = (inst_size == 4),
.param.val = inst_val
};
inst_handler_t inst_handler = inst_handler_table[opcode];
if (!inst_handler)
{
fprintf (stderr, "[ERROR] Not supported opcode : %02X\n", opcode);
ret = -1;
goto ERROR;
}
reg_set->PC += inst_size;
inst_handler (memory_manager, inst_param, reg_set);
is_continue = false;
/*
fprintf (stderr,
"A : %08X X : %08X \n"
"L : %08X PC: %08X \n"
"B : %08X S : %08X \n"
"T : %08X \n",
reg_set->A, reg_set->X,
reg_set->L, reg_set->PC,
reg_set->B, reg_set->S,
reg_set->T
);
*/
//getchar();
}
*is_running = false;
ret = 0;
goto END;
ERROR:
*is_running = false;
END:
printf ("[Info] Program Terminated.\n");
return ret;
}
// TODO: range check.
static bool load_mem (struct memory_manager *memory_manager, const struct run_register_set *reg_set,
struct inst_param inst_param, uint32_t *value, size_t bytes, bool jump_op)
{
uint32_t target_address;
#define INST_PARAM(S) \
(inst_param.extend ? inst_param.param.f4_param.S : inst_param.param.f3_param.S)
if (INST_PARAM (b) == 1 && INST_PARAM (p) == 0) // Base relative
target_address = INST_PARAM (address) + reg_set->B;
else if (INST_PARAM (b) == 0 && INST_PARAM (p) == 1) // PC relative
{
int32_t value;
uint32_t boundary;
if (inst_param.extend)
boundary = (1 << 19);
else
boundary = (1 << 11);
if (INST_PARAM (address) >= boundary)
value = INST_PARAM (address) - (boundary << 1);
else
value = INST_PARAM (address);
target_address = reg_set->PC + value;
}
else
target_address = INST_PARAM (address);
if (INST_PARAM (x) == 1)
{
target_address += reg_set->X;
}
// fprintf (stderr, "[DEBUG - load_mem] address = %08X, target_address = %08X\n", INST_PARAM (address), target_address);
bool is_immediate, is_simple, is_indirect;
if (jump_op)
{
is_immediate = INST_PARAM (n) == 1 && INST_PARAM (i) == 1;
is_simple = INST_PARAM (n) == 1 && INST_PARAM (i) == 0;
is_indirect = false;
}
else
{
is_immediate = INST_PARAM (n) == 0 && INST_PARAM (i) == 1;
is_simple = INST_PARAM (n) == 1 && INST_PARAM (i) == 1;
is_indirect = INST_PARAM (n) == 1 && INST_PARAM (i) == 0;
}
if (is_immediate) // immediate
{
//fprintf (stderr, "[DEBUG - load_mem - immediate]\n");
*value = target_address;
}
else if (is_simple) // simple
{
//fprintf (stderr, "[DEBUG - load_mem - simple]\n");
uint8_t mem_val;
*value = 0;
for (size_t i = 0; i < bytes; ++i)
{
memory_get (memory_manager, target_address + i, &mem_val);
*value = (*value << 8) + mem_val;
}
}
else if (is_indirect) // indirect
{
//fprintf (stderr, "[DEBUG - load_mem - indirect]\n");
uint32_t address = 0;
uint8_t mem_val;
for (int i = 0; i < 3; ++i)
{
memory_get (memory_manager, target_address + i, &mem_val);
address = (address << 8) + mem_val;
}
//fprintf (stderr, "[DEBUG - load_mem - indirect] final address = %08X\n", address);
*value = 0;
for (size_t i = 0; i < bytes; ++i)
{
memory_get (memory_manager, address + i, &mem_val);
*value = (*value << 8) + mem_val;
}
}
else
{
return false;
}
#undef CONTROL_INST
return true;
}
// TODO: range check.
static bool store_mem (struct memory_manager *memory_manager, const struct run_register_set *reg_set,
struct inst_param inst_param, uint32_t value, size_t bytes)
{
uint32_t target_address;
#define INST_PARAM(S) \
(inst_param.extend ? inst_param.param.f4_param.S : inst_param.param.f3_param.S)
if (INST_PARAM (b) == 1 && INST_PARAM (p) == 0) // Base relative
target_address = INST_PARAM (address) + reg_set->B;
else if (INST_PARAM (b) == 0 && INST_PARAM (p) == 1) // PC relative
{
int32_t value;
uint32_t boundary;
if (inst_param.extend)
boundary = (1 << 19);
else
boundary = (1 << 11);
if (INST_PARAM (address) >= boundary)
value = INST_PARAM (address) - (boundary << 1);
else
value = INST_PARAM (address);
target_address = reg_set->PC + value;
}
else
target_address = INST_PARAM (address);
if (INST_PARAM (x) == 1)
{
target_address += reg_set->X;
}
// fprintf (stderr, "[DEBUG - store_mem] address = %08X, target_address = %08X\n", INST_PARAM (address), target_address);
if (INST_PARAM (n) == 0 && INST_PARAM (i) == 1) // immediate
{
// WTF?
return false;
}
else if (INST_PARAM (n) == 1 && INST_PARAM (i) == 1) // simple
{
for (int i = bytes-1; i >= 0; --i)
{
memory_edit (memory_manager, target_address + i, value);
value >>= 8;
}
}
else if (INST_PARAM (n) == 1 && INST_PARAM (i) == 0) // indirect
{
uint8_t mem_val;
uint32_t address = 0;
for (int i = 0; i < 3; ++i)
{
memory_get (memory_manager, target_address + i, &mem_val);
address = (address << 8) + mem_val;
}
for (int i = 2; i >= 0; --i)
{
memory_edit (memory_manager, address + i, value);
value >>= 8;
}
}
else
{
return false;
}
#undef CONTROL_INST
return true;
}
static bool load_reg (struct run_register_set *reg_set, int reg_no, uint32_t *reg_val)
{
switch (reg_no)
{
case 0:
*reg_val = reg_set->A;
break;
case 1:
*reg_val = reg_set->X;
break;
case 2:
*reg_val = reg_set->L;
break;
case 3:
*reg_val = reg_set->B;
break;
case 4:
*reg_val = reg_set->S;
break;
case 5:
*reg_val = reg_set->T;
break;
case 6:
// *reg_val = reg_set->F;
return false; // Not supported.
case 8:
*reg_val = reg_set->PC;
break;
case 9:
*reg_val = reg_set->SW;
break;
default:
return false; // invalid
}
return true;
}
static bool store_reg (struct run_register_set *reg_set, int reg_no, uint32_t reg_val)
{
switch (reg_no)
{
case 0:
reg_set->A = reg_val;
break;
case 1:
reg_set->X = reg_val;
break;
case 2:
reg_set->L = reg_val;
break;
case 3:
reg_set->B = reg_val;
break;
case 4:
reg_set->S = reg_val;
break;
case 5:
reg_set->T = reg_val;
break;
case 6:
// reg_set->F = reg_val;
return false; // Not supported.
case 8:
reg_set->PC = reg_val;
break;
case 9:
reg_set->SW = reg_val;
break;
default:
return false;
}
return true;
}
static void _h_STA (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
store_mem (memory_manager, reg_set, inst_param, reg_set->A, 3);
}
static void _h_STL (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
store_mem (memory_manager, reg_set, inst_param, reg_set->L, 3);
}
static void _h_STCH (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
store_mem (memory_manager, reg_set, inst_param, reg_set->A & 0xFF, 1);
}
static void _h_STX (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
store_mem (memory_manager, reg_set, inst_param, reg_set->X, 3);
}
static void _h_LDA (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
load_mem (memory_manager, reg_set, inst_param, ®_set->A, 3, false);
}
static void _h_LDB (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
load_mem (memory_manager, reg_set, inst_param, ®_set->B, 3, false);
}
static void _h_LDT (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
load_mem (memory_manager, reg_set, inst_param, ®_set->T, 3, false);
}
static void _h_LDX (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
load_mem (memory_manager, reg_set, inst_param, ®_set->X, 3, false);
}
static void _h_LDCH (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
uint32_t value;
load_mem (memory_manager, reg_set, inst_param, &value, 1, false);
reg_set->A = (reg_set->A & 0xFFFFFF00) + (value & 0xFF);
}
static void _h_JSUB (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
uint32_t jump_address;
load_mem (memory_manager, reg_set, inst_param, &jump_address, 3, true);
// fprintf (stderr, "[DEBUG - JSUB] jump_address = %08X\n", jump_address);
reg_set->L = reg_set->PC;
reg_set->PC = jump_address;
}
static void _h_JEQ (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
if (reg_set->SW == 0)
{
load_mem (memory_manager, reg_set, inst_param, ®_set->PC, 3, true);
// fprintf (stderr, "[DEBUG - JEQ] jump_address = %08X\n", reg_set->PC);
}
}
static void _h_J (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
load_mem (memory_manager, reg_set, inst_param, ®_set->PC, 3, true);
}
static void _h_JLT (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
if ((int32_t) reg_set->SW < 0)
{
load_mem (memory_manager, reg_set, inst_param, ®_set->PC, 3, true);
// fprintf (stderr, "[DEBUG - JLT] jump_address = %08X\n", reg_set->PC);
}
}
static void _h_JGT (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
if ((int32_t) reg_set->SW > 0)
load_mem (memory_manager, reg_set, inst_param, ®_set->PC, 3, true);
}
static void _h_RSUB (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
reg_set->PC = reg_set->L;
}
static void _h_COMP (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
uint32_t value;
load_mem (memory_manager, reg_set, inst_param, &value, 3, false);
if (reg_set->A > value)
reg_set->SW = 1;
else if (reg_set->A < value)
reg_set->SW = -1;
else
reg_set->SW = 0;
}
static void _h_COMPR (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
uint32_t reg_val_1, reg_val_2;
load_reg (reg_set, inst_param.param.f2_param.r1, ®_val_1);
load_reg (reg_set, inst_param.param.f2_param.r2, ®_val_2);
if (reg_val_1 > reg_val_2)
reg_set->SW = 1;
else if (reg_val_1 < reg_val_2)
reg_set->SW = -1;
else
reg_set->SW = 0;
}
static void _h_TD (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
/* I/O instructions are not supported.
* This behavior is just for test */
// fprintf (stderr, "[DEBUG] TD\n");
reg_set->SW = 1;
}
static void _h_RD (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
/* I/O instructions are not supported.
* This behavior is just for test */
static char device_input_mock[] = "HELLO WORLD\0I'M TAEGUK\0";
static size_t device_input_idx = 0;
reg_set->A = (reg_set->A & 0xFFFFFF00) + (uint8_t) device_input_mock[device_input_idx++];
fprintf (stdout, "--- [Input Device] input = '%c'\n", (char)(reg_set->A & 0xFF));
if (device_input_idx >= sizeof(device_input_mock) / sizeof(char))
device_input_idx = 0;
}
static void _h_WD (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
/* I/O instructions are not supported.
* This behavior is just for test */
fprintf (stdout, "+++ [Output Device] output = '%c'\n", (char)(reg_set->A & 0xFF));
}
static void _h_CLEAR (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
store_reg (reg_set, inst_param.param.f2_param.r1, 0);
}
static void _h_TIXR (struct memory_manager *memory_manager, struct inst_param inst_param, struct run_register_set *reg_set)
{
uint32_t reg_val;
load_reg (reg_set, inst_param.param.f2_param.r1, ®_val);
++reg_set->X;
if (reg_set->X > reg_val)
reg_set->SW = 1;
else if (reg_set->X < reg_val)
reg_set->SW = -1;
else
reg_set->SW = 0;
}