1 #ifndef AVR_INSTRUCTIONS_H
2 #define AVR_INSTRUCTIONS_H
4 #include "Instruction.h"
16 class ADC
: public Instruction
{
20 * Opcode : 0001 11rd dddd rrrr
22 * Operation : Rd <- Rd + Rr + C
31 int operator()(Core
*core
);
32 int trace(Core
*core
, std::ostream
& ostr
);
41 class ADD
: public Instruction
{
45 * Opcode : 0000 11rd dddd rrrr
47 * Operation : Rd <- Rd + Rr
56 int operator ()(Core
*core
);
57 int trace(Core
*core
, std::ostream
& ostr
);
65 class ADIW
: public Instruction
{
67 * Add Immediate to Word.
69 * Opcode : 1001 0110 KKdd KKKK
71 * Operation : Rd+1:Rd <- Rd+1:Rd + K
80 int operator ()(Core
*core
);
81 int trace(Core
*core
, std::ostream
& ostr
);
90 class AND
: public Instruction
{
94 * Opcode : 0010 00rd dddd rrrr
96 * Operation : Rd <- Rd & Rr
105 int operator()(Core
*core
);
106 int trace(Core
*core
, std::ostream
& ostr
);
114 class ANDI
: public Instruction
{
116 * Logical AND with Immed.
118 * Opcode : 0111 KKKK dddd KKKK
120 * Operation : Rd <- Rd & K
129 int operator()(Core
*core
);
130 int trace(Core
*core
, std::ostream
& ostr
);
138 class ASR
: public Instruction
{
140 * Arithmetic Shift Right.
142 * Opcode : 1001 010d dddd 0101
144 * Operation : Rd(n) <- Rd(n+1), n=0..6
153 int operator()(Core
*core
);
154 int trace(Core
*core
, std::ostream
& ostr
);
161 class BCLR
: public Instruction
{
163 * Clear a single flag or bit in SREG.
165 * Opcode : 1001 0100 1sss 1000
167 * Operation : SREG(s) <- 0
176 int operator()(Core
*core
);
177 int trace(Core
*core
, std::ostream
& ostr
);
184 class BLD
: public Instruction
{
185 /* Bit load from T to Register.
187 * Opcode : 1111 100d dddd 0bbb
189 * Operation : Rd(b) <- T
198 int operator()(Core
*core
);
199 int trace(Core
*core
, std::ostream
& ostr
);
203 unsigned char Kadd
, Kremove
;
207 class BRBC
: public Instruction
{
209 * Branch if Status Flag Cleared.
211 * Pass control directly to the specific bit operation.
213 * Opcode : 1111 01kk kkkk ksss
215 * Operation : if (SREG(s) = 0) then PC <- PC + k + 1
219 * k is an relative address represented in two's complements.
227 int operator()(Core
*core
);
228 int trace(Core
*core
, std::ostream
& ostr
);
231 unsigned char bitmask
;
236 class BRBS
: public Instruction
{
238 * Branch if Status Flag Set.
240 * Pass control directly to the specific bit operation.
242 * Opcode : 1111 00kk kkkk ksss
244 * Operation : if (SREG(s) = 1) then PC <- PC + k + 1
248 * k is an relative address represented in two's complements.
256 int operator()(Core
*core
);
257 int trace(Core
*core
, std::ostream
& ostr
);
260 unsigned char bitmask
;
265 class BSET
: public Instruction
{
267 * Set a single flag or bit in SREG.
269 * Opcode : 1001 0100 0sss 1000
271 * Operation : SREG(s) <- 1
280 int operator()(Core
*core
);
281 int trace(Core
*core
, std::ostream
& ostr
);
288 class BST
:public Instruction
291 * Bit Store from Register to T.
293 * Opcode : 1111 101d dddd 0bbb
295 * Operation : T <- Rd(b)
304 int operator()(Core
*core
);
305 int trace(Core
*core
, std::ostream
& ostr
);
314 class CALL
: public Instruction
{
318 * Opcode : 1001 010k kkkk 111k kkkk kkkk kkkk kkkk
320 * Operation : PC <- k
329 int operator()(Core
*core
);
330 int trace(Core
*core
, std::ostream
& ostr
);
331 bool is2Word() const { return true; }
337 class CBI
: public Instruction
{
339 * Clear Bit in I/O Register.
341 * Opcode : 1001 1000 AAAA Abbb
343 * Operation : I/O(A, b) <- 0
350 int operator()(Core
*core
);
351 int trace(Core
*core
, std::ostream
& ostr
);
358 class COM
: public Instruction
{
362 * Opcode : 1001 010d dddd 0000
364 * Operation : Rd <- $FF - Rd
373 int operator()(Core
*core
);
374 int trace(Core
*core
, std::ostream
& ostr
);
381 class CP
: public Instruction
{
385 * Opcode : 0001 01rd dddd rrrr
387 * Operation : Rd - Rr
388 * Flags : Z,C,N,V,S,H
396 int operator()(Core
*core
);
397 int trace(Core
*core
, std::ostream
& ostr
);
405 class CPC
: public Instruction
{
407 * Compare with Carry.
409 * Opcode : 0000 01rd dddd rrrr
411 * Operation : Rd - Rr - C
412 * Flags : Z,C,N,V,S,H
418 int operator()(Core
*core
);
419 int trace(Core
*core
, std::ostream
& ostr
);
427 class CPI
: public Instruction
{
429 * Compare with Immediate.
431 * Opcode : 0011 KKKK dddd KKKK
434 * Flags : Z,C,N,V,S,H
442 int operator()(Core
*core
);
443 int trace(Core
*core
, std::ostream
& ostr
);
452 class CPSE
: public Instruction
{
454 * Compare, Skip if Equal.
456 * Opcode : 0001 00rd dddd rrrr
457 * Usage : CPSE Rd, Rr
458 * Operation : if (Rd = Rr) PC <- PC + 2 or 3
460 * Num Clocks : 1 / 2 / 3
467 int operator()(Core
*core
);
468 int trace(Core
*core
, std::ostream
& ostr
);
476 class DEC
: public Instruction
{
480 * Opcode : 1001 010d dddd 1010
482 * Operation : Rd <- Rd - 1
489 int operator()(Core
*core
);
490 int trace(Core
*core
, std::ostream
& ostr
);
497 class EICALL
: public Instruction
{
499 * Extended Indirect Call to (Z).
501 * Opcode : 1001 0101 0001 1001
503 * Operation : PC(15:0) <- Z, PC(21:16) <- EIND
512 int operator()(Core
*core
);
513 int trace(Core
*core
, std::ostream
& ostr
);
521 class EIJMP
: public Instruction
{
523 * Extended Indirect Jmp to (Z).
525 * Opcode : 1001 0100 0001 1001
527 * Operation : PC(15:0) <- Z, PC(21:16) <- EIND
536 int operator()(Core
*core
);
537 int trace(Core
*core
, std::ostream
& ostr
);
545 class ELPM_Z
: public Instruction
{
547 * Extended Load Program Memory.
549 * Opcode : 1001 000d dddd 0110
551 * Operation : R <- (RAMPZ:Z)
557 ELPM_Z (word opcode
);
560 int operator()(Core
*core
);
561 int trace(Core
*core
, std::ostream
& ostr
);
569 class ELPM_Z_incr
:public Instruction
{
571 * Extended Ld Prg Mem and Post-Incr.
573 * Opcode : 1001 000d dddd 0111
574 * Usage : ELPM Rd, Z+
575 * Operation : Rd <- (RAMPZ:Z), Z <- Z + 1
581 ELPM_Z_incr(word opcode
);
584 int operator()(Core
*core
);
585 int trace(Core
*core
, std::ostream
& ostr
);
593 class ELPM
: public Instruction
{
595 * Extended Load Program Memory.
598 * Opcode : 1001 0101 1101 1000
600 * Operation : R0 <- (RAMPZ:Z)
609 int operator()(Core
*core
);
610 int trace(Core
*core
, std::ostream
& ostr
);
618 class EOR
:public Instruction
{
622 * Opcode : 0010 01rd dddd rrrr
624 * Operation : Rd <- Rd ^ Rr
633 int operator()(Core
*core
);
634 int trace(Core
*core
, std::ostream
& ostr
);
642 class ESPM
: public Instruction
{
644 * Extended Store Program Memory.
646 * Opcode : 1001 0101 1111 1000
648 * Operation : Z <- R1:R0
657 int operator()(Core
*core
);
658 int trace(Core
*core
, std::ostream
& ostr
);
665 class FMUL
:public Instruction
{
667 * Fractional Mult Unsigned.
669 * Opcode : 0000 0011 0ddd 1rrr
670 * Usage : FMUL Rd, Rr
671 * Operation : R1:R0 <- (Rd * Rr)<<1 (UU)
680 int operator()(Core
*core
);
681 int trace(Core
*core
, std::ostream
& ostr
);
691 class FMULS
: public Instruction
{
693 * Fractional Mult Signed.
695 * Opcode : 0000 0011 1ddd 0rrr
696 * Usage : FMULS Rd, Rr
697 * Operation : R1:R0 <- (Rd * Rr)<<1 (SS)
706 int operator()(Core
*core
);
707 int trace(Core
*core
, std::ostream
& ostr
);
717 class FMULSU
: public Instruction
{
719 * Fract Mult Signed w/ Unsigned.
721 * Opcode : 0000 0011 1ddd 1rrr
722 * Usage : FMULSU Rd, Rr
723 * Operation : R1:R0 <- (Rd * Rr)<<1 (SU)
729 FMULSU (word opcode
);
732 int operator()(Core
*core
);
733 int trace(Core
*core
, std::ostream
& ostr
);
743 class ICALL
: public Instruction
{
745 * Indirect Call to (Z).
747 * Opcode : 1001 0101 0000 1001
749 * Operation : PC(15:0) <- Z, PC(21:16) <- 0
758 int operator()(Core
*core
);
759 int trace(Core
*core
, std::ostream
& ostr
);
766 class IJMP
: public Instruction
{
768 * Indirect Jump to (Z).
770 * Opcode : 1001 0100 0000 1001
772 * Operation : PC(15:0) <- Z, PC(21:16) <- 0
781 int operator()(Core
*core
);
782 int trace(Core
*core
, std::ostream
& ostr
);
789 class IN
: public Instruction
{
791 * In From I/O Location.
793 * Opcode : 1011 0AAd dddd AAAA
795 * Operation : Rd <- I/O(A)
804 int operator()(Core
*core
);
805 int trace(Core
*core
, std::ostream
& ostr
);
812 class INC
: public Instruction
{
816 * Opcode : 1001 010d dddd 0011
818 * Operation : Rd <- Rd + 1
827 int operator()(Core
*core
);
828 int trace(Core
*core
, std::ostream
& ostr
);
835 class JMP
: public Instruction
{
839 * Opcode : 1001 010k kkkk 110k kkkk kkkk kkkk kkkk
841 * Operation : PC <- k
850 int operator()(Core
*core
);
851 int trace(Core
*core
, std::ostream
& ostr
);
852 bool is2Word() const { return true; }
858 class LDD_Y
: public Instruction
{
860 * Load Indirect with Displacement using index Y.
862 * Opcode : 10q0 qq0d dddd 1qqq
863 * Usage : LDD Rd, Y+q
864 * Operation : Rd <- (Y + q)
873 int operator()(Core
*core
);
874 int trace(Core
*core
, std::ostream
& ostr
);
883 class LDD_Z
: public Instruction
{
885 * Load Indirect with Displacement using index Z.
887 * Opcode : 10q0 qq0d dddd 0qqq
888 * Usage : LDD Rd, Z+q
889 * Operation : Rd <- (Z + q)
898 int operator()(Core
*core
);
899 int trace(Core
*core
, std::ostream
& ostr
);
908 class LDI
: public Instruction
{
912 * Opcode : 1110 KKKK dddd KKKK
914 * Operation : Rd <- K
923 int operator()(Core
*core
);
924 int trace(Core
*core
, std::ostream
& ostr
);
931 class LDS
: public Instruction
{
933 * Load Direct from data space.
935 * Opcode : 1001 000d dddd 0000 kkkk kkkk kkkk kkkk
937 * Operation : Rd <- (k)
946 int operator()(Core
*core
);
947 int trace(Core
*core
, std::ostream
& ostr
);
948 bool is2Word() const { return true; }
954 class LD_X
: public Instruction
{
956 * Load Indirect using index X.
958 * Opcode : 1001 000d dddd 1100
960 * Operation : Rd <- (X)
969 int operator()(Core
*core
);
970 int trace(Core
*core
, std::ostream
& ostr
);
978 class LD_X_decr
: public LD_X
{
980 * Load Indirect and Pre-Decrement using index X.
982 * Opcode : 1001 000d dddd 1110
984 * Operation : X <- X - 1, Rd <- (X)
990 LD_X_decr(word opcode
);
993 int operator()(Core
*core
);
994 int trace(Core
*core
, std::ostream
& ostr
);
997 class LD_X_incr
: public LD_X
{
999 * Load Indirect and Post-Increment using index X.
1001 * Opcode : 1001 000d dddd 1101
1003 * Operation : Rd <- (X), X <- X + 1
1009 LD_X_incr(word opcode
);
1012 int operator()(Core
*core
);
1013 int trace(Core
*core
, std::ostream
& ostr
);
1016 class LD_Y_decr
: public Instruction
{
1018 * Load Indirect and PreDecrement using index Y.
1020 * Opcode : 1001 000d dddd 1010
1022 * Operation : Y <- Y - 1, Rd <- (Y)
1028 LD_Y_decr(word opcode
);
1031 int operator()(Core
*core
);
1032 int trace(Core
*core
, std::ostream
& ostr
);
1040 class LD_Y_incr
: public Instruction
{
1042 * Load Indirect and Post-Increment using index Y.
1044 * Opcode : 1001 000d dddd 1001
1046 * Operation : Rd <- (Y), Y <- Y + 1
1052 LD_Y_incr(word opcode
);
1055 int operator()(Core
*core
);
1056 int trace(Core
*core
, std::ostream
& ostr
);
1064 class LD_Z_incr
: public Instruction
{
1066 * Load Indirect and Post-Increment using index Z.
1068 * Opcode : 1001 000d dddd 0001
1070 * Operation : Rd <- (Z), Z <- Z+1
1076 LD_Z_incr(word opcode
);
1079 int operator()(Core
*core
);
1080 int trace(Core
*core
, std::ostream
& ostr
);
1088 class LD_Z_decr
: public Instruction
{
1090 * Load Indirect and Pre-Decrement using index Z.
1092 * Opcode : 1001 000d dddd 0010
1094 * Operation : Z <- Z - 1, Rd <- (Z)
1100 LD_Z_decr(word opcode
);
1103 int operator()(Core
*core
);
1104 int trace(Core
*core
, std::ostream
& ostr
);
1112 class LPM_Z
: public Instruction
{
1114 * Load Program Memory.
1116 * Opcode : 1001 000d dddd 0100
1118 * Operation : Rd <- (Z)
1127 int operator()(Core
*core
);
1128 int trace(Core
*core
, std::ostream
& ostr
);
1136 class LPM
: public Instruction
{
1137 /* Load Program Memory.
1139 * This the same as LPM_Z:public Instruction
1141 * Opcode : 1001 0101 1100 1000
1143 * Operation : R0 <- (Z)
1152 int operator()(Core
*core
);
1153 int trace(Core
*core
, std::ostream
& ostr
);
1161 class LPM_Z_incr
: public Instruction
{
1163 * Load Program Memory and Post-Incr.
1165 * Opcode : 1001 000d dddd 0101
1166 * Usage : LPM Rd, Z+
1167 * Operation : Rd <- (Z), Z <- Z + 1
1173 LPM_Z_incr(word opcode
);
1176 int operator()(Core
*core
);
1177 int trace(Core
*core
, std::ostream
& ostr
);
1185 class LSR
: public Instruction
{
1187 * Logical Shift Right.
1189 * Opcode : 1001 010d dddd 0110
1191 * Operation : Rd(n) <- Rd(n+1), Rd(7) <- 0, C <- Rd(0)
1200 int operator()(Core
*core
);
1201 int trace(Core
*core
, std::ostream
& ostr
);
1208 class MOV
:public Instruction
{
1211 * Opcode : 0010 11rd dddd rrrr
1212 * Usage : MOV Rd, Rr
1213 * Operation : Rd <- Rr
1222 int operator()(Core
*core
);
1223 int trace(Core
*core
, std::ostream
& ostr
);
1230 class MOVW
:public Instruction
{
1232 *Copy Register Pair.
1234 * Opcode : 0000 0001 dddd rrrr
1235 * Usage : MOVW Rd, Rr
1236 * Operation : Rd+1:Rd <- Rr+1:Rr
1245 int operator()(Core
*core
);
1246 int trace(Core
*core
, std::ostream
& ostr
);
1255 class MUL
: public Instruction
{
1259 * Opcode : 1001 11rd dddd rrrr
1260 * Usage : MUL Rd, Rr
1261 * Operation : R1:R0 <- Rd * Rr (UU)
1270 int operator()(Core
*core
);
1271 int trace(Core
*core
, std::ostream
& ostr
);
1281 class MULS
: public Instruction
{
1285 * Opcode : 0000 0010 dddd rrrr
1286 * Usage : MULS Rd, Rr
1287 * Operation : R1:R0 <- Rd * Rr (SS)
1296 int operator()(Core
*core
);
1297 int trace(Core
*core
, std::ostream
& ostr
);
1307 class MULSU
:public Instruction
{
1309 * Mult Signed with Unsigned.
1311 * Rd(unsigned),Rr(signed), result (signed)
1313 * Opcode : 0000 0011 0ddd 0rrr
1314 * Usage : MULSU Rd, Rr
1315 * Operation : R1:R0 <- Rd * Rr (SU)
1324 int operator()(Core
*core
);
1325 int trace(Core
*core
, std::ostream
& ostr
);
1335 class NEG
: public Instruction
{
1339 * Opcode : 1001 010d dddd 0001
1341 * Operation : Rd <- $00 - Rd
1342 * Flags : Z,C,N,V,S,H
1350 int operator()(Core
*core
);
1351 int trace(Core
*core
, std::ostream
& ostr
);
1358 class NOP
: public Instruction
{
1362 * Opcode : 0000 0000 0000 0000
1373 int operator()(Core
*core
);
1374 int trace(Core
*core
, std::ostream
& ostr
);
1377 class OR
:public Instruction
{
1381 * Opcode : 0010 10rd dddd rrrr
1383 * Operation : Rd <- Rd or Rr
1392 int operator()(Core
*core
);
1393 int trace(Core
*core
, std::ostream
& ostr
);
1401 class ORI
: public Instruction
{
1403 * Logical OR with Immed.
1405 * Opcode : 0110 KKKK dddd KKKK
1407 * Operation : Rd <- Rd or K
1416 int operator()(Core
*core
);
1417 int trace(Core
*core
, std::ostream
& ostr
);
1425 class OUT
: public Instruction
{
1427 * Out To I/O Location.
1429 * Opcode : 1011 1AAd dddd AAAA
1431 * Operation : I/O(A) <- Rd
1440 int operator()(Core
*core
);
1441 int trace(Core
*core
, std::ostream
& ostr
);
1445 unsigned char ioreg
;
1448 class POP
: public Instruction
{
1450 * Pop Register from Stack.
1452 * Opcode : 1001 000d dddd 1111
1454 * Operation : Rd <- STACK
1463 int operator()(Core
*core
);
1464 int trace(Core
*core
, std::ostream
& ostr
);
1470 class PUSH
: public Instruction
{
1472 * Push Register on Stack.
1474 * Opcode : 1001 001d dddd 1111
1476 * Operation : STACK <- Rd
1485 int operator()(Core
*core
);
1486 int trace(Core
*core
, std::ostream
& ostr
);
1492 class RCALL
: public Instruction
{
1494 * Relative Call Subroutine.
1496 * Opcode : 1101 kkkk kkkk kkkk
1498 * Operation : PC <- PC + k + 1
1500 * Num Clocks : 3 / 4
1507 int operator()(Core
*core
);
1508 int trace(Core
*core
, std::ostream
& ostr
);
1514 class RET
: public Instruction
{
1516 * Subroutine Return.
1518 * Opcode : 1001 0101 0000 1000
1520 * Operation : PC <- STACK
1522 * Num Clocks : 4 / 5
1529 int operator()(Core
*core
);
1530 int trace(Core
*core
, std::ostream
& ostr
);
1533 class RETI
: public Instruction
{
1537 * Opcode : 1001 0101 0001 1000
1539 * Operation : PC <- STACK
1541 * Num Clocks : 4 / 5
1548 int operator()(Core
*core
);
1549 int trace(Core
*core
, std::ostream
& ostr
);
1555 class RJMP
: public Instruction
{
1559 * Opcode : 1100 kkkk kkkk kkkk
1561 * Operation : PC <- PC + k + 1
1570 int operator()(Core
*core
);
1571 int trace(Core
*core
, std::ostream
& ostr
);
1577 class ROR
: public Instruction
{
1579 * Rotate Right Though Carry.
1581 * Opcode : 1001 010d dddd 0111
1583 * Operation : Rd(7) <- C, Rd(n) <- Rd(n+1), C <- Rd(0)
1592 int operator()(Core
*core
);
1593 int trace(Core
*core
, std::ostream
& ostr
);
1600 class SBC
: public Instruction
{
1602 * Subtract with Carry.
1604 * Opcode : 0000 10rd dddd rrrr
1605 * Usage : SBC Rd, Rr
1606 * Operation : Rd <- Rd - Rr - C
1607 * Flags : Z,C,N,V,S,H
1615 int operator()(Core
*core
);
1616 int trace(Core
*core
, std::ostream
& ostr
);
1624 class SBCI
: public Instruction
{
1626 * Subtract Immediate with Carry.
1628 * Opcode : 0100 KKKK dddd KKKK
1629 * Usage : SBCI Rd, K
1630 * Operation : Rd <- Rd - K - C
1631 * Flags : Z,C,N,V,S,H
1639 int operator()(Core
*core
);
1640 int trace(Core
*core
, std::ostream
& ostr
);
1648 class SBI
: public Instruction
{
1650 * Set Bit in I/O Register.
1652 * Opcode : 1001 1010 AAAA Abbb
1654 * Operation : I/O(A, b) <- 1
1663 int operator()(Core
*core
);
1664 int trace(Core
*core
, std::ostream
& ostr
);
1667 unsigned char ioreg
;
1671 class SBIC
: public Instruction
{
1673 * Skip if Bit in I/O Reg Cleared.
1675 * Opcode : 1001 1001 AAAA Abbb
1677 * Operation : if (I/O(A,b) = 0) PC <- PC + 2 or 3
1679 * Num Clocks : 1 / 2 / 3
1686 int operator()(Core
*core
);
1687 int trace(Core
*core
, std::ostream
& ostr
);
1690 unsigned char ioreg
;
1694 class SBIS
: public Instruction
{
1696 * Skip if Bit in I/O Reg Set.
1698 * Opcode : 1001 1011 AAAA Abbb
1700 * Operation : if (I/O(A,b) = 1) PC <- PC + 2 or 3
1702 * Num Clocks : 1 / 2 / 3
1709 int operator()(Core
*core
);
1710 int trace(Core
*core
, std::ostream
& ostr
);
1713 unsigned char ioreg
;
1717 class SBIW
: public Instruction
{
1719 * Subtract Immed from Word.
1721 * Opcode : 1001 0111 KKdd KKKK
1722 * Usage : SBIW Rd, K
1723 * Operation : Rd+1:Rd <- Rd+1:Rd - K
1732 int operator()(Core
*core
);
1733 int trace(Core
*core
, std::ostream
& ostr
);
1742 class SBRC
: public Instruction
{
1744 * Skip if Bit in Reg Cleared.
1746 * Opcode : 1111 110d dddd 0bbb
1747 * Usage : SBRC Rd, b
1748 * Operation : if (Rd(b) = 0) PC <- PC + 2 or 3
1750 * Num Clocks : 1 / 2 / 3
1757 int operator()(Core
*core
);
1758 int trace(Core
*core
, std::ostream
& ostr
);
1765 class SBRS
: public Instruction
{
1767 * Skip if Bit in Reg Set.
1769 * Opcode : 1111 111d dddd 0bbb
1770 * Usage : SBRS Rd, b
1771 * Operation : if (Rd(b) = 1) PC <- PC + 2 or 3
1773 * Num Clocks : 1 / 2 / 3
1780 int operator()(Core
*core
);
1781 int trace(Core
*core
, std::ostream
& ostr
);
1788 class SLEEP
: public Instruction
{
1792 * This is device specific and should be overridden by sub-class.
1794 * Opcode : 1001 0101 1000 1000
1796 * Operation : (see specific hardware specification for Sleep)
1806 int operator()(Core
*core
);
1807 int trace(Core
*core
, std::ostream
& ostr
);
1810 class SPM
: public Instruction
{
1812 * Store Program Memory.
1814 * Opcode : 1001 0101 1110 1000
1816 * Operation : (Z) <- R1:R0
1825 int operator()(Core
*core
);
1826 int trace(Core
*core
, std::ostream
& ostr
);
1835 class STD_Y
: public Instruction
{
1837 * Store Indirect with Displacement.
1839 * Opcode : 10q0 qq1d dddd 1qqq
1840 * Usage : STD Y+q, Rd
1841 * Operation : (Y + q) <- Rd
1850 int operator()(Core
*core
);
1851 int trace(Core
*core
, std::ostream
& ostr
);
1860 class STD_Z
: public Instruction
{
1862 * Store Indirect with Displacement.
1864 * Opcode : 10q0 qq1d dddd 0qqq
1865 * Usage : STD Z+q, Rd
1866 * Operation : (Z + q) <- Rd
1875 int operator()(Core
*core
);
1876 int trace(Core
*core
, std::ostream
& ostr
);
1885 class STS
: public Instruction
{
1887 * Store Direct to data space.
1889 * Opcode : 1001 001d dddd 0000 kkkk kkkk kkkk kkkk
1891 * Operation : (k) <- Rd
1900 int operator()(Core
*core
);
1901 int trace(Core
*core
, std::ostream
& ostr
);
1902 bool is2Word() const { return true; }
1908 class ST_X
: public Instruction
{
1910 * Store Indirect using index X.
1912 * Opcode : 1001 001d dddd 1100
1914 * Operation : (X) <- Rd
1923 int operator()(Core
*core
);
1924 int trace(Core
*core
, std::ostream
& ostr
);
1932 class ST_X_decr
: public ST_X
{
1934 * Store Indirect and Pre-Decrement using index X.
1936 * Opcode : 1001 001d dddd 1110
1938 * Operation : X <- X - 1, (X) <- Rd
1944 ST_X_decr(word opcode
);
1947 int operator()(Core
*core
);
1948 int trace(Core
*core
, std::ostream
& ostr
);
1951 class ST_X_incr
: public ST_X
{
1953 * Store Indirect and Post-Increment using index X.
1955 * Opcode : 1001 001d dddd 1101
1957 * Operation : (X) <- Rd, X <- X + 1
1963 ST_X_incr(word opcode
);
1966 int operator()(Core
*core
);
1967 int trace(Core
*core
, std::ostream
& ostr
);
1970 class ST_Y_decr
: public Instruction
{
1972 * Store Indirect and Pre-Decrement using index Y.
1974 * Opcode : 1001 001d dddd 1010
1976 * Operation : Y <- Y - 1, (Y) <- Rd
1982 ST_Y_decr (word opcode
);
1985 int operator()(Core
*core
);
1986 int trace(Core
*core
, std::ostream
& ostr
);
1994 class ST_Y_incr
: public Instruction
{
1996 * Store Indirect and Post-Increment using index Y.
1998 * Opcode : 1001 001d dddd 1001
2000 * Operation : (Y) <- Rd, Y <- Y + 1
2006 ST_Y_incr (word opcode
);
2009 int operator()(Core
*core
);
2010 int trace(Core
*core
, std::ostream
& ostr
);
2018 class ST_Z_decr
: public Instruction
{
2020 * Store Indirect and Pre-Decrement using index Z.
2022 * Opcode : 1001 001d dddd 0010
2024 * Operation : Z <- Z - 1, (Z) <- Rd
2030 ST_Z_decr (word opcode
);
2033 int operator()(Core
*core
);
2034 int trace(Core
*core
, std::ostream
& ostr
);
2042 class ST_Z_incr
: public Instruction
{
2044 * Store Indirect and Post-Increment using index Z.
2046 * Opcode : 1001 001d dddd 0001
2048 * Operation : (Z) <- Rd, Z <- Z + 1
2054 ST_Z_incr (word opcode
);
2057 int operator()(Core
*core
);
2058 int trace(Core
*core
, std::ostream
& ostr
);
2066 class SUB
: public Instruction
{
2068 * Subtract without Carry.
2070 * Opcode : 0001 10rd dddd rrrr
2071 * Usage : SUB Rd, Rr
2072 * Operation : Rd <- Rd - Rr
2073 * Flags : Z,C,N,V,S,H
2081 int operator()(Core
*core
);
2082 int trace(Core
*core
, std::ostream
& ostr
);
2089 class SUBI
: public Instruction
{
2091 * Subtract Immediate.
2093 * Opcode : 0101 KKKK dddd KKKK
2094 * Usage : SUBI Rd, K
2095 * Operation : Rd <- Rd - K
2096 * Flags : Z,C,N,V,S,H
2104 int operator()(Core
*core
);
2105 int trace(Core
*core
, std::ostream
& ostr
);
2113 class SWAP
: public Instruction
{
2117 * Opcode : 1001 010d dddd 0010
2119 * Operation : Rd(3..0) <--> Rd(7..4)
2128 int operator()(Core
*core
);
2129 int trace(Core
*core
, std::ostream
& ostr
);
2135 class WDR
: public Instruction
{
2139 * This is device specific and must be overridden by sub-class.
2141 * Opcode : 1001 0101 1010 1000
2143 * Operation : (see specific hardware specification for WDR)
2152 int operator()(Core
*core
);
2153 int trace(Core
*core
, std::ostream
& ostr
);
2156 class BREAK
: public Instruction
{
2158 * On-chip Debug system break.
2160 * Opcode : 1001 0101 1001 1000
2162 * Operation : (see specific hardware specification for BREAK)
2171 int operator()(Core
*core
);
2172 int trace(Core
*core
, std::ostream
& ostr
);
2175 class ILLEGAL
: public Instruction
{
2176 //illegal instruction
2179 ILLEGAL(word opcode
);
2182 int operator()(Core
*core
);
2183 int trace(Core
*core
, std::ostream
& ostr
);
2193 #endif /*AVR_INSTRUCTIONS_H*/