DR805X 8-bit RISC Microcontroller Instructions set details ver 3.10 DR805x Instructions set details -2Contents 1. Overview ____________________________________________________________ 6 1.1. Document structure. ________________________________________________________6 2. Instructions set brief___________________________________________________ 6 2.1. Instruction set notes ________________________________________________________6 2.2. Instruction set brief – functional order _________________________________________7 2.2.1. 2.2.2. 2.2.3. 2.2.4. 2.2.5. Arithmetic operations ___________________________________________________________ 7 Logic operations _______________________________________________________________ 8 Boolean manipulation___________________________________________________________ 8 Data transfers_________________________________________________________________ 9 Program branches ____________________________________________________________ 10 2.3. Instruction set brief – hexadecimal order ______________________________________11 3. Instructions set details ________________________________________________ 14 3.1. ACALL __________________________________________________________________14 3.2. ADD_____________________________________________________________________15 3.2.1. 3.2.2. 3.2.3. 3.2.4. ADD A, Rn __________________________________________________________________ ADD A, direct ________________________________________________________________ ADD A, @Ri _________________________________________________________________ ADD A, #data ________________________________________________________________ 15 15 16 16 3.3. ADDC ___________________________________________________________________17 3.3.1. 3.3.2. 3.3.3. 3.3.4. ADDC A, Rn _________________________________________________________________ ADDC A, direct _______________________________________________________________ ADDC A, @Ri________________________________________________________________ ADDC A, #data_______________________________________________________________ 17 17 18 18 3.4. AJMP____________________________________________________________________19 3.5. ANL _____________________________________________________________________20 3.5.1. 3.5.2. 3.5.3. 3.5.4. 3.5.5. 3.5.6. 3.5.7. 3.5.8. ANL A, Rn __________________________________________________________________ ANL A, direct ________________________________________________________________ ANL A, @Ri _________________________________________________________________ ANL A, #data ________________________________________________________________ ANL direct, A ________________________________________________________________ ANL direct, #data _____________________________________________________________ ANL C, bit___________________________________________________________________ ANL C, /bit __________________________________________________________________ 20 20 21 21 21 21 22 22 3.6. CJNE ____________________________________________________________________23 3.6.1. 3.6.2. 3.6.3. 3.6.4. CJNE A, direct, rel ____________________________________________________________ CJNE A, #data, rel ____________________________________________________________ CJNE RN, #data, rel___________________________________________________________ CJNE @Ri, #data, rel __________________________________________________________ 23 24 24 25 3.7. CLR _____________________________________________________________________26 3.7.1. 3.7.2. 3.7.3. CLR A______________________________________________________________________ 26 CLR bit ____________________________________________________________________ 26 CLR C _____________________________________________________________________ 27 3.8. CPL _____________________________________________________________________28 3.8.1. 3.8.2. 3.8.3. CPL A______________________________________________________________________ 28 CPL bit _____________________________________________________________________ 28 CPL C______________________________________________________________________ 29 3.9. DA ______________________________________________________________________30 3.10. DEC ___________________________________________________________________31 All trademarks mentioned in this document are trademarks of their respective owners. http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. DR805x Instructions set details 3.10.1. 3.10.2. 3.10.3. 3.10.4. -3- DEC A _____________________________________________________________________ DEC Rn ____________________________________________________________________ DEC direct __________________________________________________________________ DEC @Ri ___________________________________________________________________ 31 31 32 32 3.11. DIV____________________________________________________________________33 3.12. DJNZ __________________________________________________________________34 3.12.1. DJNZ Rn, rel_________________________________________________________________ 34 3.12.2. DJNZ direct, rel ______________________________________________________________ 35 3.13. INC ___________________________________________________________________36 3.13.1. 3.13.2. 3.13.3. 3.13.4. 3.13.5. INC A ______________________________________________________________________ INC Rn _____________________________________________________________________ INC direct ___________________________________________________________________ INC @Ri ____________________________________________________________________ INC DPTR __________________________________________________________________ 36 36 37 37 37 3.14. JB ____________________________________________________________________38 3.15. JBC ___________________________________________________________________39 3.16. JC ____________________________________________________________________40 3.17. JMP ___________________________________________________________________41 3.18. JNB ___________________________________________________________________42 3.19. JNC ___________________________________________________________________43 3.20. JNZ ___________________________________________________________________44 3.21. JZ ____________________________________________________________________45 3.22. LCALL_________________________________________________________________46 3.23. LJMP __________________________________________________________________47 3.24. MOV __________________________________________________________________48 3.24.1. MOV A, Rn __________________________________________________________________ 3.24.2. MOV A, direct ________________________________________________________________ 3.24.3. MOV A, @Ri_________________________________________________________________ 3.24.4. MOV A, #data________________________________________________________________ 3.24.5. MOV Rn, A __________________________________________________________________ 3.24.6. MOV Rn, direct_______________________________________________________________ 3.24.7. MOV Rn, #data_______________________________________________________________ 3.24.8. MOV direct, A ________________________________________________________________ 3.24.9. MOV direct, Rn_______________________________________________________________ 3.24.10. MOV direct, direct __________________________________________________________ 3.24.11. MOV direct, @Ri ___________________________________________________________ 3.24.12. MOV direct, #data __________________________________________________________ 3.24.13. MOV @Ri, A ______________________________________________________________ 3.24.14. MOV @Ri, direct ___________________________________________________________ 3.24.15. MOV @Ri, #data ___________________________________________________________ 3.24.16. MOV C, bit ________________________________________________________________ 3.24.17. MOV bit, C ________________________________________________________________ 3.24.18. MOV DPTR, #data16 ________________________________________________________ 3.25. 48 48 49 49 49 49 50 50 50 50 51 51 51 51 52 52 52 53 MOVC _________________________________________________________________54 3.25.1. MOVC A, @A + DPTR _________________________________________________________ 54 3.25.2. MOVC A, @A + PC ___________________________________________________________ 54 3.26. MOVX _________________________________________________________________55 3.26.1. MOVX A, @Ri _______________________________________________________________ 55 3.26.2. MOVX A, @DPTR ____________________________________________________________ 55 3.26.3. MOVX @Ri, A _______________________________________________________________ 56 All trademarks mentioned in this document are trademarks of their respective owners. http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. DR805x Instructions set details -4- 3.26.4. MOVX @DPTR, A ____________________________________________________________ 56 3.27. MUL___________________________________________________________________57 3.28. NOP___________________________________________________________________58 3.29. ORL ___________________________________________________________________59 3.29.1. 3.29.2. 3.29.3. 3.29.4. 3.29.5. 3.29.6. 3.29.7. 3.29.8. ORL A, Rn __________________________________________________________________ ORL A, direct ________________________________________________________________ ORL A, @Ri _________________________________________________________________ ORL A, #data ________________________________________________________________ ORL direct, A ________________________________________________________________ ORL direct, #data _____________________________________________________________ ORL C, bit __________________________________________________________________ ORL C, /bit __________________________________________________________________ 59 59 60 60 60 60 61 61 3.30. POP ___________________________________________________________________62 3.31. PUSH__________________________________________________________________63 3.32. RET ___________________________________________________________________64 3.33. RETI __________________________________________________________________65 3.34. RL ____________________________________________________________________66 3.35. RLC ___________________________________________________________________67 3.36. RR ____________________________________________________________________68 3.37. RRC___________________________________________________________________69 3.38. SETB __________________________________________________________________70 3.38.1. SETB C ____________________________________________________________________ 70 3.38.2. SETB bit ____________________________________________________________________ 70 3.39. SJMP__________________________________________________________________71 3.40. SUBB _________________________________________________________________72 3.40.1. 3.40.2. 3.40.3. 3.40.4. SUBB A, Rn _________________________________________________________________ SUBB A, direct _______________________________________________________________ SUBB A, @Ri ________________________________________________________________ SUBB A, #data _______________________________________________________________ 72 72 73 73 3.41. SWAP _________________________________________________________________74 3.42. XCH ___________________________________________________________________75 3.42.1. XCH A, Rn __________________________________________________________________ 75 3.42.2. XCH A, direct ________________________________________________________________ 75 3.42.3. XCH A, @Ri _________________________________________________________________ 75 3.43. XCHD _________________________________________________________________76 3.44. XRL ___________________________________________________________________77 3.44.1. 3.44.2. 3.44.3. 3.44.4. 3.44.5. 3.44.6. 4. XRL A, Rn __________________________________________________________________ XRL A, direct ________________________________________________________________ XRL A, @ Ri_________________________________________________________________ XRL A, #data ________________________________________________________________ XRL direct, A ________________________________________________________________ XRL direct, #data _____________________________________________________________ 77 77 78 78 78 78 Contacts ____________________________________________________________ 79 All trademarks mentioned in this document are trademarks of their respective owners. http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. DR805x Instructions set details -5- Tables Table 1. Notes on data addressing modes_______________________________________ 6 Table 2. Notes on program addressing modes ___________________________________ 6 Table 3. Arithmetic operations ________________________________________________ 7 Table 4. Logic operations ____________________________________________________ 8 Table 5. Boolean manipulation ________________________________________________ 8 Table 6. Data transfer_______________________________________________________ 9 Table 7. Program branches _________________________________________________ 10 Table 8. Instruction set brief in hexadecimal order________________________________ 13 All trademarks mentioned in this document are trademarks of their respective owners. http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. -6- DR805x Instructions set details 1. OVERVIEW 1.1. DOCUMENT STRUCTURE. Document contains brief description of DR805X instructions. This manual is intended for design engineers who are planning to use the DR805X HDL core in conjunction with software assembler, compiler and debugger tools. 2. INSTRUCTIONS SET BRIEF 2.1. INSTRUCTION SET NOTES The DR805X has five different addressing modes: immediate, direct, register, indirect and relative. In the immediate addressing mode the data is contained in the opcode. By direct addressing an eight bit address is a part of the opcode, by register addressing, a register is selected in the opcode for the operation. In the indirect addressing mode, a register is selected in the opcode to point to the address used by the operation. The relative addressing mode is used for jump instructions. The following tables give a survey about the instruction set cycles of the DR805X microcontroller core. One cycle is equal to one clock period. Table 1 and Table 2 contain notes for mnemonics used in Instruction set tables. Tables 3 7 show instruction hexadecimal codes, number of bytes and machine cycles that each instruction takes to execute. Rn direct @Ri #data #data 16 bit A B C Working register R0-R7 128 internal RAM locations, any Special Function Registers Indirect internal or external RAM location addressed by register R0 or R1 8-bit constant included in instruction 16-bit constant included as bytes 2 and 3 of instruction 256 software flags, any bit-addressable l/O pin, control or status bit Accumulator B working register Carry flag Table 1. Notes on data addressing modes addr16 addr11 rel Destination address for LCALL and LJMP may be anywhere within the 64-Kbyte of program memory address space. Destination address for ACALL and AJMP will be within the same 2-Kbyte page of program memory as the first byte of the following instruction. SJMP and all conditional jumps include an 8-bit offset byte. Range is +127/-128 bytes relative to the first byte of the following instruction Table 2. Notes on program addressing modes All trademarks mentioned in this document are trademarks of their respective owners. http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. -7- DR805x Instructions set details 2.2. INSTRUCTION SET BRIEF – FUNCTIONAL ORDER 2.2.1. ARITHMETIC OPERATIONS Mnemonic ADD A,Rn ADD A,direct ADD A,@Ri ADD A,#data ADDC A,Rn ADDC A,direct ADDC A,@Ri ADDC A,#data SUBB A,Rn SUBB A,direct SUBB A,@Ri SUBB A,#data INC A INC Rn INC direct INC @Ri DEC A DEC Rn DEC direct DEC @Ri INC DPTR MUL A,B DIV A,B DA A Description Code Add register to accumulator Add direct byte to accumulator Add indirect RAM to accumulator Add immediate data to accumulator Add register to accumulator with carry flag Add direct byte to A with carry flag Add indirect RAM to A with carry flag Add immediate data to A with carry flag Subtract register from A with borrow Subtract direct byte from A with borrow Subtract indirect RAM from A with borrow Subtract immediate data from A with borrow Increment accumulator Increment register Increment direct byte Increment indirect RAM Decrement accumulator Decrement register Decrement direct byte Decrement indirect RAM Increment data pointer Multiply A and B Divide A by B Decimal adjust accumulator 0x28-0x2F 0x25 0x26-0x27 0x24 0x38-0x3F 0x35 0x36-0x37 0x34 0x98-0x9F 0x95 0x96-0x97 0x94 0x04 0x08-0x0F 0x05 0x06-0x07 0x14 0x18-0x1F 0x15 0x16-0x17 0xA3 0xA4 0x84 0xD4 Bytes Cycles 1 2 1 2 1 2 1 2 1 2 1 2 1 1 2 1 1 1 1 2 1 1 1 1 2 3 3 2 2 3 3 2 2 3 3 2 2 3 4 4 2 3 4 4 1 4 5 4 Table 3. Arithmetic operations All trademarks mentioned in this document are trademarks of their respective owners. http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. -8- DR805x Instructions set details 2.2.2. LOGIC OPERATIONS Mnemonic ANL A,Rn ANL A,direct ANL A,@Ri ANL A,#data ANL direct,A ANL direct,#data ORL A,Rn ORL A,direct ORL A,@Ri ORL A,#data ORL direct,A ORL direct,#data XRL A,Rn XRL A,direct XRL A,@Ri XRL A,#data XRL direct,A XRL direct,#data CLR A CPL A RL A RLC A RR A RRC A SWAP A Description Code AND register to accumulator AND direct byte to accumulator AND indirect RAM to accumulator AND immediate data to accumulator AND accumulator to direct byte AND immediate data to direct byte OR register to accumulator OR direct byte to accumulator OR indirect RAM to accumulator OR immediate data to accumulator OR accumulator to direct byte OR immediate data to direct byte Exclusive OR register to accumulator Exclusive OR direct byte to accumulator Exclusive OR indirect RAM to accumulator Exclusive OR immediate data to accumulator Exclusive OR accumulator to direct byte Exclusive OR immediate data to direct byte Clear accumulator Complement accumulator Rotate accumulator left Rotate accumulator left through carry Rotate accumulator right Rotate accumulator right through carry Swap nibbles within the accumulator 0x58-0x5F 0x55 0x56-0x57 0x54 0x52 0x53 0x48-0x4F 0x45 0x46-0x47 0x44 0x42 0x43 0x68-0x6F 0x65 0x66-0x67 0x64 0x62 0x63 0xE4 0xF4 0x23 0x33 0x03 0x13 0xC4 Bytes Cycles 1 2 1 2 2 3 1 2 1 2 2 3 1 2 1 2 2 3 1 1 1 1 1 1 1 2 3 3 2 4 4 2 3 3 2 4 4 2 3 3 2 4 4 1 2 1 1 1 1 1 Table 4. Logic operations 2.2.3. BOOLEAN MANIPULATION Mnemonic CLR C CLR bit SETB C SETB bit CPL C CPL bit ANL C,bit ANL C,/bit ORL C,bit ORL C,/bit MOV C,bit MOV bit,C Description Code Clear carry flag Clear direct bit Set carry flag Set direct bit Complement carry flag Complement direct bit AND direct bit to carry flag AND complement of direct bit to carry OR direct bit to carry flag OR complement of direct bit to carry Move direct bit to carry flag Move carry flag to direct bit 0xC3 0xC2 0xD3 0xD2 0xB3 0xB2 0x82 0xB0 0x72 0xA0 0xA2 0x92 Bytes Cycles 1 2 1 2 1 2 2 2 2 2 2 2 1 4 1 4 1 4 3 3 3 3 3 4 Table 5. Boolean manipulation All trademarks mentioned in this document are trademarks of their respective owners. http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. -9- DR805x Instructions set details 2.2.4. DATA TRANSFERS Mnemonic Description Code MOV A,Rn MOV A,direct MOV A,@Ri MOV A,#data MOV Rn,A MOV Rn,direct MOV Rn,#data Move register to accumulator Move direct byte to accumulator Move indirect RAM to accumulator Move immediate data to accumulator Move accumulator to register Move direct byte to register Move immediate data to register MOV direct,A Move accumulator to direct MOV direct,Rn Move register to direct MOV direct1,direct2 Move direct byte to direct MOV direct,@Ri Move indirect RAM to direct MOV direct,#data MOV @Ri,A MOV @Ri,direct MOV @Ri,#data MOV DPTR,#data16 MOVC A,@A+DPTR MOVC A,@A+PC MOVX A,@Ri MOVX A,@DPTR MOVX @Ri,A MOVX @DPTR,A PUSH direct Move immediate data to direct byte Move accumulator to indirect RAM Move direct byte to indirect RAM Move immediate data to indirect RAM Load data pointer with a 16-bit constant Move code byte relative to DPTR to accumulator Move code byte relative to PC to accumulator Move external RAM (8-bit address) to A Move external RAM (16-bit address) to A Move A to external RAM (8-bit address) Move A to external RAM (16-bit address) Push direct byte onto stack SFR Pop direct byte from stack to RAM Exchange register with accumulator Exchange direct byte with accumulator Exchange indirect RAM with accumulator Exchange low-order nibble indirect RAM with A POP direct XCH A,Rn XCH A,direct XCH A,@Ri XCHD A,@Ri SFR byte RAM byte SFR byte RAM byte SFR byte RAM byte SFR byte RAM byte Bytes Cycles 0xE8-0xEF 0xE5 0xE6-0xE7 0x74 0xF8-0xFF 0xA8-0xAF 0x78-0x7F 1 2 1 2 1 2 2 0xF5 2 0x88-8F 2 85 3 86-87 2 75 F6-F7 A6-A7 76-77 90 93 83 E2-E3 E0 F2-F3 F0 C0 3 1 2 2 3 1 1 1 1 1 1 2 D0 2 C8-CF C5 C6-C7 D6-D7 1 2 1 1 1 2 2 2 2 4 2 2 3 2 3 3 4 3 4 3 3 4 3 3 4 4 3* 2* 4* 3* 4 2 3 2 3 3 3 Table 6. Data transfer * MOVX cycles depends on STRETCH register All trademarks mentioned in this document are trademarks of their respective owners. http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 10 - DR805x Instructions set details 2.2.5. PROGRAM BRANCHES Mnemonic Description Code ACALL addr11 LCALL addr16 RET RETI AJMP addr11 LJMP addr16 SJMP rel JMP @A+DPTR JZ rel JNZ rel Absolute subroutine call Long subroutine call Return from subroutine Return from interrupt Absolute jump Long jump Short jump (relative address) Jump indirect relative to the DPTR Jump if accumulator is zero Jump if accumulator is not zero JC rel Jump if carry flag is set JNC rel Jump if carry flag is not set JB bit,rel JNB bit,rel JBC bit,direct rel CJNE A,direct rel CJNE A,#data rel CJNE Rn,#data rel CJNE @Ri,#data rel DJNZ Rn,rel DJNZ direct,rel NOP Jump if direct bit is set Jump if direct bit is not set Jump if direct bit is set and clear bit Compare direct byte to A and jump if not equal Compare immediate to A and jump if not equal Compare immediate to reg. and jump if not equal Compare immediate to ind. and jump if not equal Decrement register and jump if not zero Decrement direct byte and jump if not zero No operation C=1 C=0 C=0 C=1 Bytes Cycles 0x11-0xF1 12 22 32 01-E1 02 80 73 60 70 2 3 1 1 2 3 2 1 2 2 40 2 50 2 20 30 10 B5 B4 B8-BF B6-B7 D8-DF D5 00 3 3 3 3 3 3 3 2 3 1 6 6 4 4 3 4 3 3 3 3 3 2 3 2 4 4 4 5 4 4 5 4 5 1 Table 7. Program branches All trademarks mentioned in this document are trademarks of their respective owners. http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. DR805x Instructions set details - 11 - 2.3. INSTRUCTION SET BRIEF – HEXADECIMAL ORDER Opcode 00 H 01 H 02 H 03 H 04 H 05 H 06 H 07 H 08 H 09 H 0A H 0B H 0C H 0D H 0E H 0F H 10 H 11 H 12 H 13 H 14 H 15 H 16 H 17 H 18 H 19 H 1A H 1B H 1C H 1D H 1E H 1F H 20 H 21 H 22 H 23 H 24 H 25 H 26 H 27 H 28 H 29 H 2A H 2B H 2C H 2D H 2E H 2F H Mnemonic NOP AJMP addr11 LJMP addr16 RR A INC A INC direct INC @R0 INC @R1 INC R0 INC R1 INC R2 INC R3 INC R4 INC R5 INC R6 INC R7 JBC bit,rel ACALL addr11 LCALL addr16 RRC A DEC A DEC direct DEC @R0 DEC @R1 DEC R0 DEC R1 DEC R2 DEC R3 DEC R4 DEC R5 DEC R6 DEC R7 JB bit.rel AJMP addr11 RET RL A ADD A,#data ADD A,direct ADD A,@R0 ADD A,@R1 ADD A,R0 ADD A,R1 ADD A,R2 ADD A,R3 ADD A,R4 ADD A,R5 ADD A,R6 ADD A,R7 All trademarks mentioned in this document are trademarks of their respective owners. Opcode 30 H 31 H 32 H 33 H 34 H 35 H 36 H 37 H 38 H 39 H 3A H 3B H 3C H 3D H 3E H 3F H 40 H 41 H 42 H 43 H 44 H 45 H 46 H 47 H 48 H 49 H 4A H 4B H 4C H 4D H 4E H 4F H 50 H 51 H 52 H 53 H 54 H 55 H 56 H 57 H 58 H 59 H 5A H 5B H 5C H 5D H 5E H 5F H Mnemonic JNB bit.rel ACALL addr11 RETI RLC A ADDC A,#data ADDC A,direct ADDC A,@R0 ADDC A,@R1 ADDC A,R0 ADDC A,R1 ADDC A,R2 ADDC A,R3 ADDC A,R4 ADDC A,R5 ADDC A,R6 ADDC A,R7 JC rel AJMP addr11 ORL direct,A ORL direct,#data ORL A,#data ORL A,direct ORL A,@R0 ORL A,@R1 ORL A,R0 ORL A,R1 ORL A,R2 ORL A,R3 ORL A,R4 ORL A,R5 ORL A,R6 ORL A,R7 JNC rel ACALL addr11 ANL direct,A ANL direct,#data ANL A,#data ANL A,direct ANL A,@R0 ANL A,@R1 ANL A,R0 ANL A,R1 ANL A,R2 ANL A,R3 ANL A,R4 ANL A,R5 ANL A,R6 ANL A,R7 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. DR805x Instructions set details Opcode 60 H 61 H 62 H 63 H 64 H 65 H 66 H 67 H 68 H 69 H 6A H 6B H 6C H 6D H 6E H 6F H 70 H 71 H 72 H 73 H 74 H 75 H 76 H 77 H 78 H 79 H 7A H 7B H 7C H 7D H 7E H 7F H 80 H 81 H 82 H 83 H 84 H 85 H 86 H 87 H 88 H 89 H 8A H 8B H 8C H 8D H 8E H 8F H Mnemonic JZ rel AJMP addr11 XRL direct,A XRL direct,#data XRL A,#data XRL A,direct XRL A,@R0 XRL A,@R1 XRL A,R0 XRL A,R1 XRL A,R2 XRL A,R3 XRL A,R4 XRL A,R5 XRL A,R6 XRL A,R7 JNZ rel ACALL addr11 ORL C,direct JMP @A+DPTR MOV A,#data MOV direct,#data MOV @R0,#data MOV @R1,#data MOV R0.#data MOV R1.#data MOV R2.#data MOV R3.#data MOV R4.#data MOV R5.#data MOV R6.#data MOV R7.#data SJMP rel AJMP addr11 ANL C,bit MOVC A,@A+PC DIV AB MOV direct,direct MOV direct,@R0 MOV direct,@R1 MOV direct,R0 MOV direct,R1 MOV direct,R2 MOV direct,R3 MOV direct,R4 MOV direct,R5 MOV direct,R6 MOV direct,R7 All trademarks mentioned in this document are trademarks of their respective owners. - 12 Opcode 90 H 91 H 92 H 93 H 94 H 95 H 96 H 97 H 98 H 99 H 9A H 9B H 9C H 9D H 9E H 9F H A0 H A1 H A2 H A3 H A4 H A5 H A6 H A7 H A8 H A9 H AA H AB H AC H AD H AE H AF H B0 H B1 H B2 H B3 H B4 H B5 H B6 H B7 H B8 H B9 H BA H BB H BC H BD H BE H BF H Mnemonic MOV DPTR,#data16 ACALL addr11 MOV bit,C MOVC A,@A+DPTR SUBB A,#data SUBB A,direct SUBB A,@R0 SUBB A,@R1 SUBB A,R0 SUBB A,R1 SUBB A,R2 SUBB A,R3 SUBB A,R4 SUBB A,R5 SUBB A,R6 SUBB A,R7 ORL C,bit AJMP addr11 MOV C,bit INC DPTR MUL AB MOV @R0,direct MOV @R1,direct MOV R0,direct MOV R1,direct MOV R2,direct MOV R3,direct MOV R4,direct MOV R5,direct MOV R6,direct MOV R7,direct ANL C,bit ACALL addr11 CPL bit CPL C CJNE A,#data,rel CJNE A,direct,rel CJNE @R0,#data,rel CJNE @R1,#data,rel CJNE R0,#data,rel CJNE R1,#data,rel CJNE R2,#data,rel CJNE R3,#data,rel CJNE R4,#data,rel CJNE R5,#data,rel CJNE R6,#data,rel CJNE R7,#data,rel http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. DR805x Instructions set details Opcode C0 H C1 H C2 H C3 H C4 H C5 H C6 H C7 H C8 H C9 H CA H CB H CC H CD H CE H CF H D0 H D1 H D2 H D3 H D4 H D5 H D6 H D7 H D8 H D9 H DA H DB H DC H DD H DE H DF H Mnemonic PUSH direct AJMP addr11 CLR bit CLR C SWAP A XCH A, direct XCH A,@R0 XCH A,@R1 XCH A,R0 XCH A,R1 XCH A,R2 XCH A,R3 XCH A,R4 XCH A,R5 XCH A,R6 XCH A,R7 POP direct ACALL addr11 SETB bit SETB C DA A DJNZ direct, rel XCHD A,@R0 XCHD A,@R1 DJNZ R0,rel DJNZ R1,rel DJNZ R2,rel DJNZ R3,rel DJNZ R4,rel DJNZ R5,rel DJNZ R6,rel DJNZ R7,rel - 13 Opcode E0 H E1 H E2 H E3 H E4 H E5 H E6 H E7 H E8 H E9 H EA H EB H EC H ED H EE H EF H F0 H F1 H F2 H F3 H F4 H F5 H F6 H F7 H F8 H F9 H FA H FB H FC H FD H FE H FF H Mnemonic MOVX A,@DPTR AJMP addr11 MOVX A,@R0 MOVX A,@R1 CLR A MOV A, direct MOV A,@R0 MOV A,@R1 MOV A,R0 MOV A,R1 MOV A,R2 MOV A,R3 MOV A,R4 MOV A,R5 MOV A,R6 MOV A,R7 MOVX @DPTR,A ACALL addr11 MOVX @R0,A MOVX @R1,A CPL A MOV direct, A MOV @R0,A MOV @R1,A MOV R0,A MOV R1,A MOV R2,A MOV R3,A MOV R4,A MOV R5,A MOV R6,A MOV R7,A Table 8. Instruction set brief in hexadecimal order All trademarks mentioned in this document are trademarks of their respective owners. http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 14 - DR805x Instructions set details 3. INSTRUCTIONS SET DETAILS 3.1. ACALL Instruction: ACALL addr11 Function: Absolute call Description: ACALL unconditionally calls a subroutine located at the indicated address. The instruction increments the PC twice to obtain the address of the following instruction, then pushes the 16-bit result onto the stack (low-order byte first) and increments the stack pointer twice. The destination address is obtained by successively concatenating the five high-order bits of the incremented PC, op code bits 7-5, and the second byte of the instruction. The subroutine called must therefore start within the same 2K block of program memory as the first byte of the instruction following ACALL. No flags are affected. Operation: Bytes: Cycles: ← (PC) + 2 ← (SP) + 1 ← (PC7-0) ← (SP) + 1 ← (PC15-8) ← page address (PC) (SP) ((SP)) (SP) ((SP)) (PC10-0) 2 6 Encoding: a10 a9 a8 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 0 0 1 a7 a6 a5 a4 a3 a2 a1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. a0 - 15 - DR805x Instructions set details 3.2. ADD Instruction: ADD A, <src-byte> Function: Adds A to the source operand and returns the result to A. Description: ADD adds the byte variable indicated to the accumulator, leaving the result in the accumulator. The carry and auxiliary carry flags are set, respectively, if there is a carry out of bit 7 or bit 3, and cleared otherwise. When adding unsigned integers, the carry flag indicates an overflow occurred. OV is set if there is a carry out of bit 6 but not out of bit 7, or a carry out of bit 7 but not out of bit 6; otherwise OV is cleared. When adding signed integers, OV indicates a negative number produced as the sum of two positive operands, or a positive sum from two negative operands. Four source operand addressing modes are allowed: register, direct, register- indirect, or immediate. 3.2.1. ADD A, RN Operation: (PC) ← (PC) + 1 (A) ← (A) + (Rn) Bytes: Cycles: 1 2 Encoding: 0 0 1 0 1 r r r 1 0 1 3.2.2. ADD A, DIRECT Operation: (PC) ← (PC) + 2 (A) ← (A) + (direct) Bytes: Cycles: 2 3 Encoding: 0 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 direct address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 16 - DR805x Instructions set details 3.2.3. ADD A, @RI Operation: (PC) ← (PC) + 1 (A) ← (A) + ((Ri)) Bytes: Cycles: 1 3 Encoding: 0 0 1 0 0 1 1 i 0 1 0 0 3.2.4. ADD A, #DATA Operation: (PC) ← (PC) + 2 (A) ← (A) + #data Bytes: Cycles: 2 2 Encoding: 0 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 immediate data http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 17 - DR805x Instructions set details 3.3. ADDC Instruction: ADDC A, < src-byte> Function: Adds A and the source operand, then adds one (1) if CY is set, and puts the result in A. Description: ADDC simultaneously adds the byte variable indicated, the carry flag and the accumulator contents, leaving the result in the accumulator. The carry and auxiliary carry flags are set, respectively, if there is a carry out of bit 7 or bit 3, and cleared otherwise. When adding unsigned integers, the carry flag indicates an overflow occurred. OV is set if there is a carry out of bit 6 but not out of bit 7, or a carry out of bit 7 but not out of bit 6; otherwise OV is cleared. When adding signed integers, OV indicates a negative number produced as the sum of two positive operands or a positive sum from two negative operands. Four source operand-addressing modes are allowed: register= direct, registerindirect, or immediate. 3.3.1. ADDC A, RN Operation: (PC) ← (PC) + 1 (A) ← (A) + (C) + (Rn) Bytes: Cycles: 1 2 Encoding: 0 0 1 1 1 r r r 0 1 3.3.2. ADDC A, DIRECT Operation: (PC) ← (PC) + 2 (A) ← (A) + (C) + (direct) Bytes: Cycles: 2 3 Encoding: 0 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 1 direct address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 18 - DR805x Instructions set details 3.3.3. ADDC A, @RI Operation: (PC) ← (PC) + 1 (A) ← (A) + (C) + ((Ri)) Bytes: Cycles: 1 3 Encoding: 0 0 1 1 0 1 1 i 0 0 3.3.4. ADDC A, #DATA Operation: (PC) ← (PC) + 2 (A) ← (A) + (C) + #data Bytes: Cycles: 2 2 Encoding: 0 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 1 immediate data http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 19 - DR805x Instructions set details 3.4. AJMP Instruction: AJMP addr11 Function: Absolute jump Description: AJMP transfers program execution to the indicated address, which is formed at run- time by concatenating the high-order five bits of the PC (after incrementing the PC twice), op code bits 7-5, and the second byte of the instruction. The destination must therefore be within the same 2K block of program memory as the first byte of the instruction following AJMP. Operation: (PC) ← (PC) + 2 (PC10-0) ← page address Bytes: Cycles: 2 3 Encoding: a10 a9 a8 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 0 1 a7 a6 a5 a4 a3 a2 a1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. a0 - 20 - DR805x Instructions set details 3.5. ANL Instruction: ANL <dest-byte>, <src-byte> Function: Logical AND for byte operands Description: ANL performs the bit wise logical AND operation between the variables indicated and stores the results in the destination variable. No flags are affected (except P, if <dest-byte> = A). The two operands allow six addressing mode combinations. When the destination is a accumulator, the source can use register, direct, register-indirect, or immediate addressing; when the destination is a direct address, the source can be the accumulator or immediate data. Note: When this instruction is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins. 3.5.1. ANL A, RN Operation: (PC) ← (PC) + 1 (A) ← (A) and (Rn) Bytes: Cycles: 1 2 Encoding: 0 1 0 1 1 r r r 1 0 1 3.5.2. ANL A, DIRECT Operation: (PC) ← (PC) + 2 (A) ← (A) and (direct) Bytes: Cycles: 2 3 Encoding: 0 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 direct address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 21 - DR805x Instructions set details 3.5.3. ANL A, @RI Operation: (PC) ← (PC) + 1 (A) ← (A) and ((Ri)) Bytes: Cycles: 1 3 Encoding: 0 1 0 1 0 1 1 i 1 0 0 immediate data 1 0 direct address 1 1 3.5.4. ANL A, #DATA Operation: (PC) ← (PC) + 2 (A) ← (A) and #data Bytes: Cycles: 2 2 Encoding: 0 1 0 1 0 3.5.5. ANL DIRECT, A Operation: (PC) ← (PC) + 2 (direct) ← (direct) and (A) Bytes: Cycles: 2 4 Encoding: 0 1 0 1 0 0 3.5.6. ANL DIRECT, #DATA Operation: (PC) ← (PC) + 3 (direct) ← (direct) and #data Bytes: Cycles: 3 4 Encoding: 0 Instruction: 1 0 1 0 0 direct address immediate data ANL C, <src-bit> All trademarks mentioned in this document are trademarks of their respective owners. http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 22 - DR805x Instructions set details Function: Logical AND for bit operands Description: If the Boolean value of the source bit is a logic 0 then clear the carry flag; otherwise leave the carry flag in its current state. A slash (“/” preceding the operand in the assembly language indicates that the logical complement of the addressed bit is used as the source value, but the source bit itself is not affected. No other flags are affected. Only direct bit addressing is allowed for the source operand. 3.5.7. ANL C, BIT Operation: (PC) ← (PC) + 2 (C) ← (C) and (bit) Bytes: Cycles: 2 3 Encoding: 1 0 0 0 0 0 1 0 bit address 0 0 0 bit address 3.5.8. ANL C, /BIT Operation: (PC) ← (PC) + 2 (C) ← (C) and / (bit) Bytes: Cycles: 2 3 Encoding: 1 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 23 - DR805x Instructions set details 3.6. CJNE Instruction: CJNE <dest-byte >, < src-byte >, rel Function: Compare and jump if not equal. Description: CJNE compares the magnitudes of the first two operands, and branches if their values are not equal. The branch destination is computed by adding the signed relative displacement in the last instruction byte to the PC, after incrementing the PC to the start of the next instruction. The carry flag is set if the unsigned integer value of <dest-byte> is less than the unsigned integer value of <src-byte>; otherwise, the carry is cleared. Neither operand is affected. The first two operands allow four addressing mode combinations: the accumulator may be compared with any directly addressed byte or immediate data, and any indirect RAM location or working register can be compared with an immediate constant. 3.6.1. CJNE A, DIRECT, REL Operation: (PC) ← (PC) + 3 if (A) < > (direct) then (PC) ← (PC) + relative offset if (A) < (direct) then (C) ← 1 else (C) ← 0 Bytes: Cycles: 3 5 Encoding: 1 0 1 1 0 1 direct address relative address All trademarks mentioned in this document are trademarks of their respective owners. 0 1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 24 - DR805x Instructions set details 3.6.2. CJNE A, #DATA, REL Operation: (PC) ← (PC) + 3 if (A) < > data then (PC) ← (PC) + relative offset if (A) < data then (C) ← 1 else (C) ← 0 Bytes: Cycles: 3 4 Encoding: 1 0 1 1 0 1 immediate data relative address 0 0 3.6.3. CJNE RN, #DATA, REL Operation: (PC) ← (PC) + 3 if (Rn) < > data then (PC) ← (PC) + relative offset if (Rn) < data then (C) ← 1 else (C) ← 0 Bytes: Cycles: 3 4 Encoding: 1 0 1 1 1 r immediate data relative address All trademarks mentioned in this document are trademarks of their respective owners. r r http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 25 - DR805x Instructions set details 3.6.4. CJNE @RI, #DATA, REL Operation: (PC) ← (PC) + 3 if ((Ri)) < > data then (PC) ← (PC) + relative offset if ((Ri)) < data then (C) ← 1 else (C) ← 0 Bytes: Cycles: 3 5 Encoding: 1 0 1 1 0 1 immediate data relative address All trademarks mentioned in this document are trademarks of their respective owners. 1 i http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 26 - DR805x Instructions set details 3.7. CLR 3.7.1. CLR A Function: Clear accumulator Description: The accumulator is cleared (all bits set to zero). No flags are affected. Operation: (PC) ← (PC) + 1 (A) ← 0 Bytes: Cycles: 1 1 Encoding: 1 3.7.2. CLR Function: 1 1 0 0 1 0 0 BIT Clear bit Description: The indicated bit is cleared (reset to zero). No other flags are affected. Operation: (PC) ← (PC) + 2 bit ← 0 Bytes: Cycles: 2 4 Encoding: 1 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 1 0 bit address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 27 - DR805x Instructions set details 3.7.3. CLR C Function: Clear carry Description: The carry flag is cleared (reset to zero). No other flags are affected. Operation: (PC) ← (PC) + 1 (C) ← 0 Bytes: Cycles: 1 1 Encoding: 1 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 1 1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 28 - DR805x Instructions set details 3.8. CPL 3.8.1. CPL A Function: Complement accumulator Description: Each bit of the accumulator is logically complemented (one’s complement). Bits which previously contained a one are changed to zero and vice versa. No flags are affected. Operation: (PC) ← (PC) + 1 (A) ← / (A) Bytes: Cycles: 1 2 Encoding: 1 1 1 1 0 1 0 0 3.8.2. CPL BIT Function: Complement bit Description: The bit variable specified is complemented. A bit which had been a one is changed to zero and vice versa. No other flags are affected. CPL can operate on the carry or any directly addressable bit. Note: When this instruction is used to modify an output pin, the value used as the original data will be read from the output data latch, not the input pin. Operation: (PC) ← (PC) + 2 (C) ← (bit) Bytes: Cycles: 2 4 Encoding: 1 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 0 1 0 bit address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 29 - DR805x Instructions set details 3.8.3. CPL C Function: Complement carry Description: The carry flag is complemented. A bit which had been a one is changed to zero and vice versa. Operation: (PC) ← (PC) + 1 (C) ← / (C) Bytes: Cycles: 1 1 Encoding: 1 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 0 1 1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 30 - DR805x Instructions set details 3.9. DA Instruction: DA A Function: Decimal adjust accumulator for addition Description: DA A adjusts the eight-bit value in the accumulator resulting from the earlier addition of two variables (each in packed BCD format), producing two four-bit digits. Any ADD or ADDC instruction may have been used to perform the addition. If accumulator bits 3-0 are greater than nine (xxxx1010-xxxx1111), or if the AC flag is one, six is added to the accumulator producing the proper BCD digit in the low- order nibble. This internal addition would set the carry flag if a carry-out of the loworder four-bit field propagated through all high-order bits, but it would not clear the carry flag otherwise. If the carry flag is now set, or if the four high-order bits now exceed nine (1010xxxx-1111xxxx), these high-order bits are incremented by six, producing the proper BCD digit in the high-order nibble. Again, this would set the carry flag if there was a carry-out of the high-order bits, but wouldn't clear the carry. The carry flag thus indicates if the sum of the original two BCD variables is greater than 100, allowing multiple precision decimal addition. OV is not affected. All of this occurs during the one instruction cycle. Essentially; this instruction performs the decimal conversion by adding 00 H , 06 H , 60 H , or 66 H to the accumulator, depending on initial accumulator and PSW conditions. Note: DA A cannot simply convert a hexadecimal number in the accumulator to BCD notation, nor does DA A apply to decimal subtraction. Operation: (PC) ← (PC) + 1 if [[(A3-0) > 9] ^ [(AC) = 1]] then (A3-0) ← (A3-0) + 6 next if [[(A7-4) > 9] ^ [(C) = 1]] then (A7-4) ← (A7-4) + 6 Bytes: Cycles: 1 4 Encoding: 1 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 1 0 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 31 - DR805x Instructions set details 3.10. DEC Instruction: DEC byte Function: Decrement byte Description: The variable indicated is decremented by 1. An original value of 00 H will underflow to 0FF H. No flags are affected. Four operand addressing modes are allowed: accumulator, register, direct, or register-indirect. Note: When this instruction is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins. 3.10.1. DEC A Operation: (PC) ← (PC) + 1 (A) ← (A) - 1 Bytes: Cycles: 1 2 Encoding: 0 3.10.2. 0 0 1 0 1 0 0 1 r r r DEC RN Operation: (PC) ← (PC) + 1 (Rn) ← (Rn) - 1 Bytes: Cycles: 1 3 Encoding: 0 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 32 - DR805x Instructions set details 3.10.3. DEC DIRECT Operation: (PC) ← (PC) + 2 (direct) ← (direct) - 1 Bytes: Cycles: 2 4 Encoding: 0 3.10.4. 0 0 1 0 1 0 1 0 1 1 i direct address DEC @RI Operation: (PC) ← (PC) + 1 ((Ri)) ← ((Ri)) - 1 Bytes: Cycles: 1 4 Encoding: 0 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 33 - DR805x Instructions set details 3.11. DIV Instruction: DIV AB Function: Divide Description: DIV AB divides the unsigned eight-bit integer in the accumulator by the unsigned eight-bit integer in register B. The accumulator receives the integer part of the quotient; register B receives the integer remainder. The carry and OV flags will be cleared. If B had originally contained 00 H, the values returned in the accumulator and B register will be undefined and the overflow flag will be set. The carry flag is cleared in any case. Exception: Operation: (PC) ← (PC) + 1 (A15-8) ← (A) / (B) – result’s bits 15..8 (B7-0) ← (A) / (B) – result’s bits 7..0 Bytes: Cycles: 1 5 Encoding: 1 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 1 0 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 34 - DR805x Instructions set details 3.12. DJNZ Instruction: DJNZ <byte>, <rel-addr> Function: Decrement and jump if not zero Description: DJNZ decrements the location indicated by 1, and branches to the address indicated by the second operand if the resulting value is not zero. An original value of 00 H will underflow to 0FF H. No flags are affected. The branch destination would be computed by adding the signed relative-displacement value in the last instruction byte to the PC, after incrementing the PC to the first byte of the following instruction. The location decremented may be a register or directly addressed byte. Note: When this instruction is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins. 3.12.1. DJNZ RN, REL Operation: (PC) ← (PC) + 2 (Rn) ← (Rn) - 1 if (Rn) ≠ 0 then (PC) ← (PC) + rel Bytes: Cycles: 2 4 Encoding: 1 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 1 r r r relative address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 35 - DR805x Instructions set details 3.12.2. DJNZ DIRECT, REL Operation: (PC) ← (PC) + 3 (direct) ← (direct) - 1 if (direct) ≠ 0 then (PC) ← (PC) + rel Bytes: Cycles: 3 5 Encoding: 1 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 1 0 direct address relative address 1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 36 - DR805x Instructions set details 3.13. INC Instruction: INC operand Function: Increment Description: INC increments the indicated variable by 1. An original value of 0FFh will overflow to 00h. No flags are affected. Three addressing modes are allowed: register, direct, or register-indirect. Note: When this instruction is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins. 3.13.1. INC A Operation: (PC) ← (PC) + 1 (A) ← (A) + 1 Bytes: Cycles: 1 2 Encoding: 0 3.13.2. 0 0 0 0 1 0 0 1 r r r INC RN Operation: (PC) ← (PC) + 1 (Rn) ← (Rn) + 1 Bytes: Cycles: 1 3 Encoding: 0 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 37 - DR805x Instructions set details 3.13.3. INC DIRECT Operation: (PC) ← (PC) + 2 (direct) ← (direct) + 1 Bytes: Cycles: 2 4 Encoding: 0 3.13.4. 0 0 0 0 1 0 1 0 1 1 i direct address INC @RI Operation: (PC) ← (PC) + 1 ((Ri)) ← ((Ri)) + 1 Bytes: Cycles: 1 4 Encoding: 0 3.13.5. Function: 0 0 0 INC DPTR Increment data pointer Description: Increment the 16-bit data pointer by 1. A 16-bit increment (modulo 2 16) is performed; an overflow of the low-order byte of the data pointer (DPL) from 0FF H to 00 H will increment the high-order byte (DPH). No flags are affected. This is the only 16-bit register which can be incremented. Operation: (PC) ← (PC) + 1 (DPTR) ← (DPTR) + 1 Bytes: Cycles: 1 1 Encoding: 1 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 1 1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 38 - DR805x Instructions set details 3.14. JB Instruction: JB bit, rel Function: Jump if bit is set Description: If the indicated bit is a one, jump to the address indicated; otherwise proceed with the next instruction. The branch destination is computed by adding the signed relative-displacement in the third instruction byte to the PC, after incrementing the PC to the first byte of the next instruction. The bit tested is not modified. No flags are affected. Operation: (PC) ← (PC) + 3 if (bit) = 1 then (PC) ← (PC) + rel Bytes: Cycles: 3 4 Encoding: 0 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 0 bit address relative address 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 39 - DR805x Instructions set details 3.15. JBC Instruction: JBC bit, rel Function: Jump if bit is set and clear bit Description: If the indicated bit is one, branch to the address indicated; otherwise proceed with the next instruction. In either case, clear the designated bit. The branch destination is computed by adding the signed relative displacement in the third instruction byte to the PC, after incrementing the PC to the first byte of the next instruction. No flags are affected. Note: When this instruction is used to test an output pin, the value used as the original data will be read from the output data latch, not the input pin. Operation: (PC) ← (PC) + 3 if (bit) = 1 then (bit) ← 0 (PC) ← (PC) + rel Bytes: Cycles: 3 4 Encoding: 0 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 0 0 bit address relative address 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 40 - DR805x Instructions set details 3.16. JC Instruction: JC rel Function: Jump if carry is set Description: If the carry flag is set, branch to the address indicated; otherwise proceed with the next instruction. The branch destination is computed by adding the signed relative- displacement in the second instruction byte to the PC, after incrementing the PC twice. No flags are affected. Operation: (PC) ← (PC) + 2 if (C) = 1 then (PC) ← (PC) + rel Bytes: Cycles: 2 3 – C=1 2 – C=0 Encoding: 0 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 0 0 relative address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 41 - DR805x Instructions set details 3.17. JMP Instruction: JMP @A + DPTR Function: Jump indirect Description: Add the eight-bit unsigned contents of the accumulator with the sixteenbit data pointer, and load the resulting sum to the program counter. This will be the address for subsequent instruction fetches. Sixteen-bit addition is performed (modulo 2 16): a carry-out from the low-order eight bits propagates through the higher-order bits. Neither the accumulator nor the data pointer is altered. No flags are affected. Operation: (PC) ← (A) + (DPTR) Bytes: Cycles: 1 3 Encoding: 0 1 1 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 0 1 1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 42 - DR805x Instructions set details 3.18. JNB Instruction: JNB bit,rel Function: Jump if bit is not set Description: If the indicated bit is a zero, branch to the indicated address; otherwise proceed with the next instruction. The branch destination is computed by adding the signed relative-displacement in the third instruction byte to the PC, after incrementing the PC to the first byte of the next instruction. The bit tested is not modified. No flags are affected. Operation: (PC) ← (PC) + 3 if (bit) = 0 then (PC) ← (PC) + rel. Bytes: Cycles: 3 4 Encoding: 0 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 0 0 bit address relative address 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 43 - DR805x Instructions set details 3.19. JNC Instruction: JNC rel Function: Jump if carry is not set Description: If the carry flag is a zero, branch to the address indicated; otherwise proceed with the next instruction. The branch destination is computed by adding the signed relative-displacement in the second instruction byte to the PC, after incrementing the PC twice to point to the next instruction. The carry flag is not modified. Operation: (PC) ← (PC) + 2 if (C) = 0 then (PC) ← (PC) + rel Bytes: Cycles: 2 3 – C=0 2 – C=1 Encoding: 0 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 0 0 0 relative address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 44 - DR805x Instructions set details 3.20. JNZ Instruction: JNZ rel Function: Jump if accumulator is not zero Description: If any bit of the accumulator is a one, branch to the indicated address; otherwise proceed with the next instruction. The branch destination is computed by adding the signed relative-displacement in the second instruction byte to the PC, after incrementing the PC twice. The accumulator is not modified. No flags are affected. Operation: (PC) ← (PC) + 2 if (A) ≠ 0 then (PC) ← (PC) + rel. Bytes: Cycles: 2 3 Encoding: 0 1 1 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 0 0 0 relative address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 45 - DR805x Instructions set details 3.21. JZ Instruction: JZ rel Function: Jump if accumulator is zero Description: If all bits of the accumulator are zero, branch to the address indicated; otherwise proceed with the next instruction. The branch destination is computed by adding the signed relative-displacement in the second instruction byte to the PC, after incrementing the PC twice. The accumulator is not modified. No flags are affected. Operation: (PC) ← (PC) + 2 if (A) = 0 then (PC) ← (PC) + rel Bytes: Cycles: 2 3 Encoding: 0 1 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 0 0 relative address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 46 - DR805x Instructions set details 3.22. LCALL Instruction: LCALL addr16 Function: Long call Description: LCALL calls a subroutine located at the indicated address. The instruction adds three to the program counter to generate the address of the next instruction and then pushes the 16-bit result onto the stack (low byte first), incrementing the stack pointer by two. The high-order and low-order bytes of the PC are then loaded, respectively, with the second and third bytes of the LCALL instruction. Program execution continues with the instruction at this address. The subroutine may therefore begin anywhere in the full 64 Kbyte program memory address space. No flags are affected. Operation: (PC) ← (PC) + 3 (SP) ← (SP) + 1 ((SP)) ← (PC7-0) (SP) ← (SP) + 1 ((SP)) ← (PC15-8) (PC) ← addr15-0 Bytes: Cycles: 3 6 Encoding: 0 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 0 address 15..8 address 7..0 1 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 47 - DR805x Instructions set details 3.23. LJMP Instruction: LCALL addr16 Function: Long jump Description: LJMP causes an unconditional branch to the indicated address, by loading the high- order and low-order bytes of the PC (respectively) with the second and third instruction bytes. The destination may therefore be anywhere in the full 64K program memory address space. No flags are affected. Operation: (PC) ← addr15... addr0 Bytes: Cycles: 3 4 Encoding: 0 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 address 15..8 address 7..0 1 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 48 - DR805x Instructions set details 3.24. MOV Instruction: MOV <dest-byte>, <src-byte> Function: Move byte variable Description: The byte variable indicated by the second operand is copied into the location specified by the first operand. The source byte is not affected. No other register or flag is affected. This is by far the most flexible operation. Fifteen combinations of source and destination addressing modes are allowed. 3.24.1. MOV A, RN Operation: (PC) ← (PC) + 1 (A) ← (Rn) Bytes: Cycles: 1 1 Encoding: 1 3.24.2. 1 1 0 1 r r r MOV A, DIRECT Operation: (PC) ← (PC) + 2 (A) ← (direct) Note: MOV A, ACC is a valid instruction. Bytes: Cycles: 2 2 Encoding: 1 1 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 1 0 1 direct address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 49 - DR805x Instructions set details 3.24.3. MOV A, @RI Operation: (PC) ← (PC) + 1 (A) ← ((Ri)) Bytes: Cycles: 1 2 Encoding: 1 3.24.4. 1 1 0 0 1 1 i 0 1 0 0 1 r r r 1 r r r MOV A, #DATA Operation: (PC) ← (PC) + 2 (A) ← #data Bytes: Cycles: 2 2 Encoding: 0 3.24.5. 1 1 1 immediate data MOV RN, A Operation: (PC) ← (PC) + 1 (Rn) ← (A) Bytes: Cycles: 1 2 Encoding: 1 3.24.6. 1 1 1 MOV RN, DIRECT Operation: (PC) ← (PC) + 2 (Rn) ← (direct) Bytes: Cycles: 2 4 Encoding: 1 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 direct address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 50 - DR805x Instructions set details 3.24.7. MOV RN, #DATA Operation: (PC) ← (PC) + 2 (Rn) ← #data Bytes: Cycles: 2 2 Encoding: 0 3.24.8. 1 1 1 1 r r r immediate data 0 1 direct address r r direct address MOV DIRECT, A Operation: (PC) ← (PC) + 2 (direct) ← (A) Bytes: Cycles: 2 2 – destination inside SFR 3 – destination inside RAM Encoding: 1 3.24.9. 1 1 1 0 1 MOV DIRECT, RN Operation: (PC) ← (PC) + 2 (direct) ← (Rn) Bytes: Cycles: 2 2 – destination inside SFR 3 – destination inside RAM Encoding: 1 3.24.10. 0 0 0 1 r MOV DIRECT, DIRECT Operation: (PC) ← (PC) + 3 (direct) ← (direct) Bytes: Cycles: 3 3 – destination inside SFR 4 – destination inside RAM Encoding: 1 0 0 0 0 1 0 1 direct address (source) direct address (destination) All trademarks mentioned in this document are trademarks of their respective owners. http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 51 - DR805x Instructions set details 3.24.11. MOV DIRECT, @RI Operation: (PC) ← (PC) + 2 (direct) ← ((Ri)) Bytes: Cycles: 2 3 – direct inside SFR 4 – direct inside RAM Encoding: 1 3.24.12. 0 0 0 0 1 1 i direct address MOV DIRECT, #DATA Operation: (PC) ← (PC) + 2 (direct) ← #data Bytes: Cycles: 3 3 Encoding: 0 3.24.13. 1 1 1 0 1 0 direct address (source) immediate data 1 MOV @RI, A Operation: (PC) ← (PC) + 1 ((Ri)) ← (A) Bytes: Cycles: 1 3 Encoding: 1 3.24.14. 1 1 1 0 1 1 i 0 1 1 i MOV @RI, DIRECT Operation: (PC) ← (PC) + 2 ((Ri)) ← (direct) Bytes: Cycles: 2 4 Encoding: 1 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 direct address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 52 - DR805x Instructions set details 3.24.15. MOV @RI, #DATA Operation: (PC) ← (PC) + 2 ((Ri)) ← #data Bytes: Cycles: 2 3 Encoding: 0 3.24.16. Function: 1 1 1 0 1 1 i immediate data MOV C, BIT Move bit data Description: The Boolean variable indicated by the second operand (directly addressable bit) is copied into carry flag. No other register or flag is affected. Operation: (PC) ← (PC) + 2 (C) ← (bit) Bytes: Cycles: 2 3 Encoding: 1 3.24.17. Function: 0 1 0 0 0 1 0 bit address MOV BIT, C Move carry flag Description: The carry flag is copied into the Boolean variable indicated by the first operand (directly addressable bit). No other register or flag is affected. Operation: (PC) ← (PC) + 2 (bit) ← (C) Bytes: Cycles: 2 4 Encoding: 1 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 0 1 0 bit address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 53 - DR805x Instructions set details 3.24.18. Function: MOV DPTR, #DATA16 Load data pointer with a 16-bit constant Description: The data pointer is loaded with the 16-bit constant indicated. The 16 bit constant is loaded into the second and third bytes of the instruction. The second byte (DPH) is the high-order byte, while the third byte (DPL) holds the low-order byte. No flags are affected. This is the only instruction which moves 16 bits of data at once. Operation: (PC) ← (PC) + 3 DPH ← immediate data15...8 DPL ← immediate data7..0 Bytes: Cycles: 3 3 Encoding: 1 0 0 0 0 1 0 immediate data 15...8 immediate data 7...0 All trademarks mentioned in this document are trademarks of their respective owners. 1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 54 - DR805x Instructions set details 3.25. MOVC Instruction: MOVC A, @A + <base-reg> Function: Move code byte Description: The MOVC instructions load the accumulator with a code byte, or constant from program memory. The address of the byte fetched is the sum of the original unsigned eight-bit accumulator contents and the contents of a sixteen-bit base register, which may be either the data pointer or the PC. In the latter case, the PC is incremented to the address of the following instruction before being added to the accumulator; otherwise the base register is not altered. Sixteen-bit addition is performed so a carry-out from the low-order eight bits may propagate through higher-order bits. No flags are affected. 3.25.1. MOVC A, @A + DPTR Operation: (PC) ← (PC) + 1 (A) ← ((A) + (DPTR)) Bytes: Cycles: 1 4 Encoding: 1 3.25.2. 0 0 1 0 0 1 1 0 1 1 MOVC A, @A + PC Operation: (PC) ← (PC) + 1 (A) ← ((A) + (PC)) Bytes: Cycles: 1 4 Encoding: 1 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 55 - DR805x Instructions set details 3.26. MOVX Instruction: MOVX <dest-byte>, <src-byte> Function: Move external Description: The MOVX instructions transfer data between the accumulator and a byte of external data memory, hence the X appended to MOV. There are two types of instructions, differing in whether they provide an eightbit or sixteen-bit indirect address to the external data RAM. In the first type, the contents of R0 or R1 in the current register bank provide an eight-bit address, in the second type of MOVX instructions, the data pointer generates a sixteen-bit address. Please refer to the section “External Data Memory” of core specification for more information. 3.26.1. MOVX A, @RI Operation: (PC) ← (PC) + 1 (A) ← ((Ri)) Bytes: Cycles: 1 3 Encoding: 1 3.26.2. 1 1 0 0 0 1 i 0 0 0 0 MOVX A, @DPTR Operation: (PC) ← (PC) + 1 (A) ← ((DPTR)) Bytes: Cycles: 1 2 Encoding: 1 1 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 56 - DR805x Instructions set details 3.26.3. MOVX @RI, A Operation: (PC) ← (PC) + 1 ((Ri)) ← (A) Bytes: Cycles: 1 4 Encoding: 1 3.26.4. 1 1 1 0 0 1 i 0 0 0 MOVX @DPTR, A Operation: (PC) ← (PC) + 1 ((DPTR)) ← (A) Bytes: Cycles: 1 3 Encoding: 1 1 1 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 57 - DR805x Instructions set details 3.27. MUL Instruction: MUL AB Function: Multiply Description: MUL AB multiplies the unsigned eight-bit integers in the accumulator and register B. The low-order byte of the sixteen-bit product is left in the accumulator, and the high-order byte in B. If the product is greater than 255 (0FF H) the overflow flag is set; otherwise it is cleared. The carry flag is always cleared. Operation: (PC) ← (PC) + 1 (A) ← (A) x (B) – result’s bits 7..0 (B) ← (A) x (B) – result’s bits 15..8 Bytes: Cycles: 1 4 Encoding: 1 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 1 0 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 58 - DR805x Instructions set details 3.28. NOP Function: No operation Description: Execution continues at the following instruction. Other than the PC, no registers or flags are affected. Operation: (PC) ← (PC) + 1 Bytes: Cycles: 1 1 Encoding: 0 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 0 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 59 - DR805x Instructions set details 3.29. ORL Instruction: ORL <dest-byte>, <src-byte> Function: Logical OR for byte variables Description: ORL performs the bit wise logical OR operation between the indicated variables, storing the results in the destination byte. No flags are affected (except P, if <dest-byte> = A). The two operands allow six addressing mode combinations. When the destination is the accumulator, the source can use register, direct, register-indirect, or immediate addressing; when the destination is a direct address, the source can be the accumulator or immediate data. Note: When this instruction is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins. 3.29.1. ORL A, RN Operation: (PC) ← (PC) + 1 (A) ← (A) or (Rn) Bytes: Cycles: 1 2 Encoding: 0 3.29.2. 1 0 0 1 r r r 1 0 1 ORL A, DIRECT Operation: (PC) ← (PC) + 2 (A) ← (A) or (direct) Bytes: Cycles: 2 3 Encoding: 0 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 direct address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 60 - DR805x Instructions set details 3.29.3. ORL A, @RI Operation: (PC) ← (PC) + 1 (A) ← (A) or ((Ri)) Bytes: Cycles: 1 3 Encoding: 0 3.29.4. 1 0 0 0 1 1 i 1 0 0 immediate data 1 0 direct address 0 0 0 1 direct address Immediate data 1 ORL A, #DATA Operation: (PC) ← (PC) + 1 (A) ← (A) or #data Bytes: Cycles: 2 2 Encoding: 0 3.29.5. 1 0 0 0 ORL DIRECT, A Operation: (PC) ← (PC) + 1 (direct) ← (direct) or (A) Bytes: Cycles: 2 4 Encoding: 0 3.29.6. 1 0 0 0 0 ORL DIRECT, #DATA Operation: (PC) ← (PC) + 1 (direct) ← (direct) or #data Bytes: Cycles: 3 4 Encoding: 0 Instruction: 1 0 ORL C, <src-bit> All trademarks mentioned in this document are trademarks of their respective owners. http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 61 - DR805x Instructions set details Function: Logical OR for bit variables Description: Set the carry flag if the Boolean value is a logic 1; leave the carry in its current state otherwise. A slash (“/”) preceding the operand in the assembly language indicates that the logical complement of the addressed bit is used as the source value, but the source bit itself is not affected. No other flags are affected. 3.29.7. ORL C, BIT Operation: (PC) ← (PC) + 2 (C) ← (C) or (bit) Bytes: Cycles: 2 3 Encoding: 0 3.29.8. 1 1 1 0 0 1 0 0 0 0 0 bit address ORL C, /BIT Operation: (PC) ← (PC) + 2 (C) ← (C) or /(bit) Bytes: Cycles: 2 3 Encoding: 1 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 bit address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 62 - DR805x Instructions set details 3.30. POP Instruction: POP direct Function: Pop from stack Description: The contents of the internal RAM location addressed by the stack pointer are read, and the stack pointer is decremented by one. The value read is the transfer to the directly addressed byte indicated. No flags are affected. Operation: (PC) ← (PC) + 2 (direct) ← ((SP)) (SP) ← (SP) - 1 Bytes: Cycles: 2 2 – direct inside SFR 3 – direct inside RAM Encoding: 1 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 0 0 0 direct address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 63 - DR805x Instructions set details 3.31. PUSH Instruction: PUSH direct Function: Push onto stack Description: The stack pointer is incremented by one. The contents of the indicated variable are then copied into the internal RAM location addressed by the stack pointer. Otherwise no flags are affected. Operation: (PC) ← (PC) + 2 (SP) ← (SP) + 1 ((SP)) ← (direct) Bytes: Cycles: 2 4 Encoding: 1 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 0 0 direct address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 64 - DR805x Instructions set details 3.32. RET Function: Return from subroutine Description: RET pops the high and low-order bytes of the PC successively from the stack, decrementing the stack pointer by two. Program execution continues at the resulting address, generally the instruction immediately following an ACALL or LCALL. No flags are affected. Operation: (PC15-8) (SP) (PC7-0) (SP) Bytes: Cycles: 1 4 ← ((SP)) ← (SP) - 1 ← ((SP)) ← (SP) - 1 Encoding: 0 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 1 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 65 - DR805x Instructions set details 3.33. RETI Function: Return from interrupt Description: RETI pops the high and low-order bytes of the PC successively from the stack, and restores the interrupt logic to accept additional interrupts at the same priority level as the one just processed. The stack pointer is left decremented by two. No other registers are affected; the PSW is not automatically restored to its pre-interrupt status. Program execution continues at the resulting address, which is generally the instruction immediately after the point at which the interrupt request was detected. If a lower or same-level interrupt is pending when the RETI instruction is executed, that one instruction will be executed before the pending interrupt is processed. Operation: (PC15-8) (SP) (PC7-0) (SP) Bytes: Cycles: 1 4 ← ((SP)) ← (SP) - 1 ← ((SP)) ← (SP) - 1 Encoding: 0 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 0 1 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 66 - DR805x Instructions set details 3.34. RL Instruction: RL A Function: Rotate accumulator left Description: The eight bits in the accumulator are rotated one bit to the left. Bit 7 is rotated into the bit 0 position. No flags are affected. Operation: (PC) ← (PC) + 1 (An + 1) ← (An) n = 0-6 (A0) ← (A7) Bytes: Cycles: 1 1 Encoding: 0 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 1 1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 67 - DR805x Instructions set details 3.35. RLC Instruction: RLC A Function: Rotate accumulator left through carry flag Description: The eight bits in the accumulator and the carry flag are together rotated one bit to the left. Bit 7 moves into the carry flag; the original state of the carry flag moves into the bit 0 position. No other flags are affected. Operation: (PC) (An + 1) (A0) (C) Bytes: Cycles: 1 1 ← (PC) + 1 ← (An) n = 0-6 ← (C) ← (A7) Encoding: 0 0 1 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 0 1 1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 68 - DR805x Instructions set details 3.36. RR Instruction: RR A Function: Rotate accumulator right Description: The eight bits in the accumulator are rotated one bit to the right. Bit 0 is rotated into the bit 7 position. No flags are affected. Operation: (PC) ← (PC) + 1 (An) ← (An + 1) n = 0-6 (A7) ← (A0) Bytes: Cycles: 1 1 Encoding: 0 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 1 1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 69 - DR805x Instructions set details 3.37. RRC Instruction: RRC A Function: Rotate accumulator right through carry flag Description: The eight bits in the accumulator and the carry flag are together rotated one bit to the right. Bit 0 moves into the carry flag; the original value of the carry flag moves into the bit 7 position. No other flags are affected. Operation: (PC) (An) (A7) (C) Bytes: Cycles: 1 1 ← (PC) + 1 ← (An + 1) n=0-6 ← (C) ← (A0) Encoding: 0 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 0 1 1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 70 - DR805x Instructions set details 3.38. SETB Instruction: SETB <bit> Function: Set bit Description: SETB sets the indicated bit to one. SETB can operate on the carry flag or any directly addressable bit. No other flags are affected. 3.38.1. SETB C Operation: (PC) ← (PC) + 1 (C) ← 1 Bytes: Cycles: 1 1 Encoding: 1 3.38.2. 1 0 1 0 0 1 1 0 0 1 0 SETB BIT Operation: (PC) ← (PC) + 2 (bit) ← 1 Bytes: Cycles: 2 4 Encoding: 1 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 bit address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 71 - DR805x Instructions set details 3.39. SJMP Instruction: SJMP rel Function: Short jump Description: Program control branches unconditionally to the address indicated. The branch destination is computed by adding the signed displacement in the second instruction byte to the PC, after incrementing the PC twice. Therefore, the range of destinations allowed is from 128 bytes preceding this instruction to 127 bytes following it. Note: Under the above conditions the instruction following SJMP will be at 102 H. Therefore, the displacement byte of the instruction will be the relative offset (0123 H - 0102 H ) = 21 H . In other words, an SJMP with a displacement of 0FE H would be a one-instruction infinite loop. Operation: (PC) ← (PC) + 2 (PC) ← (PC) + rel Bytes: Cycles: 2 3 Encoding: 1 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 0 0 relative address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 72 - DR805x Instructions set details 3.40. SUBB Instruction: SUBB A, <src-byte> Function: Subtract with borrow Description: SUBB subtracts the indicated variable and the carry flag together from the accumulator, leaving the result in the accumulator. SUBB sets the carry (borrow) flag if a borrow is needed for bit 7, and clears C otherwise. (If C was set before executing a SUBB instruction, this indicates that a borrow was needed for the previous step in a multiple precision subtraction, so the carry is subtracted from the accumulator along with the source operand). AC is set if a borrow is needed for bit 3, and cleared otherwise. OV is set if a borrow is needed into bit 6 but not into bit 7, or into bit 7 but not bit 6. When subtracting signed integers OV indicates a negative number produced when a negative value is subtracted from a positive value, or a positive result when a positive number is subtracted from a negative number. The source operand allows four addressing modes: register, direct, register-indirect, or immediate. 3.40.1. SUBB A, RN Operation: (PC) ← (PC) + 1 (A) ← (A) - (C) - (Rn) Bytes: Cycles: 1 2 Encoding: 1 3.40.2. 0 0 1 1 r r r 0 1 SUBB A, DIRECT Operation: (PC) ← (PC) + 2 (A) ← (A) - (C) - (direct) Bytes: Cycles: 2 3 Encoding: 1 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 1 direct address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 73 - DR805x Instructions set details 3.40.3. SUBB A, @RI Operation: (PC) ← (PC) + 1 (A) ← (A) - (C) - ((Ri)) Bytes: Cycles: 1 3 Encoding: 1 3.40.4. 0 0 1 0 1 1 i 1 0 0 SUBB A, #DATA Operation: (PC) ← (PC) + 2 (A) ← (A) - (C) - #data Bytes: Cycles: 2 2 Encoding: 1 0 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 immediate data http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 74 - DR805x Instructions set details 3.41. SWAP Instruction: SWAP A Function: Swap nibbles within the accumulator Description: SWAP A interchanges the low and high-order nibbles (four-bit fields) of the accumulator (bits 3-0 and bits 7-4). The operation can also be thought of as a four-bit rotate instruction. No flags are affected. Operation: (PC) ← (PC) + 1 (A3-0) ↔ (A7-4), (A7-4) ↔ (A3-0) Bytes: Cycles: 1 1 Encoding: 1 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 1 0 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 75 - DR805x Instructions set details 3.42. XCH Instruction: XCH A, <byte> Function: Exchange accumulator with byte variable Description: XCH loads the accumulator with the contents of the indicated variable, at the same time writing the original accumulator contents to the indicated variable. The source/destination operand can use register, direct, or register-indirect addressing. 3.42.1. XCH A, RN Operation: (PC) ← (PC) + 1 (A) ↔ (Rn) Bytes: Cycles: 1 2 Encoding: 1 3.42.2. 1 0 0 1 r r r 0 1 0 1 0 1 1 i XCH A, DIRECT Operation: (PC) ← (PC) + 2 (A) ↔ (direct) Bytes: Cycles: 2 3 Encoding: 1 3.42.3. 1 0 0 direct address XCH A, @RI Operation: (PC) ← (PC) + 1 (A) ↔ ((Ri)) Bytes: Cycles: 1 3 Encoding: 1 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 0 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 76 - DR805x Instructions set details 3.43. XCHD Instruction: XCHD A, @Ri Function: Exchange digit Description: XCHD exchanges the low-order nibble of the accumulator (bits 3-0, generally representing a hexadecimal or BCD digit), with that of the internal RAM location indirectly addressed by the specified register. The high-order nibbles (bits 7-4) of each register are not affected. No flags are affected. Operation: (PC) ← (PC) + 1 (A3-0) ↔ ((Ri)3-0) Bytes: Cycles: 1 3 Encoding: 1 1 0 All trademarks mentioned in this document are trademarks of their respective owners. 1 0 1 1 i http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 77 - DR805x Instructions set details 3.44. XRL Instruction: XRL <dest-byte>, <src-byte> Function: Logical Exclusive OR for byte variables Description: XRL performs the bit wise logical Exclusive OR operation between the indicated variables, storing the results in the destination. No flags are affected (except P, if <dest-byte> = A). The two operands allow six addressing mode combinations. When the destination is the accumulator, the source can use register, direct, register-indirect, or immediate addressing; when the destination is a direct address, the source can be accumulator or immediate data. Note: When this instruction is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins. 3.44.1. XRL A, RN Operation: (PC) ← (PC) + 1 (A) ← (A) xor (Rn) Bytes: Cycles: 1 2 Encoding: 0 3.44.2. 1 1 0 1 r r r 1 0 1 XRL A, DIRECT Operation: (PC) ← (PC) + 2 (A) ← (A) xor (direct) Bytes: Cycles: 2 3 Encoding: 0 1 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 direct address http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. - 78 - DR805x Instructions set details 3.44.3. XRL A, @ RI Operation: (PC) ← (PC) + 1 (A) ← (A) xor ((Ri)) Bytes: Cycles: 1 3 Encoding: 0 3.44.4. 1 1 0 0 1 1 i 1 0 0 immediate data 1 0 direct address XRL A, #DATA Operation: (PC) ← (PC) + 2 (A) ← (A) xor #data Bytes: Cycles: 2 2 Encoding: 0 3.44.5. 1 1 0 0 XRL DIRECT, A Operation: (PC) ← (PC) + 2 (direct) ← (direct) xor (A) Bytes: Cycles: 2 4 Encoding: 0 3.44.6. 1 1 0 0 0 XRL DIRECT, #DATA Operation: (PC) (direct) Bytes: Cycles: 3 4 ← (PC) + 3 ← (direct) xor #data Encoding: 0 1 1 All trademarks mentioned in this document are trademarks of their respective owners. 0 0 0 1 direct address immediate data 1 http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved. DR805x Instructions set details - 79 - 4. CONTACTS If any problems are encountered please contact Digital Core Design. Headquarters: Wroclawska 94 41-902 Bytom POLAND e-mail: iinnffoo@ @ddccdd..ppll tel. : +48 32 282 82 66 fax : +48 32 282 74 37 Field Office: Texas Research Park 14815 Omicron Dr. suite 100 San Antonio, TX 78245,USA e-mail: iinnffooU USS@ @ddccdd..ppll tel. : +1 210 422 8268 fax : +1 210 679 7511 Distributors: Please check hhttttpp::////w ww ww w..ddccdd..ppll//aappaarrttnn..pphhpp All trademarks mentioned in this document are trademarks of their respective owners. http://www.DigitalCoreDesign.com http://www.dcd.pl Copyright 1999-2003 DCD – Digital Core Design. All Rights Reserved.