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
) const;
32 int trace(Core
*core
, std::ostream
& ostr
) const;
40 class ADD
: public Instruction
{
44 * Opcode : 0000 11rd dddd rrrr
46 * Operation : Rd <- Rd + Rr
55 int operator()(Core
*core
) const;
56 int trace(Core
*core
, std::ostream
& ostr
) const;
63 class ADIW
: public Instruction
{
65 * Add Immediate to Word.
67 * Opcode : 1001 0110 KKdd KKKK
69 * Operation : Rd+1:Rd <- Rd+1:Rd + K
78 int operator()(Core
*core
) const;
79 int trace(Core
*core
, std::ostream
& ostr
) const;
87 class AND
: public Instruction
{
91 * Opcode : 0010 00rd dddd rrrr
93 * Operation : Rd <- Rd & Rr
102 int operator()(Core
*core
) const;
103 int trace(Core
*core
, std::ostream
& ostr
) const;
110 class ANDI
: public Instruction
{
112 * Logical AND with Immed.
114 * Opcode : 0111 KKKK dddd KKKK
116 * Operation : Rd <- Rd & K
125 int operator()(Core
*core
) const;
126 int trace(Core
*core
, std::ostream
& ostr
) const;
134 class ASR
: public Instruction
{
136 * Arithmetic Shift Right.
138 * Opcode : 1001 010d dddd 0101
140 * Operation : Rd(n) <- Rd(n+1), n=0..6
149 int operator()(Core
*core
) const;
150 int trace(Core
*core
, std::ostream
& ostr
) const;
156 class BCLR
: public Instruction
{
158 * Clear a single flag or bit in SREG.
160 * Opcode : 1001 0100 1sss 1000
162 * Operation : SREG(s) <- 0
171 int operator()(Core
*core
) const;
172 int trace(Core
*core
, std::ostream
& ostr
) const;
178 class BLD
: public Instruction
{
179 /* Bit load from T to Register.
181 * Opcode : 1111 100d dddd 0bbb
183 * Operation : Rd(b) <- T
192 int operator()(Core
*core
) const;
193 int trace(Core
*core
, std::ostream
& ostr
) const;
197 unsigned char Kadd
, Kremove
;
200 class BRBC
: public Instruction
{
202 * Branch if Status Flag Cleared.
204 * Pass control directly to the specific bit operation.
206 * Opcode : 1111 01kk kkkk ksss
208 * Operation : if (SREG(s) = 0) then PC <- PC + k + 1
212 * k is an relative address represented in two's complements.
220 int operator()(Core
*core
) const;
221 int trace(Core
*core
, std::ostream
& ostr
) const;
224 unsigned char bitmask
;
228 class BRBS
: public Instruction
{
230 * Branch if Status Flag Set.
232 * Pass control directly to the specific bit operation.
234 * Opcode : 1111 00kk kkkk ksss
236 * Operation : if (SREG(s) = 1) then PC <- PC + k + 1
240 * k is an relative address represented in two's complements.
248 int operator()(Core
*core
) const;
249 int trace(Core
*core
, std::ostream
& ostr
) const;
252 unsigned char bitmask
;
256 class BSET
: public Instruction
{
258 * Set a single flag or bit in SREG.
260 * Opcode : 1001 0100 0sss 1000
262 * Operation : SREG(s) <- 1
271 int operator()(Core
*core
) const;
272 int trace(Core
*core
, std::ostream
& ostr
) const;
278 class BST
:public Instruction
281 * Bit Store from Register to T.
283 * Opcode : 1111 101d dddd 0bbb
285 * Operation : T <- Rd(b)
294 int operator()(Core
*core
) const;
295 int trace(Core
*core
, std::ostream
& ostr
) const;
303 class CALL
: public Instruction
{
307 * Opcode : 1001 010k kkkk 111k kkkk kkkk kkkk kkkk
309 * Operation : PC <- k
318 int operator()(Core
*core
) const;
319 int trace(Core
*core
, std::ostream
& ostr
) const;
320 bool is2Word() const { return true; }
326 class CBI
: public Instruction
{
328 * Clear Bit in I/O Register.
330 * Opcode : 1001 1000 AAAA Abbb
332 * Operation : I/O(A, b) <- 0
339 int operator()(Core
*core
) const;
340 int trace(Core
*core
, std::ostream
& ostr
) const;
347 class COM
: public Instruction
{
351 * Opcode : 1001 010d dddd 0000
353 * Operation : Rd <- $FF - Rd
362 int operator()(Core
*core
) const;
363 int trace(Core
*core
, std::ostream
& ostr
) const;
369 class CP
: public Instruction
{
373 * Opcode : 0001 01rd dddd rrrr
375 * Operation : Rd - Rr
376 * Flags : Z,C,N,V,S,H
384 int operator()(Core
*core
) const;
385 int trace(Core
*core
, std::ostream
& ostr
) const;
392 class CPC
: public Instruction
{
394 * Compare with Carry.
396 * Opcode : 0000 01rd dddd rrrr
398 * Operation : Rd - Rr - C
399 * Flags : Z,C,N,V,S,H
405 int operator()(Core
*core
) const;
406 int trace(Core
*core
, std::ostream
& ostr
) const;
413 class CPI
: public Instruction
{
415 * Compare with Immediate.
417 * Opcode : 0011 KKKK dddd KKKK
420 * Flags : Z,C,N,V,S,H
428 int operator()(Core
*core
) const;
429 int trace(Core
*core
, std::ostream
& ostr
) const;
437 class CPSE
: public Instruction
{
439 * Compare, Skip if Equal.
441 * Opcode : 0001 00rd dddd rrrr
442 * Usage : CPSE Rd, Rr
443 * Operation : if (Rd = Rr) PC <- PC + 2 or 3
445 * Num Clocks : 1 / 2 / 3
452 int operator()(Core
*core
) const;
453 int trace(Core
*core
, std::ostream
& ostr
) const;
460 class DEC
: public Instruction
{
464 * Opcode : 1001 010d dddd 1010
466 * Operation : Rd <- Rd - 1
473 int operator()(Core
*core
) const;
474 int trace(Core
*core
, std::ostream
& ostr
) const;
480 class EICALL
: public Instruction
{
482 * Extended Indirect Call to (Z).
484 * Opcode : 1001 0101 0001 1001
486 * Operation : PC(15:0) <- Z, PC(21:16) <- EIND
495 int operator()(Core
*core
) const;
496 int trace(Core
*core
, std::ostream
& ostr
) const;
502 class EIJMP
: public Instruction
{
504 * Extended Indirect Jmp to (Z).
506 * Opcode : 1001 0100 0001 1001
508 * Operation : PC(15:0) <- Z, PC(21:16) <- EIND
517 int operator()(Core
*core
) const;
518 int trace(Core
*core
, std::ostream
& ostr
) const;
524 class ELPM_Z
: public Instruction
{
526 * Extended Load Program Memory.
528 * Opcode : 1001 000d dddd 0110
530 * Operation : R <- (RAMPZ:Z)
536 ELPM_Z (word opcode
);
539 int operator()(Core
*core
) const;
540 int trace(Core
*core
, std::ostream
& ostr
) const;
546 class ELPM_Z_incr
:public Instruction
{
548 * Extended Ld Prg Mem and Post-Incr.
550 * Opcode : 1001 000d dddd 0111
551 * Usage : ELPM Rd, Z+
552 * Operation : Rd <- (RAMPZ:Z), Z <- Z + 1
558 ELPM_Z_incr(word opcode
);
561 int operator()(Core
*core
) const;
562 int trace(Core
*core
, std::ostream
& ostr
) const;
568 class ELPM
: public Instruction
{
570 * Extended Load Program Memory.
573 * Opcode : 1001 0101 1101 1000
575 * Operation : R0 <- (RAMPZ:Z)
584 int operator()(Core
*core
) const;
585 int trace(Core
*core
, std::ostream
& ostr
) const;
588 class EOR
:public Instruction
{
592 * Opcode : 0010 01rd dddd rrrr
594 * Operation : Rd <- Rd ^ Rr
603 int operator()(Core
*core
) const;
604 int trace(Core
*core
, std::ostream
& ostr
) const;
611 class ESPM
: public Instruction
{
613 * Extended Store Program Memory.
615 * Opcode : 1001 0101 1111 1000
617 * Operation : Z <- R1:R0
626 int operator()(Core
*core
) const;
627 int trace(Core
*core
, std::ostream
& ostr
) const;
630 class FMUL
:public Instruction
{
632 * Fractional Mult Unsigned.
634 * Opcode : 0000 0011 0ddd 1rrr
635 * Usage : FMUL Rd, Rr
636 * Operation : R1:R0 <- (Rd * Rr)<<1 (UU)
645 int operator()(Core
*core
) const;
646 int trace(Core
*core
, std::ostream
& ostr
) const;
653 class FMULS
: public Instruction
{
655 * Fractional Mult Signed.
657 * Opcode : 0000 0011 1ddd 0rrr
658 * Usage : FMULS Rd, Rr
659 * Operation : R1:R0 <- (Rd * Rr)<<1 (SS)
668 int operator()(Core
*core
) const;
669 int trace(Core
*core
, std::ostream
& ostr
) const;
676 class FMULSU
: public Instruction
{
678 * Fract Mult Signed w/ Unsigned.
680 * Opcode : 0000 0011 1ddd 1rrr
681 * Usage : FMULSU Rd, Rr
682 * Operation : R1:R0 <- (Rd * Rr)<<1 (SU)
688 FMULSU (word opcode
);
691 int operator()(Core
*core
) const;
692 int trace(Core
*core
, std::ostream
& ostr
) const;
699 class ICALL
: public Instruction
{
701 * Indirect Call to (Z).
703 * Opcode : 1001 0101 0000 1001
705 * Operation : PC(15:0) <- Z, PC(21:16) <- 0
714 int operator()(Core
*core
) const;
715 int trace(Core
*core
, std::ostream
& ostr
) const;
718 class IJMP
: public Instruction
{
720 * Indirect Jump to (Z).
722 * Opcode : 1001 0100 0000 1001
724 * Operation : PC(15:0) <- Z, PC(21:16) <- 0
733 int operator()(Core
*core
) const;
734 int trace(Core
*core
, std::ostream
& ostr
) const;
737 class IN
: public Instruction
{
739 * In From I/O Location.
741 * Opcode : 1011 0AAd dddd AAAA
743 * Operation : Rd <- I/O(A)
752 int operator()(Core
*core
) const;
753 int trace(Core
*core
, std::ostream
& ostr
) const;
760 class INC
: public Instruction
{
764 * Opcode : 1001 010d dddd 0011
766 * Operation : Rd <- Rd + 1
775 int operator()(Core
*core
) const;
776 int trace(Core
*core
, std::ostream
& ostr
) const;
782 class JMP
: public Instruction
{
786 * Opcode : 1001 010k kkkk 110k kkkk kkkk kkkk kkkk
788 * Operation : PC <- k
797 int operator()(Core
*core
) const;
798 int trace(Core
*core
, std::ostream
& ostr
) const;
799 bool is2Word() const { return true; }
805 class LDD_Y
: public Instruction
{
807 * Load Indirect with Displacement using index Y.
809 * Opcode : 10q0 qq0d dddd 1qqq
810 * Usage : LDD Rd, Y+q
811 * Operation : Rd <- (Y + q)
820 int operator()(Core
*core
) const;
821 int trace(Core
*core
, std::ostream
& ostr
) const;
828 class LDD_Z
: public Instruction
{
830 * Load Indirect with Displacement using index Z.
832 * Opcode : 10q0 qq0d dddd 0qqq
833 * Usage : LDD Rd, Z+q
834 * Operation : Rd <- (Z + q)
843 int operator()(Core
*core
) const;
844 int trace(Core
*core
, std::ostream
& ostr
) const;
851 class LDI
: public Instruction
{
855 * Opcode : 1110 KKKK dddd KKKK
857 * Operation : Rd <- K
866 int operator()(Core
*core
) const;
867 int trace(Core
*core
, std::ostream
& ostr
) const;
874 class LDS
: public Instruction
{
876 * Load Direct from data space.
878 * Opcode : 1001 000d dddd 0000 kkkk kkkk kkkk kkkk
880 * Operation : Rd <- (k)
889 int operator()(Core
*core
) const;
890 int trace(Core
*core
, std::ostream
& ostr
) const;
891 bool is2Word() const { return true; }
897 class LD_X
: public Instruction
{
899 * Load Indirect using index X.
901 * Opcode : 1001 000d dddd 1100
903 * Operation : Rd <- (X)
912 int operator()(Core
*core
) const;
913 int trace(Core
*core
, std::ostream
& ostr
) const;
919 class LD_X_decr
: public LD_X
{
921 * Load Indirect and Pre-Decrement using index X.
923 * Opcode : 1001 000d dddd 1110
925 * Operation : X <- X - 1, Rd <- (X)
931 LD_X_decr(word opcode
);
934 int operator()(Core
*core
) const;
935 int trace(Core
*core
, std::ostream
& ostr
) const;
938 class LD_X_incr
: public LD_X
{
940 * Load Indirect and Post-Increment using index X.
942 * Opcode : 1001 000d dddd 1101
944 * Operation : Rd <- (X), X <- X + 1
950 LD_X_incr(word opcode
);
953 int operator()(Core
*core
) const;
954 int trace(Core
*core
, std::ostream
& ostr
) const;
957 class LD_Y_decr
: public Instruction
{
959 * Load Indirect and PreDecrement using index Y.
961 * Opcode : 1001 000d dddd 1010
963 * Operation : Y <- Y - 1, Rd <- (Y)
969 LD_Y_decr(word opcode
);
972 int operator()(Core
*core
) const;
973 int trace(Core
*core
, std::ostream
& ostr
) const;
979 class LD_Y_incr
: public Instruction
{
981 * Load Indirect and Post-Increment using index Y.
983 * Opcode : 1001 000d dddd 1001
985 * Operation : Rd <- (Y), Y <- Y + 1
991 LD_Y_incr(word opcode
);
994 int operator()(Core
*core
) const;
995 int trace(Core
*core
, std::ostream
& ostr
) const;
1001 class LD_Z_incr
: public Instruction
{
1003 * Load Indirect and Post-Increment using index Z.
1005 * Opcode : 1001 000d dddd 0001
1007 * Operation : Rd <- (Z), Z <- Z+1
1013 LD_Z_incr(word opcode
);
1016 int operator()(Core
*core
) const;
1017 int trace(Core
*core
, std::ostream
& ostr
) const;
1023 class LD_Z_decr
: public Instruction
{
1025 * Load Indirect and Pre-Decrement using index Z.
1027 * Opcode : 1001 000d dddd 0010
1029 * Operation : Z <- Z - 1, Rd <- (Z)
1035 LD_Z_decr(word opcode
);
1038 int operator()(Core
*core
) const;
1039 int trace(Core
*core
, std::ostream
& ostr
) const;
1045 class LPM_Z
: public Instruction
{
1047 * Load Program Memory.
1049 * Opcode : 1001 000d dddd 0100
1051 * Operation : Rd <- (Z)
1060 int operator()(Core
*core
) const;
1061 int trace(Core
*core
, std::ostream
& ostr
) const;
1067 class LPM
: public Instruction
{
1068 /* Load Program Memory.
1070 * This the same as LPM_Z:public Instruction
1072 * Opcode : 1001 0101 1100 1000
1074 * Operation : R0 <- (Z)
1083 int operator()(Core
*core
) const;
1084 int trace(Core
*core
, std::ostream
& ostr
) const;
1087 class LPM_Z_incr
: public Instruction
{
1089 * Load Program Memory and Post-Incr.
1091 * Opcode : 1001 000d dddd 0101
1092 * Usage : LPM Rd, Z+
1093 * Operation : Rd <- (Z), Z <- Z + 1
1099 LPM_Z_incr(word opcode
);
1102 int operator()(Core
*core
) const;
1103 int trace(Core
*core
, std::ostream
& ostr
) const;
1109 class LSR
: public Instruction
{
1111 * Logical Shift Right.
1113 * Opcode : 1001 010d dddd 0110
1115 * Operation : Rd(n) <- Rd(n+1), Rd(7) <- 0, C <- Rd(0)
1124 int operator()(Core
*core
) const;
1125 int trace(Core
*core
, std::ostream
& ostr
) const;
1131 class MOV
:public Instruction
{
1134 * Opcode : 0010 11rd dddd rrrr
1135 * Usage : MOV Rd, Rr
1136 * Operation : Rd <- Rr
1145 int operator()(Core
*core
) const;
1146 int trace(Core
*core
, std::ostream
& ostr
) const;
1153 class MOVW
:public Instruction
{
1155 *Copy Register Pair.
1157 * Opcode : 0000 0001 dddd rrrr
1158 * Usage : MOVW Rd, Rr
1159 * Operation : Rd+1:Rd <- Rr+1:Rr
1168 int operator()(Core
*core
) const;
1169 int trace(Core
*core
, std::ostream
& ostr
) const;
1178 class MUL
: public Instruction
{
1182 * Opcode : 1001 11rd dddd rrrr
1183 * Usage : MUL Rd, Rr
1184 * Operation : R1:R0 <- Rd * Rr (UU)
1193 int operator()(Core
*core
) const;
1194 int trace(Core
*core
, std::ostream
& ostr
) const;
1201 class MULS
: public Instruction
{
1205 * Opcode : 0000 0010 dddd rrrr
1206 * Usage : MULS Rd, Rr
1207 * Operation : R1:R0 <- Rd * Rr (SS)
1216 int operator()(Core
*core
) const;
1217 int trace(Core
*core
, std::ostream
& ostr
) const;
1224 class MULSU
:public Instruction
{
1226 * Mult Signed with Unsigned.
1228 * Rd(unsigned),Rr(signed), result (signed)
1230 * Opcode : 0000 0011 0ddd 0rrr
1231 * Usage : MULSU Rd, Rr
1232 * Operation : R1:R0 <- Rd * Rr (SU)
1241 int operator()(Core
*core
) const;
1242 int trace(Core
*core
, std::ostream
& ostr
) const;
1249 class NEG
: public Instruction
{
1253 * Opcode : 1001 010d dddd 0001
1255 * Operation : Rd <- $00 - Rd
1256 * Flags : Z,C,N,V,S,H
1264 int operator()(Core
*core
) const;
1265 int trace(Core
*core
, std::ostream
& ostr
) const;
1271 class NOP
: public Instruction
{
1275 * Opcode : 0000 0000 0000 0000
1286 int operator()(Core
*core
) const;
1287 int trace(Core
*core
, std::ostream
& ostr
) const;
1290 class OR
:public Instruction
{
1294 * Opcode : 0010 10rd dddd rrrr
1296 * Operation : Rd <- Rd or Rr
1305 int operator()(Core
*core
) const;
1306 int trace(Core
*core
, std::ostream
& ostr
) const;
1313 class ORI
: public Instruction
{
1315 * Logical OR with Immed.
1317 * Opcode : 0110 KKKK dddd KKKK
1319 * Operation : Rd <- Rd or K
1328 int operator()(Core
*core
) const;
1329 int trace(Core
*core
, std::ostream
& ostr
) const;
1336 class OUT
: public Instruction
{
1338 * Out To I/O Location.
1340 * Opcode : 1011 1AAd dddd AAAA
1342 * Operation : I/O(A) <- Rd
1351 int operator()(Core
*core
) const;
1352 int trace(Core
*core
, std::ostream
& ostr
) const;
1356 unsigned char ioreg
;
1359 class POP
: public Instruction
{
1361 * Pop Register from Stack.
1363 * Opcode : 1001 000d dddd 1111
1365 * Operation : Rd <- STACK
1374 int operator()(Core
*core
) const;
1375 int trace(Core
*core
, std::ostream
& ostr
) const;
1381 class PUSH
: public Instruction
{
1383 * Push Register on Stack.
1385 * Opcode : 1001 001d dddd 1111
1387 * Operation : STACK <- Rd
1396 int operator()(Core
*core
) const;
1397 int trace(Core
*core
, std::ostream
& ostr
) const;
1403 class RCALL
: public Instruction
{
1405 * Relative Call Subroutine.
1407 * Opcode : 1101 kkkk kkkk kkkk
1409 * Operation : PC <- PC + k + 1
1411 * Num Clocks : 3 / 4
1418 int operator()(Core
*core
) const;
1419 int trace(Core
*core
, std::ostream
& ostr
) const;
1425 class RET
: public Instruction
{
1427 * Subroutine Return.
1429 * Opcode : 1001 0101 0000 1000
1431 * Operation : PC <- STACK
1433 * Num Clocks : 4 / 5
1440 int operator()(Core
*core
) const;
1441 int trace(Core
*core
, std::ostream
& ostr
) const;
1444 class RETI
: public Instruction
{
1448 * Opcode : 1001 0101 0001 1000
1450 * Operation : PC <- STACK
1452 * Num Clocks : 4 / 5
1459 int operator()(Core
*core
) const;
1460 int trace(Core
*core
, std::ostream
& ostr
) const;
1463 class RJMP
: public Instruction
{
1467 * Opcode : 1100 kkkk kkkk kkkk
1469 * Operation : PC <- PC + k + 1
1478 int operator()(Core
*core
) const;
1479 int trace(Core
*core
, std::ostream
& ostr
) const;
1485 class ROR
: public Instruction
{
1487 * Rotate Right Though Carry.
1489 * Opcode : 1001 010d dddd 0111
1491 * Operation : Rd(7) <- C, Rd(n) <- Rd(n+1), C <- Rd(0)
1500 int operator()(Core
*core
) const;
1501 int trace(Core
*core
, std::ostream
& ostr
) const;
1507 class SBC
: public Instruction
{
1509 * Subtract with Carry.
1511 * Opcode : 0000 10rd dddd rrrr
1512 * Usage : SBC Rd, Rr
1513 * Operation : Rd <- Rd - Rr - C
1514 * Flags : Z,C,N,V,S,H
1522 int operator()(Core
*core
) const;
1523 int trace(Core
*core
, std::ostream
& ostr
) const;
1530 class SBCI
: public Instruction
{
1532 * Subtract Immediate with Carry.
1534 * Opcode : 0100 KKKK dddd KKKK
1535 * Usage : SBCI Rd, K
1536 * Operation : Rd <- Rd - K - C
1537 * Flags : Z,C,N,V,S,H
1545 int operator()(Core
*core
) const;
1546 int trace(Core
*core
, std::ostream
& ostr
) const;
1553 class SBI
: public Instruction
{
1555 * Set Bit in I/O Register.
1557 * Opcode : 1001 1010 AAAA Abbb
1559 * Operation : I/O(A, b) <- 1
1568 int operator()(Core
*core
) const;
1569 int trace(Core
*core
, std::ostream
& ostr
) const;
1572 unsigned char ioreg
;
1576 class SBIC
: public Instruction
{
1578 * Skip if Bit in I/O Reg Cleared.
1580 * Opcode : 1001 1001 AAAA Abbb
1582 * Operation : if (I/O(A,b) = 0) PC <- PC + 2 or 3
1584 * Num Clocks : 1 / 2 / 3
1591 int operator()(Core
*core
) const;
1592 int trace(Core
*core
, std::ostream
& ostr
) const;
1595 unsigned char ioreg
;
1599 class SBIS
: public Instruction
{
1601 * Skip if Bit in I/O Reg Set.
1603 * Opcode : 1001 1011 AAAA Abbb
1605 * Operation : if (I/O(A,b) = 1) PC <- PC + 2 or 3
1607 * Num Clocks : 1 / 2 / 3
1614 int operator()(Core
*core
) const;
1615 int trace(Core
*core
, std::ostream
& ostr
) const;
1618 unsigned char ioreg
;
1622 class SBIW
: public Instruction
{
1624 * Subtract Immed from Word.
1626 * Opcode : 1001 0111 KKdd KKKK
1627 * Usage : SBIW Rd, K
1628 * Operation : Rd+1:Rd <- Rd+1:Rd - K
1637 int operator()(Core
*core
) const;
1638 int trace(Core
*core
, std::ostream
& ostr
) const;
1646 class SBRC
: public Instruction
{
1648 * Skip if Bit in Reg Cleared.
1650 * Opcode : 1111 110d dddd 0bbb
1651 * Usage : SBRC Rd, b
1652 * Operation : if (Rd(b) = 0) PC <- PC + 2 or 3
1654 * Num Clocks : 1 / 2 / 3
1661 int operator()(Core
*core
) const;
1662 int trace(Core
*core
, std::ostream
& ostr
) const;
1669 class SBRS
: public Instruction
{
1671 * Skip if Bit in Reg Set.
1673 * Opcode : 1111 111d dddd 0bbb
1674 * Usage : SBRS Rd, b
1675 * Operation : if (Rd(b) = 1) PC <- PC + 2 or 3
1677 * Num Clocks : 1 / 2 / 3
1684 int operator()(Core
*core
) const;
1685 int trace(Core
*core
, std::ostream
& ostr
) const;
1692 class SLEEP
: public Instruction
{
1696 * This is device specific and should be overridden by sub-class.
1698 * Opcode : 1001 0101 1000 1000
1700 * Operation : (see specific hardware specification for Sleep)
1710 int operator()(Core
*core
) const;
1711 int trace(Core
*core
, std::ostream
& ostr
) const;
1714 class SPM
: public Instruction
{
1716 * Store Program Memory.
1718 * Opcode : 1001 0101 1110 1000
1720 * Operation : (Z) <- R1:R0
1729 int operator()(Core
*core
) const;
1730 int trace(Core
*core
, std::ostream
& ostr
) const;
1733 class STD_Y
: public Instruction
{
1735 * Store Indirect with Displacement.
1737 * Opcode : 10q0 qq1d dddd 1qqq
1738 * Usage : STD Y+q, Rd
1739 * Operation : (Y + q) <- Rd
1748 int operator()(Core
*core
) const;
1749 int trace(Core
*core
, std::ostream
& ostr
) const;
1756 class STD_Z
: public Instruction
{
1758 * Store Indirect with Displacement.
1760 * Opcode : 10q0 qq1d dddd 0qqq
1761 * Usage : STD Z+q, Rd
1762 * Operation : (Z + q) <- Rd
1771 int operator()(Core
*core
) const;
1772 int trace(Core
*core
, std::ostream
& ostr
) const;
1779 class STS
: public Instruction
{
1781 * Store Direct to data space.
1783 * Opcode : 1001 001d dddd 0000 kkkk kkkk kkkk kkkk
1785 * Operation : (k) <- Rd
1794 int operator()(Core
*core
) const;
1795 int trace(Core
*core
, std::ostream
& ostr
) const;
1796 bool is2Word() const { return true; }
1802 class ST_X
: public Instruction
{
1804 * Store Indirect using index X.
1806 * Opcode : 1001 001d dddd 1100
1808 * Operation : (X) <- Rd
1817 int operator()(Core
*core
) const;
1818 int trace(Core
*core
, std::ostream
& ostr
) const;
1824 class ST_X_decr
: public ST_X
{
1826 * Store Indirect and Pre-Decrement using index X.
1828 * Opcode : 1001 001d dddd 1110
1830 * Operation : X <- X - 1, (X) <- Rd
1836 ST_X_decr(word opcode
);
1839 int operator()(Core
*core
) const;
1840 int trace(Core
*core
, std::ostream
& ostr
) const;
1843 class ST_X_incr
: public ST_X
{
1845 * Store Indirect and Post-Increment using index X.
1847 * Opcode : 1001 001d dddd 1101
1849 * Operation : (X) <- Rd, X <- X + 1
1855 ST_X_incr(word opcode
);
1858 int operator()(Core
*core
) const;
1859 int trace(Core
*core
, std::ostream
& ostr
) const;
1862 class ST_Y_decr
: public Instruction
{
1864 * Store Indirect and Pre-Decrement using index Y.
1866 * Opcode : 1001 001d dddd 1010
1868 * Operation : Y <- Y - 1, (Y) <- Rd
1874 ST_Y_decr (word opcode
);
1877 int operator()(Core
*core
) const;
1878 int trace(Core
*core
, std::ostream
& ostr
) const;
1884 class ST_Y_incr
: public Instruction
{
1886 * Store Indirect and Post-Increment using index Y.
1888 * Opcode : 1001 001d dddd 1001
1890 * Operation : (Y) <- Rd, Y <- Y + 1
1896 ST_Y_incr (word opcode
);
1899 int operator()(Core
*core
) const;
1900 int trace(Core
*core
, std::ostream
& ostr
) const;
1906 class ST_Z_decr
: public Instruction
{
1908 * Store Indirect and Pre-Decrement using index Z.
1910 * Opcode : 1001 001d dddd 0010
1912 * Operation : Z <- Z - 1, (Z) <- Rd
1918 ST_Z_decr (word opcode
);
1921 int operator()(Core
*core
) const;
1922 int trace(Core
*core
, std::ostream
& ostr
) const;
1928 class ST_Z_incr
: public Instruction
{
1930 * Store Indirect and Post-Increment using index Z.
1932 * Opcode : 1001 001d dddd 0001
1934 * Operation : (Z) <- Rd, Z <- Z + 1
1940 ST_Z_incr (word opcode
);
1943 int operator()(Core
*core
) const;
1944 int trace(Core
*core
, std::ostream
& ostr
) const;
1950 class SUB
: public Instruction
{
1952 * Subtract without Carry.
1954 * Opcode : 0001 10rd dddd rrrr
1955 * Usage : SUB Rd, Rr
1956 * Operation : Rd <- Rd - Rr
1957 * Flags : Z,C,N,V,S,H
1965 int operator()(Core
*core
) const;
1966 int trace(Core
*core
, std::ostream
& ostr
) const;
1973 class SUBI
: public Instruction
{
1975 * Subtract Immediate.
1977 * Opcode : 0101 KKKK dddd KKKK
1978 * Usage : SUBI Rd, K
1979 * Operation : Rd <- Rd - K
1980 * Flags : Z,C,N,V,S,H
1988 int operator()(Core
*core
) const;
1989 int trace(Core
*core
, std::ostream
& ostr
) const;
1996 class SWAP
: public Instruction
{
2000 * Opcode : 1001 010d dddd 0010
2002 * Operation : Rd(3..0) <--> Rd(7..4)
2011 int operator()(Core
*core
) const;
2012 int trace(Core
*core
, std::ostream
& ostr
) const;
2018 class WDR
: public Instruction
{
2022 * This is device specific and must be overridden by sub-class.
2024 * Opcode : 1001 0101 1010 1000
2026 * Operation : (see specific hardware specification for WDR)
2035 int operator()(Core
*core
) const;
2036 int trace(Core
*core
, std::ostream
& ostr
) const;
2039 class BREAK
: public Instruction
{
2041 * On-chip Debug system break.
2043 * Opcode : 1001 0101 1001 1000
2045 * Operation : (see specific hardware specification for BREAK)
2054 int operator()(Core
*core
) const;
2055 int trace(Core
*core
, std::ostream
& ostr
) const;
2058 class ILLEGAL
: public Instruction
{
2060 * Illegal instruction
2064 ILLEGAL(word opcode
);
2067 int operator()(Core
*core
) const;
2068 int trace(Core
*core
, std::ostream
& ostr
) const;
2078 #endif /*AVR_INSTRUCTIONS_H*/