simulavr  1.1.0
decoder.h
Go to the documentation of this file.
1 /*
2  ****************************************************************************
3  *
4  * simulavr - A simulator for the Atmel AVR family of microcontrollers.
5  * Copyright (C) 2001, 2002, 2003 Theodore A. Roth, Klaus Rudolph
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  ****************************************************************************
22  *
23  * $Id$
24  */
25 
26 #ifndef DECODER
27 #define DECODER
28 
29 #include <iostream>
30 
31 #include "rwmem.h"
32 #include "types.h"
33 #include "avrdevice.h"
34 
35 class AvrFlash;
36 
38 
40 
41  protected:
43  bool size2Word;
44 
45  public:
46  DecodedInstruction(AvrDevice *c, bool s2w = false): core(c), size2Word(s2w) {}
47  virtual ~DecodedInstruction() {}
48 
50  bool IsInstruction2Words() { return size2Word; }
51 
53  virtual int operator()() = 0;
55  virtual int Trace() = 0;
57  virtual unsigned char GetModifiedR() const {return -1;}
59  virtual unsigned char GetModifiedRHi() const {return -1;}
60 };
61 
64 
66  /*
67  * Add with Carry.
68  *
69  * Opcode : 0001 11rd dddd rrrr
70  * Usage : ADC Rd, Rr
71  * Operation : Rd <- Rd + Rr + C
72  * Flags : Z,C,N,V,S,H
73  * Num Clocks : 1
74  */
75  protected:
76  unsigned char R1;
77  unsigned char R2;
79 
80  public:
81  avr_op_ADC(word opcode, AvrDevice *c);
82  virtual unsigned char GetModifiedR() const;
83  int operator()();
84  int Trace();
85 }; //end of class
86 
88  /*
89  * Add without Carry.
90  *
91  * Opcode : 0000 11rd dddd rrrr
92  * Usage : ADD Rd, Rr
93  * Operation : Rd <- Rd + Rr
94  * Flags : Z,C,N,V,S,H
95  * Num Clocks : 1
96  */
97  protected:
98  unsigned char R1;
99  unsigned char R2;
101 
102  public:
103  avr_op_ADD(word opcode, AvrDevice *c);
104  virtual unsigned char GetModifiedR() const;
105  int operator()();
106  int Trace();
107 }; //end of class
108 
109 
110 
111 
113 {
114  /*
115  * Add Immediate to Word.
116  *
117  * Opcode : 1001 0110 KKdd KKKK
118  * Usage : ADIW Rd, K
119  * Operation : Rd+1:Rd <- Rd+1:Rd + K
120  * Flags : Z,C,N,V,S
121  * Num Clocks : 2
122  */
123 
124  protected:
125  unsigned char Rl;
126  unsigned char Rh;
127  unsigned char K;
129 
130  public:
131  avr_op_ADIW(word opcode, AvrDevice *c);
132  virtual unsigned char GetModifiedR() const;
133  virtual unsigned char GetModifiedRHi() const;
134  int operator()();
135  int Trace();
136 };
137 
139 {
140  /*
141  * Logical AND.
142  *
143  * Opcode : 0010 00rd dddd rrrr
144  * Usage : AND Rd, Rr
145  * Operation : Rd <- Rd & Rr
146  * Flags : Z,N,V,S
147  * Num Clocks : 1
148  */
149 
150  protected:
151  unsigned char R1;
152  unsigned char R2;
154 
155  public:
156  avr_op_AND(word opcode, AvrDevice *c);
157  int operator()();
158  int Trace();
159 };
160 
162 {
163  /*
164  * Logical AND with Immed.
165  *
166  * Opcode : 0111 KKKK dddd KKKK
167  * Usage : ANDI Rd, K
168  * Operation : Rd <- Rd & K
169  * Flags : Z,N,V,S
170  * Num Clocks : 1
171  */
172 
173  protected:
174  unsigned char R1;
175  unsigned char K;
177 
178  public:
179  avr_op_ANDI(word opcode, AvrDevice *c);
180  int operator()();
181  int Trace();
182 };
183 
185 {
186  /*
187  * Arithmetic Shift Right.
188  *
189  * Opcode : 1001 010d dddd 0101
190  * Usage : ASR Rd
191  * Operation : Rd(n) <- Rd(n+1), n=0..6
192  * Flags : Z,C,N,V,S
193  * Num Clocks : 1
194  */
195 
196  protected:
197  unsigned char R1;
199 
200  public:
201  avr_op_ASR(word opcode, AvrDevice *c);
202  int operator()();
203  int Trace();
204 };
205 
207 {
208  /*
209  * Clear a single flag or bit in SREG.
210  *
211  * Opcode : 1001 0100 1sss 1000
212  * Usage : BCLR
213  * Operation : SREG(s) <- 0
214  * Flags : SREG(s)
215  * Num Clocks : 1
216  */
217 
218  protected:
220  unsigned char Kbit;
221 
222  public:
223  avr_op_BCLR(word opcode, AvrDevice *c);
224  int operator()();
225  int Trace();
226 };
227 
228 
230 {
231  /* Bit load from T to Register.
232  *
233  * Opcode : 1111 100d dddd 0bbb
234  * Usage : BLD Rd, b
235  * Operation : Rd(b) <- T
236  * Flags : None
237  * Num Clocks : 1
238  */
239 
240  protected:
241  unsigned char R1;
242  unsigned char Kbit;
244 
245  public:
246  avr_op_BLD(word opcode, AvrDevice *c);
247  int operator()();
248  int Trace();
249 };
250 
252 {
253  /*
254  * Branch if Status Flag Cleared.
255  *
256  * Pass control directly to the specific bit operation.
257  *
258  * Opcode : 1111 01kk kkkk ksss
259  * Usage : BRBC s, k
260  * Operation : if (SREG(s) = 0) then PC <- PC + k + 1
261  * Flags : None
262  * Num Clocks : 1 / 2
263  *
264  * k is an relative address represented in two's complements.
265  * (64 < k <= 64)
266  */
267 
268  protected:
270  unsigned char bitmask;
271  signed char offset;
272 
273  public:
274  avr_op_BRBC(word opcode, AvrDevice *c);
275  int operator()();
276  int Trace();
277 };
278 
280 {
281  /*
282  * Branch if Status Flag Set.
283  *
284  * Pass control directly to the specific bit operation.
285  *
286  * Opcode : 1111 00kk kkkk ksss
287  * Usage : BRBS s, k
288  * Operation : if (SREG(s) = 1) then PC <- PC + k + 1
289  * Flags : None
290  * Num Clocks : 1 / 2
291  *
292  * k is an relative address represented in two's complements.
293  * (64 < k <= 64)
294  */
295 
296  protected:
298  unsigned char bitmask;
299  signed char offset;
300 
301  public:
302  avr_op_BRBS(word opcode, AvrDevice *c);
303  int operator()();
304  int Trace();
305 };
306 
308 {
309  /*
310  * Set a single flag or bit in SREG.
311  *
312  * Opcode : 1001 0100 0sss 1000
313  * Usage : BSET
314  * Operation : SREG(s) <- 1
315  * Flags : SREG(s)
316  * Num Clocks : 1
317  */
318 
319  protected:
321  unsigned char Kbit;
322 
323  public:
324  avr_op_BSET(word opcode, AvrDevice *c);
325  int operator()();
326  int Trace();
327 };
328 
330 {
331  /*
332  * Bit Store from Register to T.
333  *
334  * Opcode : 1111 101d dddd 0bbb
335  * Usage : BST Rd, b
336  * Operation : T <- Rd(b)
337  * Flags : T
338  * Num Clocks : 1
339  */
340 
341  protected:
342  unsigned char R1;
343  unsigned char Kbit;
345 
346  public:
347  avr_op_BST(word opcode, AvrDevice *c);
348  int operator()();
349  int Trace();
350 
351 };
352 
354 {
355  /*
356  * Call Subroutine.
357  *
358  * Opcode : 1001 010k kkkk 111k kkkk kkkk kkkk kkkk
359  * Usage : CALL k
360  * Operation : PC <- k
361  * Flags : None
362  * Num Clocks : 3 / 4 / 5
363  */
364 
365  protected:
366  unsigned char KH;
367 
368  public:
369  avr_op_CALL(word opcode, AvrDevice *c);
370  int operator()();
371  int Trace();
372 };
373 
375 {
376  /*
377  * Clear Bit in I/O Register.
378  *
379  * Opcode : 1001 1000 AAAA Abbb
380  * Usage : CBI A, b
381  * Operation : I/O(A, b) <- 0
382  * Flags : None
383  * Num Clocks : 1 / 2
384  */
385 
386  protected:
387  unsigned char ioreg;
388  unsigned char Kbit;
390 
391  public:
392  avr_op_CBI(word opcode, AvrDevice *c);
393  int operator()();
394  int Trace();
395 };
396 
398 {
399  /*
400  * One's Complement.
401  *
402  * Opcode : 1001 010d dddd 0000
403  * Usage : COM Rd
404  * Operation : Rd <- $FF - Rd
405  * Flags : Z,C,N,V,S
406  * Num Clocks : 1
407  */
408 
409  protected:
410  unsigned char R1;
412 
413  public:
414  avr_op_COM(word opcode, AvrDevice *c);
415  int operator()();
416  int Trace();
417 };
418 
420 {
421  /*
422  * Compare.
423  *
424  * Opcode : 0001 01rd dddd rrrr
425  * Usage : CP Rd, Rr
426  * Operation : Rd - Rr
427  * Flags : Z,C,N,V,S,H
428  * Num Clocks : 1
429  */
430 
431  protected:
432  unsigned char R1;
433  unsigned char R2;
435 
436  public:
437  avr_op_CP(word opcode, AvrDevice *c);
438  int operator()();
439  int Trace();
440 };
441 
443 {
444  /*
445  * Compare with Carry.
446  *
447  * Opcode : 0000 01rd dddd rrrr
448  * Usage : CPC Rd, Rr
449  * Operation : Rd - Rr - C
450  * Flags : Z,C,N,V,S,H
451  * Num Clocks : 1
452  */
453 
454  protected:
455  unsigned char R1;
456  unsigned char R2;
458 
459  public:
460  avr_op_CPC(word opcode, AvrDevice *c);
461  int operator()();
462  int Trace();
463 };
464 
466 {
467  /*
468  * Compare with Immediate.
469  *
470  * Opcode : 0011 KKKK dddd KKKK
471  * Usage : CPI Rd, K
472  * Operation : Rd - K
473  * Flags : Z,C,N,V,S,H
474  * Num Clocks : 1
475  */
476 
477  protected:
478  unsigned char R1;
479  unsigned char K;
481 
482  public:
483  avr_op_CPI(word opcode, AvrDevice *c);
484  int operator()();
485  int Trace();
486 
487 };
488 
490 {
491  /*
492  * Compare, Skip if Equal.
493  *
494  * Opcode : 0001 00rd dddd rrrr
495  * Usage : CPSE Rd, Rr
496  * Operation : if (Rd = Rr) PC <- PC + 2 or 3
497  * Flags : None
498  * Num Clocks : 1 / 2 / 3
499  */
500 
501  protected:
502  unsigned char R1;
503  unsigned char R2;
505 
506  public:
507  avr_op_CPSE(word opcode, AvrDevice *c);
508  int operator()();
509  int Trace();
510 };
511 
513 {
514  /*
515  * Decrement.
516  *
517  * Opcode : 1001 010d dddd 1010
518  * Usage : DEC Rd
519  * Operation : Rd <- Rd - 1
520  * Flags : Z,N,V,S
521  * Num Clocks : 1
522  */
523 
524  protected:
525  unsigned char R1;
527 
528  public:
529  avr_op_DEC(word opcode, AvrDevice *c);
530  int operator()();
531  int Trace();
532 };
533 
535 {
536  /*
537  * Extended Indirect Call to (Z).
538  *
539  * Opcode : 1001 0101 0001 1001
540  * Usage : EICALL
541  * Operation : PC(15:0) <- Z, PC(21:16) <- EIND
542  * Flags : None
543  * Num Clocks : 4
544  */
545 
546  public:
547  avr_op_EICALL(word opcode, AvrDevice *c);
548  int operator()();
549  int Trace();
550 };
551 
553 {
554  /*
555  * Extended Indirect Jmp to (Z).
556  *
557  * Opcode : 1001 0100 0001 1001
558  * Usage : EIJMP
559  * Operation : PC(15:0) <- Z, PC(21:16) <- EIND
560  * Flags : None
561  * Num Clocks : 2
562  */
563 
564  public:
565  avr_op_EIJMP(word opcode, AvrDevice *c);
566  int operator()();
567  int Trace();
568 };
569 
571 {
572  /*
573  * Extended Load Program Memory.
574  *
575  * Opcode : 1001 000d dddd 0110
576  * Usage : ELPM Rd, Z
577  * Operation : R <- (RAMPZ:Z)
578  * Flags : None
579  * Num Clocks : 3
580  */
581 
582  protected:
583  unsigned char R1;
584 
585  public:
586  avr_op_ELPM_Z(word opcode, AvrDevice *c);
587  int operator()();
588  int Trace();
589 };
590 
592 {
593  /*
594  * Extended Ld Prg Mem and Post-Incr.
595  *
596  * Opcode : 1001 000d dddd 0111
597  * Usage : ELPM Rd, Z+
598  * Operation : Rd <- (RAMPZ:Z), Z <- Z + 1
599  * Flags : None
600  * Num Clocks : 3
601  */
602 
603  protected:
604  unsigned char R1;
605 
606  public:
607  avr_op_ELPM_Z_incr(word opcode, AvrDevice *c);
608  int operator()();
609  int Trace();
610 };
611 
613 {
614  /*
615  * Extended Load Program Memory.
616  *
617  *
618  * Opcode : 1001 0101 1101 1000
619  * Usage : ELPM
620  * Operation : R0 <- (RAMPZ:Z)
621  * Flags : None
622  * Num Clocks : 3
623  */
624 
625  public:
626  avr_op_ELPM(word opcode, AvrDevice *c);
627  int operator()();
628  int Trace();
629 };
630 
632 {
633  /*
634  * Exclusive OR.
635  *
636  * Opcode : 0010 01rd dddd rrrr
637  * Usage : EOR Rd, Rr
638  * Operation : Rd <- Rd ^ Rr
639  * Flags : Z,N,V,S
640  * Num Clocks : 1
641  */
642 
643  protected:
644  unsigned char R1;
645  unsigned char R2;
647 
648  public:
649  avr_op_EOR(word opcode, AvrDevice *c);
650  int operator()();
651  int Trace();
652 };
653 
655 {
656  /*
657  * Extended Store Program Memory.
658  * (In datasheet: "SPM #2– Store Program Memory")
659  *
660  * Opcode : 1001 0101 1111 1000
661  * Usage : ESPM
662  * Operation : (RAMPZ:Z) <- R1:R0
663  * Flags : None
664  * Num Clocks : -
665  */
666 
667  public:
668  avr_op_ESPM(word opcode, AvrDevice *c);
669  int operator()();
670  int Trace();
671 };
672 
674 {
675  /*
676  * Fractional Mult Unsigned.
677  *
678  * Opcode : 0000 0011 0ddd 1rrr
679  * Usage : FMUL Rd, Rr
680  * Operation : R1:R0 <- (Rd * Rr)<<1 (UU)
681  * Flags : Z,C
682  * Num Clocks : 2
683  */
684 
685  protected:
686  unsigned char Rd;
687  unsigned char Rr;
689 
690  public:
691  avr_op_FMUL(word opcode, AvrDevice *c);
692  int operator()();
693  int Trace();
694 };
695 
697 {
698  /*
699  * Fractional Mult Signed.
700  *
701  * Opcode : 0000 0011 1ddd 0rrr
702  * Usage : FMULS Rd, Rr
703  * Operation : R1:R0 <- (Rd * Rr)<<1 (SS)
704  * Flags : Z,C
705  * Num Clocks : 2
706  */
707 
708  protected:
709  unsigned char Rd;
710  unsigned char Rr;
712 
713  public:
714  avr_op_FMULS(word opcode, AvrDevice *c);
715  int operator()();
716  int Trace();
717 };
718 
720 {
721  /*
722  * Fract Mult Signed w/ Unsigned.
723  *
724  * Opcode : 0000 0011 1ddd 1rrr
725  * Usage : FMULSU Rd, Rr
726  * Operation : R1:R0 <- (Rd * Rr)<<1 (SU)
727  * Flags : Z,C
728  * Num Clocks : 2
729  */
730 
731  protected:
732  unsigned char Rd;
733  unsigned char Rr;
735 
736  public:
737  avr_op_FMULSU(word opcode, AvrDevice *c);
738  int operator()();
739  int Trace();
740 };
741 
743 {
744  /*
745  * Indirect Call to (Z).
746  *
747  * Opcode : 1001 0101 0000 1001
748  * Usage : ICALL
749  * Operation : PC(15:0) <- Z, PC(21:16) <- 0
750  * Flags : None
751  * Num Clocks : 3 / 4
752  */
753 
754  public:
755  avr_op_ICALL(word opcode, AvrDevice *c);
756  int operator()();
757  int Trace();
758 };
759 
761 {
762  /*
763  * Indirect Jump to (Z).
764  *
765  * Opcode : 1001 0100 0000 1001
766  * Usage : IJMP
767  * Operation : PC(15:0) <- Z, PC(21:16) <- 0
768  * Flags : None
769  * Num Clocks : 2
770  */
771 
772  public:
773  avr_op_IJMP (word opcode, AvrDevice *c);
774  int operator()();
775  int Trace();
776 };
777 
779 {
780  /*
781  * In From I/O Location.
782  *
783  * Opcode : 1011 0AAd dddd AAAA
784  * Usage : IN Rd, A
785  * Operation : Rd <- I/O(A)
786  * Flags : None
787  * Num Clocks : 1
788  */
789 
790  protected:
791  unsigned char R1;
792  unsigned char ioreg;
793 
794  public:
795  avr_op_IN(word opcode, AvrDevice *c);
796  int operator()();
797  int Trace();
798 };
799 
801 {
802  /*
803  * Increment.
804  *
805  * Opcode : 1001 010d dddd 0011
806  * Usage : INC Rd
807  * Operation : Rd <- Rd + 1
808  * Flags : Z,N,V,S
809  * Num Clocks : 1
810  */
811 
812  protected:
813  unsigned char R1;
815 
816  public:
817  avr_op_INC(word opcode, AvrDevice *c);
818  int operator()();
819  int Trace();
820 };
821 
823 {
824  /*
825  * Jump.
826  *
827  * Opcode : 1001 010k kkkk 110k kkkk kkkk kkkk kkkk
828  * Usage : JMP k
829  * Operation : PC <- k
830  * Flags : None
831  * Num Clocks : 3
832  */
833 
834  protected:
835  unsigned int K;
836 
837  public:
838  avr_op_JMP (word opcode, AvrDevice *c);
839  int operator()();
840  int Trace();
841 };
842 
844 {
845  /*
846  * Load Indirect with Displacement using index Y.
847  *
848  * Opcode : 10q0 qq0d dddd 1qqq
849  * Usage : LDD Rd, Y+q
850  * Operation : Rd <- (Y + q)
851  * Flags : None
852  * Num Clocks : 2
853  */
854 
855  protected:
856  unsigned char Rd;
857  unsigned char K;
858 
859  public:
860  avr_op_LDD_Y(word opcode, AvrDevice *c);
861  int operator()();
862  int Trace();
863 };
864 
866 {
867  /*
868  * Load Indirect with Displacement using index Z.
869  *
870  * Opcode : 10q0 qq0d dddd 0qqq
871  * Usage : LDD Rd, Z+q
872  * Operation : Rd <- (Z + q)
873  * Flags : None
874  * Num Clocks : 2
875  */
876 
877  protected:
878  unsigned char Rd;
879  unsigned char K;
880 
881  public:
882  avr_op_LDD_Z(word opcode, AvrDevice *c);
883  int operator()();
884  int Trace();
885 };
886 
888 {
889  /*
890  * Load Immediate.
891  *
892  * Opcode : 1110 KKKK dddd KKKK
893  * Usage : LDI Rd, K
894  * Operation : Rd <- K
895  * Flags : None
896  * Num Clocks : 1
897  */
898 
899  protected:
900  unsigned char R1;
901  unsigned char K;
902 
903  public:
904  avr_op_LDI(word opcode, AvrDevice *c);
905  virtual unsigned char GetModifiedR() const;
906  int operator()();
907  int Trace();
908 };
909 
911 {
912  /*
913  * Load Direct from data space.
914  *
915  * Opcode : 1001 000d dddd 0000 kkkk kkkk kkkk kkkk
916  * Usage : LDS Rd, k
917  * Operation : Rd <- (k)
918  * Flags : None
919  * Num Clocks : 2
920  */
921 
922  protected:
923  unsigned char R1;
924 
925  public:
926  avr_op_LDS(word opcode, AvrDevice *c);
927  int operator()();
928  int Trace();
929 };
930 
932 {
933  /*
934  * Load Indirect using index X.
935  *
936  * Opcode : 1001 000d dddd 1100
937  * Usage : LD Rd, X
938  * Operation : Rd <- (X)
939  * Flags : None
940  * Num Clocks : 2
941  */
942 
943  protected:
944  unsigned char Rd;
945 
946  public:
947  avr_op_LD_X(word opcode, AvrDevice *c);
948  int operator()();
949  int Trace();
950 };
951 
953 {
954  /*
955  * Load Indirect and Pre-Decrement using index X.
956  *
957  * Opcode : 1001 000d dddd 1110
958  * Usage : LD Rd, -X
959  * Operation : X <- X - 1, Rd <- (X)
960  * Flags : None
961  * Num Clocks : 2
962  */
963 
964  protected:
965  unsigned char Rd;
966 
967  public:
968  avr_op_LD_X_decr(word opcode, AvrDevice *c);
969  int operator()();
970  int Trace();
971 };
972 
974 {
975  /*
976  * Load Indirect and Post-Increment using index X.
977  *
978  * Opcode : 1001 000d dddd 1101
979  * Usage : LD Rd, X+
980  * Operation : Rd <- (X), X <- X + 1
981  * Flags : None
982  * Num Clocks : 2
983  */
984 
985  protected:
986  unsigned char Rd;
987 
988  public:
989  avr_op_LD_X_incr(word opcode, AvrDevice *c);
990  int operator()();
991  int Trace();
992 };
993 
995 {
996  /*
997  * Load Indirect and PreDecrement using index Y.
998  *
999  * Opcode : 1001 000d dddd 1010
1000  * Usage : LD Rd, -Y
1001  * Operation : Y <- Y - 1, Rd <- (Y)
1002  * Flags : None
1003  * Num Clocks : 2
1004  */
1005 
1006 
1007  protected:
1008  unsigned char Rd;
1009 
1010  public:
1011  avr_op_LD_Y_decr(word opcode, AvrDevice *c);
1012  int operator()();
1013  int Trace();
1014 };
1015 
1017 {
1018  /*
1019  * Load Indirect and Post-Increment using index Y.
1020  *
1021  * Opcode : 1001 000d dddd 1001
1022  * Usage : LD Rd, Y+
1023  * Operation : Rd <- (Y), Y <- Y + 1
1024  * Flags : None
1025  * Num Clocks : 2
1026  */
1027 
1028  protected:
1029  unsigned char Rd;
1030 
1031  public:
1032  avr_op_LD_Y_incr(word opcode, AvrDevice *c);
1033  int operator()();
1034  int Trace();
1035 };
1036 
1038 {
1039  /*
1040  * Load Indirect and Post-Increment using index Z.
1041  *
1042  * Opcode : 1001 000d dddd 0001
1043  * Usage : LD Rd, Z+
1044  * Operation : Rd <- (Z), Z <- Z+1
1045  * Flags : None
1046  * Num Clocks : 2
1047  */
1048 
1049  protected:
1050  unsigned char Rd;
1051 
1052  public:
1053  avr_op_LD_Z_incr(word opcode, AvrDevice *c);
1054  int operator()();
1055  int Trace();
1056 };
1057 
1059 {
1060  /*
1061  * Load Indirect and Pre-Decrement using index Z.
1062  *
1063  * Opcode : 1001 000d dddd 0010
1064  * Usage : LD Rd, -Z
1065  * Operation : Z <- Z - 1, Rd <- (Z)
1066  * Flags : None
1067  * Num Clocks : 2
1068  */
1069 
1070  protected:
1071  unsigned char Rd;
1072 
1073  public:
1074  avr_op_LD_Z_decr(word opcode, AvrDevice *c);
1075  int operator()();
1076  int Trace();
1077 };
1078 
1080 {
1081  /*
1082  * Load Program Memory.
1083  *
1084  * Opcode : 1001 000d dddd 0100
1085  * Usage : LPM Rd, Z
1086  * Operation : Rd <- (Z)
1087  * Flags : None
1088  * Num Clocks : 3
1089  */
1090 
1091  protected:
1092  unsigned char Rd;
1093 
1094  public:
1095  avr_op_LPM_Z(word opcode, AvrDevice *c);
1096  int operator()();
1097  int Trace();
1098 };
1099 
1101 {
1102  /* Load Program Memory.
1103  *
1104  * This the same as avr_op_LPM_Z:public DecodedInstruction
1105  *
1106  * Opcode : 1001 0101 1100 1000
1107  * Usage : LPM
1108  * Operation : R0 <- (Z)
1109  * Flags : None
1110  * Num Clocks : 3
1111  */
1112  //return avr_op_LPM_Z:public DecodedInstruction
1113 
1114  public:
1115  avr_op_LPM(word opcode, AvrDevice *c);
1116  int operator()();
1117  int Trace();
1118 };
1119 
1121 {
1122  /*
1123  * Load Program Memory and Post-Incr.
1124  *
1125  * Opcode : 1001 000d dddd 0101
1126  * Usage : LPM Rd, Z+
1127  * Operation : Rd <- (Z), Z <- Z + 1
1128  * Flags : None
1129  * Num Clocks : 3
1130  */
1131 
1132  protected:
1133  unsigned char Rd;
1134 
1135  public:
1136  avr_op_LPM_Z_incr(word opcode, AvrDevice *c);
1137  int operator()();
1138  int Trace();
1139 };
1140 
1142 {
1143  /*
1144  * Logical Shift Right.
1145  *
1146  * Opcode : 1001 010d dddd 0110
1147  * Usage : LSR Rd
1148  * Operation : Rd(n) <- Rd(n+1), Rd(7) <- 0, C <- Rd(0)
1149  * Flags : Z,C,N,V,S
1150  * Num Clocks : 1
1151  */
1152 
1153  protected:
1154  unsigned char Rd;
1156 
1157  public:
1158  avr_op_LSR(word opcode, AvrDevice *c);
1159  int operator()();
1160  int Trace();
1161 };
1162 
1164 {
1165  /* Copy Register.
1166  *
1167  * Opcode : 0010 11rd dddd rrrr
1168  * Usage : MOV Rd, Rr
1169  * Operation : Rd <- Rr
1170  * Flags : None
1171  * Num Clocks : 1
1172  */
1173 
1174  protected:
1175  unsigned char R1;
1176  unsigned char R2;
1177 
1178  public:
1179  avr_op_MOV(word opcode, AvrDevice *c);
1180  int operator()();
1181  int Trace();
1182 };
1183 
1185 {
1186  /*
1187  *Copy Register Pair.
1188  *
1189  * Opcode : 0000 0001 dddd rrrr
1190  * Usage : MOVW Rd, Rr
1191  * Operation : Rd+1:Rd <- Rr+1:Rr
1192  * Flags : None
1193  * Num Clocks : 1
1194  */
1195 
1196  protected:
1197  unsigned char Rd;
1198  unsigned char Rs;
1199 
1200  public:
1201  avr_op_MOVW(word opcode, AvrDevice *c);
1202  int operator()();
1203  int Trace();
1204 };
1205 
1207 {
1208  /*
1209  * Mult Unsigned.
1210  *
1211  * Opcode : 1001 11rd dddd rrrr
1212  * Usage : MUL Rd, Rr
1213  * Operation : R1:R0 <- Rd * Rr (UU)
1214  * Flags : Z,C
1215  * Num Clocks : 2
1216  */
1217 
1218  protected:
1219  unsigned char Rd;
1220  unsigned char Rr;
1222 
1223  public:
1224  avr_op_MUL(word opcode, AvrDevice *c);
1225  int operator()();
1226  int Trace();
1227 };
1228 
1230 {
1231  /*
1232  * Mult Signed.
1233  *
1234  * Opcode : 0000 0010 dddd rrrr
1235  * Usage : MULS Rd, Rr
1236  * Operation : R1:R0 <- Rd * Rr (SS)
1237  * Flags : Z,C
1238  * Num Clocks : 2
1239  */
1240 
1241  protected:
1242  unsigned char Rd;
1243  unsigned char Rr;
1245 
1246  public:
1247  avr_op_MULS(word opcode, AvrDevice *c);
1248  int operator()();
1249  int Trace();
1250 };
1251 
1253 {
1254  /*
1255  * Mult Signed with Unsigned.
1256  *
1257  * Rd(unsigned),Rr(signed), result (signed)
1258  *
1259  * Opcode : 0000 0011 0ddd 0rrr
1260  * Usage : MULSU Rd, Rr
1261  * Operation : R1:R0 <- Rd * Rr (SU)
1262  * Flags : Z,C
1263  * Num Clocks : 2
1264  */
1265 
1266 
1267  protected:
1268  unsigned char Rd;
1269  unsigned char Rr;
1271 
1272  public:
1273  avr_op_MULSU(word opcode, AvrDevice *c);
1274  int operator()();
1275  int Trace();
1276 };
1277 
1279 {
1280  /*
1281  * Two's Complement.
1282  *
1283  * Opcode : 1001 010d dddd 0001
1284  * Usage : NEG Rd
1285  * Operation : Rd <- $00 - Rd
1286  * Flags : Z,C,N,V,S,H
1287  * Num Clocks : 1
1288  */
1289 
1290  protected:
1291  unsigned char Rd;
1293 
1294  public:
1295  avr_op_NEG(word opcode, AvrDevice *c);
1296  int operator()();
1297  int Trace();
1298 };
1299 
1301 {
1302  /*
1303  * No Operation.
1304  *
1305  * Opcode : 0000 0000 0000 0000
1306  * Usage : NOP
1307  * Operation : None
1308  * Flags : None
1309  * Num Clocks : 1
1310  */
1311 
1312 
1313  public:
1314  avr_op_NOP(word opcode, AvrDevice *c);
1315  int operator()();
1316  int Trace();
1317 };
1318 
1320 {
1321  /*
1322  * Logical OR.
1323  *
1324  * Opcode : 0010 10rd dddd rrrr
1325  * Usage : OR Rd, Rr
1326  * Operation : Rd <- Rd or Rr
1327  * Flags : Z,N,V,S
1328  * Num Clocks : 1
1329  */
1330 
1331  protected:
1332  unsigned char Rd;
1333  unsigned char Rr;
1335 
1336  public:
1337  avr_op_OR(word opcode, AvrDevice *c);
1338  int operator()();
1339  int Trace();
1340 };
1341 
1343 {
1344  /*
1345  * Logical OR with Immed.
1346  *
1347  * Opcode : 0110 KKKK dddd KKKK
1348  * Usage : ORI Rd, K
1349  * Operation : Rd <- Rd or K
1350  * Flags : Z,N,V,S
1351  * Num Clocks : 1
1352  */
1353 
1354  protected:
1355  unsigned char R1;
1356  unsigned char K;
1358 
1359  public:
1360  avr_op_ORI(word opcode, AvrDevice *c);
1361  int operator()();
1362  int Trace();
1363 };
1364 
1366 {
1367  /*
1368  * Out To I/O Location.
1369  *
1370  * Opcode : 1011 1AAd dddd AAAA
1371  * Usage : OUT A Rd
1372  * Operation : I/O(A) <- Rd
1373  * Flags : None
1374  * Num Clocks : 1
1375  */
1376 
1377  protected:
1378  unsigned char ioreg;
1379  unsigned char R1;
1380 
1381  public:
1382  avr_op_OUT(word opcode, AvrDevice *c);
1383  int operator()();
1384  int Trace();
1385 
1386  friend class AvrFlash; // AvrFlash::LooksLikeContextSwitch() needs to read ioreg
1387 };
1388 
1390 {
1391  /*
1392  * Pop Register from Stack.
1393  *
1394  * Opcode : 1001 000d dddd 1111
1395  * Usage : POP Rd
1396  * Operation : Rd <- STACK
1397  * Flags : None
1398  * Num Clocks : 2
1399  */
1400 
1401  protected:
1402  unsigned char R1;
1403 
1404  public:
1405  avr_op_POP(word opcode, AvrDevice *c);
1406  int operator()();
1407  int Trace();
1408 };
1409 
1411 {
1412  /*
1413  * Push Register on Stack.
1414  *
1415  * Opcode : 1001 001d dddd 1111
1416  * Usage : PUSH Rd
1417  * Operation : STACK <- Rd
1418  * Flags : None
1419  * Num Clocks : 2
1420  */
1421 
1422  protected:
1423  unsigned char R1;
1424 
1425  public:
1426  avr_op_PUSH(word opcode, AvrDevice *c);
1427  int operator()();
1428  int Trace();
1429 };
1430 
1432 {
1433  /*
1434  * Relative Call Subroutine.
1435  *
1436  * Opcode : 1101 kkkk kkkk kkkk
1437  * Usage : RCALL k
1438  * Operation : PC <- PC + k + 1
1439  * Flags : None
1440  * Num Clocks : 3 / 4
1441  */
1442 
1443  protected:
1444  signed int K;
1445 
1446  public:
1447  avr_op_RCALL(word opcode, AvrDevice *c);
1448  int operator()();
1449  int Trace();
1450 };
1451 
1453 {
1454  /*
1455  * Subroutine Return.
1456  *
1457  * Opcode : 1001 0101 0000 1000
1458  * Usage : RET
1459  * Operation : PC <- STACK
1460  * Flags : None
1461  * Num Clocks : 4 / 5
1462  */
1463 
1464  public:
1465  avr_op_RET(word opcode, AvrDevice *c);
1466  int operator()();
1467  int Trace();
1468 };
1469 
1471 {
1472  /*
1473  * Interrupt Return.
1474  *
1475  * Opcode : 1001 0101 0001 1000
1476  * Usage : RETI
1477  * Operation : PC <- STACK
1478  * Flags : I
1479  * Num Clocks : 4 / 5
1480  */
1481 
1482  protected:
1484 
1485  public:
1486  avr_op_RETI(word opcode, AvrDevice *c);
1487  int operator()();
1488  int Trace();
1489 };
1490 
1492 {
1493  /*
1494  * Relative Jump.
1495  *
1496  * Opcode : 1100 kkkk kkkk kkkk
1497  * Usage : RJMP k
1498  * Operation : PC <- PC + k + 1
1499  * Flags : None
1500  * Num Clocks : 2
1501  */
1502 
1503  protected:
1504  signed int K;
1505 
1506  public:
1507  avr_op_RJMP(word opcode, AvrDevice *c);
1508  int operator()();
1509  int Trace();
1510 };
1511 
1513 {
1514  /*
1515  * Rotate Right Though Carry.
1516  *
1517  * Opcode : 1001 010d dddd 0111
1518  * Usage : ROR Rd
1519  * Operation : Rd(7) <- C, Rd(n) <- Rd(n+1), C <- Rd(0)
1520  * Flags : Z,C,N,V,S
1521  * Num Clocks : 1
1522  */
1523 
1524  protected:
1525  unsigned char R1;
1527 
1528  public:
1529  avr_op_ROR(word opcode, AvrDevice *c);
1530  int operator()();
1531  int Trace();
1532 };
1533 
1535 {
1536  /*
1537  * Subtract with Carry.
1538  *
1539  * Opcode : 0000 10rd dddd rrrr
1540  * Usage : SBC Rd, Rr
1541  * Operation : Rd <- Rd - Rr - C
1542  * Flags : Z,C,N,V,S,H
1543  * Num Clocks : 1
1544  */
1545 
1546  protected:
1547  unsigned char R1;
1548  unsigned char R2;
1550 
1551  public:
1552  avr_op_SBC(word opcode, AvrDevice *c);
1553  virtual unsigned char GetModifiedR() const;
1554  int operator()();
1555  int Trace();
1556 };
1557 
1559 {
1560  /*
1561  * Subtract Immediate with Carry.
1562  *
1563  * Opcode : 0100 KKKK dddd KKKK
1564  * Usage : SBCI Rd, K
1565  * Operation : Rd <- Rd - K - C
1566  * Flags : Z,C,N,V,S,H
1567  * Num Clocks : 1
1568  */
1569 
1570  protected:
1571  unsigned char R1;
1572  unsigned char K;
1574 
1575  public:
1576  avr_op_SBCI(word opcode, AvrDevice *c);
1577  virtual unsigned char GetModifiedR() const;
1578  int operator()();
1579  int Trace();
1580 };
1581 
1583 {
1584  /*
1585  * Set Bit in I/O Register.
1586  *
1587  * Opcode : 1001 1010 AAAA Abbb
1588  * Usage : SBI A, b
1589  * Operation : I/O(A, b) <- 1
1590  * Flags : None
1591  * Num Clocks : 2
1592  */
1593 
1594  protected:
1595  unsigned char ioreg;
1596  unsigned char Kbit;
1597 
1598  public:
1599  avr_op_SBI(word opcode, AvrDevice *c);
1600  int operator()();
1601  int Trace();
1602 };
1603 
1605 {
1606  /*
1607  * Skip if Bit in I/O Reg Cleared.
1608  *
1609  * Opcode : 1001 1001 AAAA Abbb
1610  * Usage : SBIC A, b
1611  * Operation : if (I/O(A,b) = 0) PC <- PC + 2 or 3
1612  * Flags : None
1613  * Num Clocks : 1 / 2 / 3
1614  */
1615 
1616  protected:
1617  unsigned char ioreg;
1618  unsigned char Kbit;
1619 
1620  public:
1621  avr_op_SBIC(word opcode, AvrDevice *c);
1622  int operator()();
1623  int Trace();
1624 };
1625 
1627 {
1628  /*
1629  * Skip if Bit in I/O Reg Set.
1630  *
1631  * Opcode : 1001 1011 AAAA Abbb
1632  * Usage : SBIS A, b
1633  * Operation : if (I/O(A,b) = 1) PC <- PC + 2 or 3
1634  * Flags : None
1635  * Num Clocks : 1 / 2 / 3
1636  */
1637 
1638  protected:
1639  unsigned char ioreg;
1640  unsigned char Kbit;
1641 
1642  public:
1643  avr_op_SBIS(word opcode, AvrDevice *c);
1644  int operator()();
1645  int Trace();
1646 };
1647 
1649 {
1650  /*
1651  * Subtract Immed from Word.
1652  *
1653  * Opcode : 1001 0111 KKdd KKKK
1654  * Usage : SBIW Rd, K
1655  * Operation : Rd+1:Rd <- Rd+1:Rd - K
1656  * Flags : Z,C,N,V,S
1657  * Num Clocks : 2
1658  */
1659 
1660  protected:
1661  unsigned char R1;
1662  unsigned char K;
1664 
1665  public:
1666  avr_op_SBIW(word opcode, AvrDevice *c);
1667  virtual unsigned char GetModifiedR() const;
1668  virtual unsigned char GetModifiedRHi() const;
1669  int operator()();
1670  int Trace();
1671 };
1672 
1674 {
1675  /*
1676  * Skip if Bit in Reg Cleared.
1677  *
1678  * Opcode : 1111 110d dddd 0bbb
1679  * Usage : SBRC Rd, b
1680  * Operation : if (Rd(b) = 0) PC <- PC + 2 or 3
1681  * Flags : None
1682  * Num Clocks : 1 / 2 / 3
1683  */
1684 
1685  protected:
1686  unsigned char R1;
1687  unsigned char Kbit;
1688 
1689  public:
1690  avr_op_SBRC(word opcode, AvrDevice *c);
1691  int operator()();
1692  int Trace();
1693 };
1694 
1696 {
1697  /*
1698  * Skip if Bit in Reg Set.
1699  *
1700  * Opcode : 1111 111d dddd 0bbb
1701  * Usage : SBRS Rd, b
1702  * Operation : if (Rd(b) = 1) PC <- PC + 2 or 3
1703  * Flags : None
1704  * Num Clocks : 1 / 2 / 3
1705  */
1706 
1707  protected:
1708  unsigned char R1;
1709  unsigned char Kbit;
1710 
1711  public:
1712  avr_op_SBRS(word opcode, AvrDevice *c);
1713  int operator()();
1714  int Trace();
1715 };
1716 
1719 {
1720  /*
1721  * Sleep.
1722  *
1723  * This is device specific and should be overridden by sub-class.
1724  *
1725  * Opcode : 1001 0101 1000 1000
1726  * Usage : SLEEP
1727  * Operation : (see specific hardware specification for Sleep)
1728  * Flags : None
1729  * Num Clocks : 1
1730  */
1731 
1732 
1733  public:
1734  avr_op_SLEEP(word opcode, AvrDevice *c);
1735  int operator()();
1736  int Trace();
1737 };
1738 
1740 {
1741  /*
1742  * Store Program Memory.
1743  *
1744  * Opcode : 1001 0101 1110 1000
1745  * Usage : SPM
1746  * Operation : (Z) <- R1:R0
1747  * Flags : None
1748  * Num Clocks : -
1749  */
1750 
1751  public:
1752  avr_op_SPM(word opcode, AvrDevice *c);
1753  int operator()();
1754  int Trace();
1755 };
1756 
1758 {
1759  /*
1760  * Store Indirect with Displacement.
1761  *
1762  * Opcode : 10q0 qq1d dddd 1qqq
1763  * Usage : STD Y+q, Rd
1764  * Operation : (Y + q) <- Rd
1765  * Flags : None
1766  * Num Clocks : 2
1767  */
1768 
1769  protected:
1770  unsigned char R1;
1771  unsigned char K;
1772 
1773  public:
1774  avr_op_STD_Y(word opcode, AvrDevice *c);
1775  int operator()();
1776  int Trace();
1777 };
1778 
1780 {
1781  /*
1782  * Store Indirect with Displacement.
1783  *
1784  * Opcode : 10q0 qq1d dddd 0qqq
1785  * Usage : STD Z+q, Rd
1786  * Operation : (Z + q) <- Rd
1787  * Flags : None
1788  * Num Clocks : 2
1789  */
1790 
1791  protected:
1792  unsigned char R1;
1793  unsigned char K;
1794 
1795  public:
1796  avr_op_STD_Z(word opcode, AvrDevice *c);
1797  int operator()();
1798  int Trace();
1799 };
1800 
1802 {
1803  /*
1804  * Store Direct to data space.
1805  *
1806  * Opcode : 1001 001d dddd 0000 kkkk kkkk kkkk kkkk
1807  * Usage : STS k, Rd
1808  * Operation : (k) <- Rd
1809  * Flags : None
1810  * Num Clocks : 2
1811  */
1812 
1813  protected:
1814  unsigned char R1;
1815 
1816  public:
1817  avr_op_STS(word opcode, AvrDevice *c);
1818  int operator()();
1819  int Trace();
1820 };
1821 
1823 {
1824  /*
1825  * Store Indirect using index X.
1826  *
1827  * Opcode : 1001 001d dddd 1100
1828  * Usage : ST X, Rd
1829  * Operation : (X) <- Rd
1830  * Flags : None
1831  * Num Clocks : 2
1832  */
1833 
1834  protected:
1835  unsigned char R1;
1836 
1837  public:
1838  avr_op_ST_X(word opcode, AvrDevice *c);
1839  int operator()();
1840  int Trace();
1841 };
1842 
1844 {
1845  /*
1846  * Store Indirect and Pre-Decrement using index X.
1847  *
1848  * Opcode : 1001 001d dddd 1110
1849  * Usage : ST -X, Rd
1850  * Operation : X <- X - 1, (X) <- Rd
1851  * Flags : None
1852  * Num Clocks : 2
1853  */
1854 
1855  protected:
1856  unsigned char R1;
1857 
1858  public:
1859  avr_op_ST_X_decr(word opcode, AvrDevice *c);
1860  int operator()();
1861  int Trace();
1862 };
1863 
1865 {
1866  /*
1867  * Store Indirect and Post-Increment using index X.
1868  *
1869  * Opcode : 1001 001d dddd 1101
1870  * Usage : ST X+, Rd
1871  * Operation : (X) <- Rd, X <- X + 1
1872  * Flags : None
1873  * Num Clocks : 2
1874  */
1875 
1876  protected:
1877  unsigned char R1;
1878 
1879  public:
1880  avr_op_ST_X_incr(word opcode, AvrDevice *c);
1881  int operator()();
1882  int Trace();
1883 };
1884 
1886 {
1887  /*
1888  * Store Indirect and Pre-Decrement using index Y.
1889  *
1890  * Opcode : 1001 001d dddd 1010
1891  * Usage : ST -Y, Rd
1892  * Operation : Y <- Y - 1, (Y) <- Rd
1893  * Flags : None
1894  * Num Clocks : 2
1895  */
1896 
1897  protected:
1898  unsigned char R1;
1899 
1900  public:
1901  avr_op_ST_Y_decr(word opcode, AvrDevice *c);
1902  int operator()();
1903  int Trace();
1904 };
1905 
1907 {
1908  /*
1909  * Store Indirect and Post-Increment using index Y.
1910  *
1911  * Opcode : 1001 001d dddd 1001
1912  * Usage : ST Y+, Rd
1913  * Operation : (Y) <- Rd, Y <- Y + 1
1914  * Flags : None
1915  * Num Clocks : 2
1916  */
1917 
1918  protected:
1919  unsigned char R1;
1920 
1921  public:
1922  avr_op_ST_Y_incr(word opcode, AvrDevice *c);
1923  int operator()();
1924  int Trace();
1925 };
1926 
1928 {
1929  /*
1930  * Store Indirect and Pre-Decrement using index Z.
1931  *
1932  * Opcode : 1001 001d dddd 0010
1933  * Usage : ST -Z, Rd
1934  * Operation : Z <- Z - 1, (Z) <- Rd
1935  * Flags : None
1936  * Num Clocks : 2
1937  */
1938 
1939  protected:
1940  unsigned char R1;
1941 
1942  public:
1943  avr_op_ST_Z_decr(word opcode, AvrDevice *c);
1944  int operator()();
1945  int Trace();
1946 };
1947 
1949 {
1950  /*
1951  * Store Indirect and Post-Increment using index Z.
1952  *
1953  * Opcode : 1001 001d dddd 0001
1954  * Usage : ST Z+, Rd
1955  * Operation : (Z) <- Rd, Z <- Z + 1
1956  * Flags : None
1957  * Num Clocks : 2
1958  */
1959 
1960  protected:
1961  unsigned char R1;
1962 
1963  public:
1964  avr_op_ST_Z_incr(word opcode, AvrDevice *c);
1965  int operator()();
1966  int Trace();
1967 };
1968 
1970 {
1971  /*
1972  * Subtract without Carry.
1973  *
1974  * Opcode : 0001 10rd dddd rrrr
1975  * Usage : SUB Rd, Rr
1976  * Operation : Rd <- Rd - Rr
1977  * Flags : Z,C,N,V,S,H
1978  * Num Clocks : 1
1979  */
1980 
1981  protected:
1982  unsigned char R1;
1983  unsigned char R2;
1985 
1986  public:
1987  avr_op_SUB(word opcode, AvrDevice *c);
1988  virtual unsigned char GetModifiedR() const;
1989  int operator()();
1990  int Trace();
1991 };
1992 
1994 {
1995  /*
1996  * Subtract Immediate.
1997  *
1998  * Opcode : 0101 KKKK dddd KKKK
1999  * Usage : SUBI Rd, K
2000  * Operation : Rd <- Rd - K
2001  * Flags : Z,C,N,V,S,H
2002  * Num Clocks : 1
2003  */
2004 
2005  protected:
2006  unsigned char R1;
2008  unsigned char K;
2009 
2010  public:
2011  avr_op_SUBI(word opcode, AvrDevice *c);
2012  virtual unsigned char GetModifiedR() const;
2013  int operator()();
2014  int Trace();
2015 };
2016 
2018 {
2019  /*
2020  * Swap Nibbles.
2021  *
2022  * Opcode : 1001 010d dddd 0010
2023  * Usage : SWAP Rd
2024  * Operation : Rd(3..0) <--> Rd(7..4)
2025  * Flags : None
2026  * Num Clocks : 1
2027  */
2028 
2029  protected:
2030  unsigned char R1;
2031 
2032  public:
2033  avr_op_SWAP(word opcode, AvrDevice *c);
2034  int operator()();
2035  int Trace();
2036 };
2037 
2039 {
2040  /*
2041  * Watchdog Reset.
2042  *
2043  * This is device specific and must be overridden by sub-class.
2044  *
2045  * Opcode : 1001 0101 1010 1000
2046  * Usage : WDR
2047  * Operation : (see specific hardware specification for WDR)
2048  * Flags : None
2049  * Num Clocks : 1
2050  */
2051 
2052  public:
2053  avr_op_WDR(word opcode, AvrDevice *c);
2054  int operator()();
2055  int Trace();
2056 };
2057 
2059 {
2060  /*
2061  * Halts execution
2062  *
2063  * TODO Check if execution is continuable on a real MCU
2064  *
2065  * Opcode : 1001 0101 1001 1000
2066  * Usage : BREAK
2067  * Operation : (see specific hardware specification for BREAK)
2068  * Flags : None
2069  * Num Clocks : N/A
2070  */
2071 
2072  public:
2073  avr_op_BREAK(word opcode, AvrDevice *c);
2074  int operator()();
2075  int Trace();
2076 };
2077 
2079 {
2080  //illegal instruction
2081 
2082  public:
2083  avr_op_ILLEGAL(word opcode, AvrDevice *c);
2084  int operator()();
2085  int Trace();
2086 };
2087 
2088 #endif
2089 
unsigned char R1
Definition: decoder.h:478
HWSreg * status
Definition: decoder.h:480
unsigned char ioreg
Definition: decoder.h:792
unsigned char ioreg
Definition: decoder.h:1617
Basic AVR device, contains the core functionality.
Definition: avrdevice.h:66
HWSreg * status
Definition: decoder.h:504
unsigned char Rs
Definition: decoder.h:1198
HWSreg * status
Definition: decoder.h:688
unsigned char R1
Definition: decoder.h:410
HWSreg * status
Definition: decoder.h:344
unsigned char Kbit
Definition: decoder.h:1640
virtual unsigned char GetModifiedR() const
If this instruction modifies a R0-R31 register then return its number, otherwise -1.
Definition: decoder.h:57
unsigned char Rl
Definition: decoder.h:125
unsigned char Rr
Definition: decoder.h:687
unsigned char R2
Definition: decoder.h:433
unsigned char R1
Definition: decoder.h:1919
unsigned char ioreg
Definition: decoder.h:1639
unsigned char Kbit
Definition: decoder.h:1687
unsigned char R1
Definition: decoder.h:604
unsigned char Rd
Definition: decoder.h:965
unsigned char Rd
Definition: decoder.h:1008
unsigned char Kbit
Definition: decoder.h:1596
unsigned char R2
Definition: decoder.h:1548
HWSreg * status
Definition: decoder.h:1984
HWSreg * status
Definition: decoder.h:100
unsigned char R1
Definition: decoder.h:342
HWSreg * status
Definition: decoder.h:320
unsigned char Rr
Definition: decoder.h:1220
unsigned char R1
Definition: decoder.h:502
unsigned short word
Definition: types.h:27
unsigned char Rd
Definition: decoder.h:1291
unsigned char R2
Definition: decoder.h:1176
unsigned char R1
Definition: decoder.h:1571
unsigned char R1
Definition: decoder.h:1898
unsigned char R2
Definition: decoder.h:152
HWSreg * status
Definition: decoder.h:1663
unsigned char Rd
Definition: decoder.h:686
unsigned char ioreg
Definition: decoder.h:1378
Holds AVR flash content and symbol informations.
Definition: flash.h:38
unsigned char R1
Definition: decoder.h:1877
HWSreg * status
Definition: decoder.h:389
HWSreg * status
Definition: decoder.h:1292
unsigned char K
Definition: decoder.h:1771
unsigned char ioreg
Definition: decoder.h:387
virtual unsigned char GetModifiedRHi() const
If this instruction modifies a pair of R0-R31 registers then ...
Definition: decoder.h:59
unsigned char R1
Definition: decoder.h:241
unsigned char R1
Definition: decoder.h:76
unsigned char R1
Definition: decoder.h:432
DecodedInstruction(AvrDevice *c, bool s2w=false)
Definition: decoder.h:46
unsigned char R1
Definition: decoder.h:1175
unsigned char R1
Definition: decoder.h:1770
unsigned char R1
Definition: decoder.h:174
unsigned char R1
Definition: decoder.h:1355
HWSreg * status
Definition: decoder.h:1549
HWSreg * status
Definition: decoder.h:1270
virtual ~DecodedInstruction()
Definition: decoder.h:47
unsigned char Rd
Definition: decoder.h:944
HWSreg * status
Definition: decoder.h:434
HWSreg * status
Definition: decoder.h:814
bool size2Word
Flag: true, if instruction has 2 words.
Definition: decoder.h:43
HWSreg * status
Definition: decoder.h:2007
unsigned char R1
Definition: decoder.h:1423
unsigned char Kbit
Definition: decoder.h:321
HWSreg * status
Definition: decoder.h:269
HWSreg * status
Definition: decoder.h:646
unsigned char R2
Definition: decoder.h:99
unsigned char R1
Definition: decoder.h:197
unsigned char Rd
Definition: decoder.h:1332
unsigned char Rd
Definition: decoder.h:1197
signed int K
Definition: decoder.h:1444
unsigned char K
Definition: decoder.h:901
unsigned char Kbit
Definition: decoder.h:242
HWSreg * status
Definition: decoder.h:1244
unsigned char Kbit
Definition: decoder.h:388
HWSreg * status
Definition: decoder.h:411
virtual int Trace()=0
Performs instruction and write out instruction mnemonic for trace.
unsigned char Rd
Definition: decoder.h:878
bool IsInstruction2Words()
Returns true, if instruction need 2 words (4byte)
Definition: decoder.h:50
unsigned char R1
Definition: decoder.h:1982
Definition: hwsreg.h:52
unsigned int K
Definition: decoder.h:835
HWSreg * status
Definition: decoder.h:1573
unsigned char R2
Definition: decoder.h:1983
HWSreg * status
Definition: decoder.h:128
unsigned char Rr
Definition: decoder.h:710
unsigned char R2
Definition: decoder.h:456
unsigned char K
Definition: decoder.h:127
signed int K
Definition: decoder.h:1504
unsigned char Rd
Definition: decoder.h:1154
HWSreg * status
Definition: decoder.h:1334
unsigned char K
Definition: decoder.h:2008
unsigned char R1
Definition: decoder.h:1547
signed char offset
Definition: decoder.h:271
unsigned char Rr
Definition: decoder.h:1269
unsigned char Rr
Definition: decoder.h:733
unsigned char Rd
Definition: decoder.h:1050
unsigned char Rd
Definition: decoder.h:1242
unsigned char R1
Definition: decoder.h:2006
HWSreg * status
Definition: decoder.h:734
HWSreg * status
Definition: decoder.h:711
unsigned char KH
Definition: decoder.h:366
unsigned char R1
Definition: decoder.h:151
unsigned char K
Definition: decoder.h:1356
unsigned char Kbit
Definition: decoder.h:343
unsigned char R1
Definition: decoder.h:1792
unsigned char R1
Definition: decoder.h:98
unsigned char K
Definition: decoder.h:479
HWSreg * status
Definition: decoder.h:243
unsigned char Rd
Definition: decoder.h:732
unsigned char K
Definition: decoder.h:1572
Base class of core instruction.
Definition: decoder.h:39
unsigned char R2
Definition: decoder.h:645
unsigned char R1
Definition: decoder.h:1708
unsigned char Rd
Definition: decoder.h:1133
unsigned char R1
Definition: decoder.h:1379
HWSreg * status
Definition: decoder.h:1357
HWSreg * status
Definition: decoder.h:1221
unsigned char R2
Definition: decoder.h:503
HWSreg * status
Definition: decoder.h:153
unsigned char K
Definition: decoder.h:175
unsigned char R1
Definition: decoder.h:791
unsigned char R1
Definition: decoder.h:1661
unsigned char R1
Definition: decoder.h:455
unsigned char Rd
Definition: decoder.h:986
unsigned char R1
Definition: decoder.h:525
unsigned char bitmask
Definition: decoder.h:298
unsigned char Rd
Definition: decoder.h:1029
unsigned char R1
Definition: decoder.h:1961
unsigned char Kbit
Definition: decoder.h:220
unsigned char R1
Definition: decoder.h:583
HWSreg * status
Definition: decoder.h:198
unsigned char R1
Definition: decoder.h:1402
unsigned char R1
Definition: decoder.h:1814
unsigned char K
Definition: decoder.h:1662
HWSreg * status
Definition: decoder.h:78
unsigned char R2
Definition: decoder.h:77
HWSreg * status
Definition: decoder.h:1483
virtual int operator()()=0
Performs instruction.
unsigned char bitmask
Definition: decoder.h:270
unsigned char Kbit
Definition: decoder.h:1618
unsigned char R1
Definition: decoder.h:1835
unsigned char Rd
Definition: decoder.h:1092
unsigned char R1
Definition: decoder.h:1686
unsigned char R1
Definition: decoder.h:1525
HWSreg * status
Definition: decoder.h:526
DecodedInstruction * lookup_opcode(word opcode, AvrDevice *core)
Translates an opcode to a instance of DecodedInstruction.
Definition: decoder.cpp:1949
unsigned char Rh
Definition: decoder.h:126
unsigned char K
Definition: decoder.h:857
unsigned char Rd
Definition: decoder.h:709
unsigned char Rd
Definition: decoder.h:856
HWSreg * status
Definition: decoder.h:1155
unsigned char Kbit
Definition: decoder.h:1709
unsigned char Rr
Definition: decoder.h:1333
HWSreg * status
Definition: decoder.h:1526
signed char offset
Definition: decoder.h:299
HWSreg * status
Definition: decoder.h:176
HWSreg * status
Definition: decoder.h:457
unsigned char R1
Definition: decoder.h:1940
AvrDevice * core
Link to device instance.
Definition: decoder.h:42
unsigned char R1
Definition: decoder.h:813
unsigned char K
Definition: decoder.h:1793
unsigned char K
Definition: decoder.h:879
unsigned char R1
Definition: decoder.h:1856
unsigned char R1
Definition: decoder.h:2030
unsigned char ioreg
Definition: decoder.h:1595
unsigned char Rd
Definition: decoder.h:1219
unsigned char R1
Definition: decoder.h:644
unsigned char Rr
Definition: decoder.h:1243
HWSreg * status
Definition: decoder.h:297
unsigned char Rd
Definition: decoder.h:1268
HWSreg * status
Definition: decoder.h:219
unsigned char R1
Definition: decoder.h:900
unsigned char Rd
Definition: decoder.h:1071
unsigned char R1
Definition: decoder.h:923