summaryrefslogtreecommitdiffstats
path: root/ue4/mycpu/instructions.h
diff options
context:
space:
mode:
Diffstat (limited to 'ue4/mycpu/instructions.h')
-rw-r--r--ue4/mycpu/instructions.h80
1 files changed, 40 insertions, 40 deletions
diff --git a/ue4/mycpu/instructions.h b/ue4/mycpu/instructions.h
index fcff3e7..3f2fd51 100644
--- a/ue4/mycpu/instructions.h
+++ b/ue4/mycpu/instructions.h
@@ -19,7 +19,7 @@
19 * Syntax: inc R1 19 * Syntax: inc R1
20 * (R1++) 20 * (R1++)
21 */ 21 */
22template <class T> 22template<class T=CDat<int>, int width=0>
23class CInstructionInc 23class CInstructionInc
24 : public CInstruction<T> 24 : public CInstruction<T>
25{ 25{
@@ -45,7 +45,7 @@ class CInstructionInc
45 45
46/*----------------------------------------------------------------------------*/ 46/*----------------------------------------------------------------------------*/
47 47
48template <class T> 48template<class T=CDat<int>, int width=0>
49void CInstructionInc<T>::compile(std::list<std::string>& params) 49void CInstructionInc<T>::compile(std::list<std::string>& params)
50{ 50{
51 if (params.size() != 1) 51 if (params.size() != 1)
@@ -56,7 +56,7 @@ void CInstructionInc<T>::compile(std::list<std::string>& params)
56 56
57/*----------------------------------------------------------------------------*/ 57/*----------------------------------------------------------------------------*/
58 58
59template <class T> 59template<class T=CDat<int>, int width=0>
60void CInstructionInc<T>::execute(CCPU<T> *cpu) 60void CInstructionInc<T>::execute(CCPU<T> *cpu)
61{ 61{
62 assert(cpu != NULL); 62 assert(cpu != NULL);
@@ -74,7 +74,7 @@ void CInstructionInc<T>::execute(CCPU<T> *cpu)
74 * Syntax: dec R1 74 * Syntax: dec R1
75 * (R1--) 75 * (R1--)
76 */ 76 */
77template <class T> 77template<class T=CDat<int>, int width=0>
78class CInstructionDec 78class CInstructionDec
79 : public CInstruction<T> 79 : public CInstruction<T>
80{ 80{
@@ -100,7 +100,7 @@ class CInstructionDec
100 100
101/*----------------------------------------------------------------------------*/ 101/*----------------------------------------------------------------------------*/
102 102
103template <class T> 103template<class T=CDat<int>, int width=0>
104void CInstructionDec<T>::compile(std::list<std::string>& params) 104void CInstructionDec<T>::compile(std::list<std::string>& params)
105{ 105{
106 if (params.size() != 1) 106 if (params.size() != 1)
@@ -111,7 +111,7 @@ void CInstructionDec<T>::compile(std::list<std::string>& params)
111 111
112/*----------------------------------------------------------------------------*/ 112/*----------------------------------------------------------------------------*/
113 113
114template <class T> 114template<class T=CDat<int>, int width=0>
115void CInstructionDec<T>::execute(CCPU<T> *cpu) 115void CInstructionDec<T>::execute(CCPU<T> *cpu)
116{ 116{
117 assert(cpu != NULL); 117 assert(cpu != NULL);
@@ -129,7 +129,7 @@ void CInstructionDec<T>::execute(CCPU<T> *cpu)
129 * Syntax: add R1, R2, R3 129 * Syntax: add R1, R2, R3
130 * (R1 = R2 + R3) 130 * (R1 = R2 + R3)
131 */ 131 */
132template <class T> 132template<class T=CDat<int>, int width=0>
133class CInstructionAdd 133class CInstructionAdd
134 : public CInstruction<T> 134 : public CInstruction<T>
135{ 135{
@@ -159,7 +159,7 @@ class CInstructionAdd
159 159
160/*----------------------------------------------------------------------------*/ 160/*----------------------------------------------------------------------------*/
161 161
162template <class T> 162template<class T=CDat<int>, int width=0>
163void CInstructionAdd<T>::compile(std::list<std::string>& params) 163void CInstructionAdd<T>::compile(std::list<std::string>& params)
164{ 164{
165 if (params.size() != 3) 165 if (params.size() != 3)
@@ -174,7 +174,7 @@ void CInstructionAdd<T>::compile(std::list<std::string>& params)
174 174
175/*----------------------------------------------------------------------------*/ 175/*----------------------------------------------------------------------------*/
176 176
177template <class T> 177template<class T=CDat<int>, int width=0>
178void CInstructionAdd<T>::execute(CCPU<T> *cpu) 178void CInstructionAdd<T>::execute(CCPU<T> *cpu)
179{ 179{
180 assert(cpu != NULL); 180 assert(cpu != NULL);
@@ -195,7 +195,7 @@ void CInstructionAdd<T>::execute(CCPU<T> *cpu)
195 * Syntax: sub R1, R2, R3 195 * Syntax: sub R1, R2, R3
196 * (R1 = R2 - R3) 196 * (R1 = R2 - R3)
197 */ 197 */
198template <class T> 198template<class T=CDat<int>, int width=0>
199class CInstructionSub 199class CInstructionSub
200 : public CInstruction<T> 200 : public CInstruction<T>
201{ 201{
@@ -225,7 +225,7 @@ class CInstructionSub
225 225
226/*----------------------------------------------------------------------------*/ 226/*----------------------------------------------------------------------------*/
227 227
228template <class T> 228template<class T=CDat<int>, int width=0>
229void CInstructionSub<T>::compile(std::list<std::string>& params) 229void CInstructionSub<T>::compile(std::list<std::string>& params)
230{ 230{
231 if (params.size() != 3) 231 if (params.size() != 3)
@@ -240,7 +240,7 @@ void CInstructionSub<T>::compile(std::list<std::string>& params)
240 240
241/*----------------------------------------------------------------------------*/ 241/*----------------------------------------------------------------------------*/
242 242
243template <class T> 243template<class T=CDat<int>, int width=0>
244void CInstructionSub<T>::execute(CCPU<T> *cpu) 244void CInstructionSub<T>::execute(CCPU<T> *cpu)
245{ 245{
246 assert(cpu != NULL); 246 assert(cpu != NULL);
@@ -261,7 +261,7 @@ void CInstructionSub<T>::execute(CCPU<T> *cpu)
261 * Syntax: mul R1, R2, R3 261 * Syntax: mul R1, R2, R3
262 * (R1 = R2 * R3) 262 * (R1 = R2 * R3)
263 */ 263 */
264template <class T> 264template<class T=CDat<int>, int width=0>
265class CInstructionMul 265class CInstructionMul
266 : public CInstruction<T> 266 : public CInstruction<T>
267{ 267{
@@ -291,7 +291,7 @@ class CInstructionMul
291 291
292/*----------------------------------------------------------------------------*/ 292/*----------------------------------------------------------------------------*/
293 293
294template <class T> 294template<class T=CDat<int>, int width=0>
295void CInstructionMul<T>::compile(std::list<std::string>& params) 295void CInstructionMul<T>::compile(std::list<std::string>& params)
296{ 296{
297 if (params.size() != 3) 297 if (params.size() != 3)
@@ -306,7 +306,7 @@ void CInstructionMul<T>::compile(std::list<std::string>& params)
306 306
307/*----------------------------------------------------------------------------*/ 307/*----------------------------------------------------------------------------*/
308 308
309template <class T> 309template<class T=CDat<int>, int width=0>
310void CInstructionMul<T>::execute(CCPU<T> *cpu) 310void CInstructionMul<T>::execute(CCPU<T> *cpu)
311{ 311{
312 super::checkRegister(cpu, m_regidx1); 312 super::checkRegister(cpu, m_regidx1);
@@ -325,7 +325,7 @@ void CInstructionMul<T>::execute(CCPU<T> *cpu)
325 * Syntax: div R1, R2, R3 325 * Syntax: div R1, R2, R3
326 * (R1 = R2 / R3) 326 * (R1 = R2 / R3)
327 */ 327 */
328template <class T> 328template<class T=CDat<int>, int width=0>
329class CInstructionDiv 329class CInstructionDiv
330 : public CInstruction<T> 330 : public CInstruction<T>
331{ 331{
@@ -355,7 +355,7 @@ class CInstructionDiv
355 355
356/*----------------------------------------------------------------------------*/ 356/*----------------------------------------------------------------------------*/
357 357
358template <class T> 358template<class T=CDat<int>, int width=0>
359void CInstructionDiv<T>::compile(std::list<std::string>& params) 359void CInstructionDiv<T>::compile(std::list<std::string>& params)
360{ 360{
361 if (params.size() != 3) 361 if (params.size() != 3)
@@ -370,7 +370,7 @@ void CInstructionDiv<T>::compile(std::list<std::string>& params)
370 370
371/*----------------------------------------------------------------------------*/ 371/*----------------------------------------------------------------------------*/
372 372
373template <class T> 373template<class T=CDat<int>, int width=0>
374void CInstructionDiv<T>::execute(CCPU<T> *cpu) 374void CInstructionDiv<T>::execute(CCPU<T> *cpu)
375{ 375{
376 assert(cpu != NULL); 376 assert(cpu != NULL);
@@ -391,7 +391,7 @@ void CInstructionDiv<T>::execute(CCPU<T> *cpu)
391 * Syntax: load R1, R2 391 * Syntax: load R1, R2
392 * (R1 = memory[R2]) 392 * (R1 = memory[R2])
393 */ 393 */
394template <class T> 394template<class T=CDat<int>, int width=0>
395class CInstructionLoad 395class CInstructionLoad
396 : public CInstruction<T> 396 : public CInstruction<T>
397{ 397{
@@ -419,7 +419,7 @@ class CInstructionLoad
419 419
420/*----------------------------------------------------------------------------*/ 420/*----------------------------------------------------------------------------*/
421 421
422template <class T> 422template<class T=CDat<int>, int width=0>
423void CInstructionLoad<T>::compile(std::list<std::string>& params) 423void CInstructionLoad<T>::compile(std::list<std::string>& params)
424{ 424{
425 if (params.size() != 2) 425 if (params.size() != 2)
@@ -432,7 +432,7 @@ void CInstructionLoad<T>::compile(std::list<std::string>& params)
432 432
433/*----------------------------------------------------------------------------*/ 433/*----------------------------------------------------------------------------*/
434 434
435template <class T> 435template<class T=CDat<int>, int width=0>
436void CInstructionLoad<T>::execute(CCPU<T> *cpu) 436void CInstructionLoad<T>::execute(CCPU<T> *cpu)
437{ 437{
438 assert(cpu != NULL); 438 assert(cpu != NULL);
@@ -453,7 +453,7 @@ void CInstructionLoad<T>::execute(CCPU<T> *cpu)
453 * Syntax: store R1, R2 453 * Syntax: store R1, R2
454 * (memory[R2] = R1) 454 * (memory[R2] = R1)
455 */ 455 */
456template <class T> 456template<class T=CDat<int>, int width=0>
457class CInstructionStore 457class CInstructionStore
458 : public CInstruction<T> 458 : public CInstruction<T>
459{ 459{
@@ -481,7 +481,7 @@ class CInstructionStore
481 481
482/*----------------------------------------------------------------------------*/ 482/*----------------------------------------------------------------------------*/
483 483
484template <class T> 484template<class T=CDat<int>, int width=0>
485void CInstructionStore<T>::compile(std::list<std::string>& params) 485void CInstructionStore<T>::compile(std::list<std::string>& params)
486{ 486{
487 if (params.size() != 2) 487 if (params.size() != 2)
@@ -494,7 +494,7 @@ void CInstructionStore<T>::compile(std::list<std::string>& params)
494 494
495/*----------------------------------------------------------------------------*/ 495/*----------------------------------------------------------------------------*/
496 496
497template <class T> 497template<class T=CDat<int>, int width=0>
498void CInstructionStore<T>::execute(CCPU<T> *cpu) 498void CInstructionStore<T>::execute(CCPU<T> *cpu)
499{ 499{
500 assert(cpu != NULL); 500 assert(cpu != NULL);
@@ -515,7 +515,7 @@ void CInstructionStore<T>::execute(CCPU<T> *cpu)
515 * Syntax: test R1 515 * Syntax: test R1
516 * (R1 == 0: zeroflag: true, R1 < 0: signflag: true) 516 * (R1 == 0: zeroflag: true, R1 < 0: signflag: true)
517 */ 517 */
518template <class T> 518template<class T=CDat<int>, int width=0>
519class CInstructionTest 519class CInstructionTest
520 : public CInstruction<T> 520 : public CInstruction<T>
521{ 521{
@@ -541,7 +541,7 @@ class CInstructionTest
541 541
542/*----------------------------------------------------------------------------*/ 542/*----------------------------------------------------------------------------*/
543 543
544template <class T> 544template<class T=CDat<int>, int width=0>
545void CInstructionTest<T>::compile(std::list<std::string>& params) 545void CInstructionTest<T>::compile(std::list<std::string>& params)
546{ 546{
547 if (params.size() != 1) 547 if (params.size() != 1)
@@ -552,7 +552,7 @@ void CInstructionTest<T>::compile(std::list<std::string>& params)
552 552
553/*----------------------------------------------------------------------------*/ 553/*----------------------------------------------------------------------------*/
554 554
555template <class T> 555template<class T=CDat<int>, int width=0>
556void CInstructionTest<T>::execute(CCPU<T> *cpu) 556void CInstructionTest<T>::execute(CCPU<T> *cpu)
557{ 557{
558 assert(cpu != NULL); 558 assert(cpu != NULL);
@@ -572,7 +572,7 @@ void CInstructionTest<T>::execute(CCPU<T> *cpu)
572 * Implementation of assembler command "label" 572 * Implementation of assembler command "label"
573 * Syntax: label name: 573 * Syntax: label name:
574 */ 574 */
575template <class T> 575template<class T=CDat<int>, int width=0>
576class CInstructionLabel 576class CInstructionLabel
577 : public CInstruction<T> 577 : public CInstruction<T>
578{ 578{
@@ -604,7 +604,7 @@ class CInstructionLabel
604 * Syntax: jumpa labelname 604 * Syntax: jumpa labelname
605 * (jump to labelname) 605 * (jump to labelname)
606 */ 606 */
607template <class T> 607template<class T=CDat<int>, int width=0>
608class CInstructionJumpA 608class CInstructionJumpA
609 : public CInstruction<T> 609 : public CInstruction<T>
610{ 610{
@@ -630,7 +630,7 @@ class CInstructionJumpA
630 630
631/*----------------------------------------------------------------------------*/ 631/*----------------------------------------------------------------------------*/
632 632
633template <class T> 633template<class T=CDat<int>, int width=0>
634void CInstructionJumpA<T>::compile(std::list<std::string>& params) 634void CInstructionJumpA<T>::compile(std::list<std::string>& params)
635{ 635{
636 if (params.size() != 1) 636 if (params.size() != 1)
@@ -641,7 +641,7 @@ void CInstructionJumpA<T>::compile(std::list<std::string>& params)
641 641
642/*----------------------------------------------------------------------------*/ 642/*----------------------------------------------------------------------------*/
643 643
644template <class T> 644template<class T=CDat<int>, int width=0>
645void CInstructionJumpA<T>::execute(CCPU<T> *cpu) 645void CInstructionJumpA<T>::execute(CCPU<T> *cpu)
646{ 646{
647 assert(cpu != NULL); 647 assert(cpu != NULL);
@@ -661,7 +661,7 @@ void CInstructionJumpA<T>::execute(CCPU<T> *cpu)
661 * Syntax: jumpz labelname 661 * Syntax: jumpz labelname
662 * (jump to labelname if zeroflag) 662 * (jump to labelname if zeroflag)
663 */ 663 */
664template <class T> 664template<class T=CDat<int>, int width=0>
665class CInstructionJumpZ 665class CInstructionJumpZ
666 : public CInstruction<T> 666 : public CInstruction<T>
667{ 667{
@@ -687,7 +687,7 @@ class CInstructionJumpZ
687 687
688/*----------------------------------------------------------------------------*/ 688/*----------------------------------------------------------------------------*/
689 689
690template <class T> 690template<class T=CDat<int>, int width=0>
691void CInstructionJumpZ<T>::compile(std::list<std::string>& params) 691void CInstructionJumpZ<T>::compile(std::list<std::string>& params)
692{ 692{
693 if (params.size() != 1) 693 if (params.size() != 1)
@@ -698,7 +698,7 @@ void CInstructionJumpZ<T>::compile(std::list<std::string>& params)
698 698
699/*----------------------------------------------------------------------------*/ 699/*----------------------------------------------------------------------------*/
700 700
701template <class T> 701template<class T=CDat<int>, int width=0>
702void CInstructionJumpZ<T>::execute(CCPU<T> *cpu) 702void CInstructionJumpZ<T>::execute(CCPU<T> *cpu)
703{ 703{
704 assert(cpu != NULL); 704 assert(cpu != NULL);
@@ -720,7 +720,7 @@ void CInstructionJumpZ<T>::execute(CCPU<T> *cpu)
720 * Syntax: jumps labelname 720 * Syntax: jumps labelname
721 * (jump to labelname if signflag) 721 * (jump to labelname if signflag)
722 */ 722 */
723template <class T> 723template<class T=CDat<int>, int width=0>
724class CInstructionJumpS 724class CInstructionJumpS
725 : public CInstruction<T> 725 : public CInstruction<T>
726{ 726{
@@ -746,7 +746,7 @@ class CInstructionJumpS
746 746
747/*----------------------------------------------------------------------------*/ 747/*----------------------------------------------------------------------------*/
748 748
749template <class T> 749template<class T=CDat<int>, int width=0>
750void CInstructionJumpS<T>::compile(std::list<std::string>& params) 750void CInstructionJumpS<T>::compile(std::list<std::string>& params)
751{ 751{
752 if (params.size() != 1) 752 if (params.size() != 1)
@@ -757,7 +757,7 @@ void CInstructionJumpS<T>::compile(std::list<std::string>& params)
757 757
758/*----------------------------------------------------------------------------*/ 758/*----------------------------------------------------------------------------*/
759 759
760template <class T> 760template<class T=CDat<int>, int width=0>
761void CInstructionJumpS<T>::execute(CCPU<T> *cpu) 761void CInstructionJumpS<T>::execute(CCPU<T> *cpu)
762{ 762{
763 assert(cpu != NULL); 763 assert(cpu != NULL);
@@ -779,7 +779,7 @@ void CInstructionJumpS<T>::execute(CCPU<T> *cpu)
779 * Syntax: write DEV, R1 779 * Syntax: write DEV, R1
780 * (write R1 to DEV, which is a name of a display) 780 * (write R1 to DEV, which is a name of a display)
781 */ 781 */
782template <class T> 782template<class T=CDat<int>, int width=0>
783class CInstructionWrite 783class CInstructionWrite
784 : public CInstruction<T> 784 : public CInstruction<T>
785{ 785{
@@ -808,7 +808,7 @@ class CInstructionWrite
808 808
809/*----------------------------------------------------------------------------*/ 809/*----------------------------------------------------------------------------*/
810 810
811template <class T> 811template<class T=CDat<int>, int width=0>
812void CInstructionWrite<T>::compile(std::list<std::string>& params) 812void CInstructionWrite<T>::compile(std::list<std::string>& params)
813{ 813{
814 if (params.size() != 2) 814 if (params.size() != 2)
@@ -821,7 +821,7 @@ void CInstructionWrite<T>::compile(std::list<std::string>& params)
821 821
822/*----------------------------------------------------------------------------*/ 822/*----------------------------------------------------------------------------*/
823 823
824template <class T> 824template<class T=CDat<int>, int width=0>
825void CInstructionWrite<T>::execute(CCPU<T> *cpu) 825void CInstructionWrite<T>::execute(CCPU<T> *cpu)
826{ 826{
827 assert(cpu != NULL); 827 assert(cpu != NULL);