# Standard Instruction Set 1. Standard Instruction Set ![](https://i.imgur.com/BBlno4X.png) 在pic18中,instruction set 是由一個single-word,也就是16個bits所組成,其中包含了opcode及一些operand,而opcode會依據指令的不同,而長度有所不同,未必都是4個bits。 而這些instruction set 大致可分為4種類型 : * Byte-oriented operations * Bit-oriented operations * Literal operations * Control operations ** 這邊若想知道各類別中有那些指令,使用了那些OPCODE,可以上datasheet去做查詢 另外,在這邊要特別介紹ㄧ個特別的register,叫做**Status Register**,他是用來紀錄register的狀態的,有8個bits前3個bits沒用到,而後面4個bits分別為 *Negative , Overflow , Zero, Digit Carry , Carry bit。* ![](https://i.imgur.com/nY8MZmA.png) 2. Logical instructions 再來介紹的是Logical instructions,像是**ANDLW、IORLW、XORLW**,都是將ㄧ個Literal與WREG去做AND,OR...等運算,當然也有指令像是**ANDWF**是可以將WREG與File register去做AND運算,若將d設為0,則可將結果存回WREG,若設為1,則可將結果放回" f " (預設)。 ![](https://i.imgur.com/Nkz1xoW.png) 還有ㄧ些bitwise的指令,像是用來設定file register中某個bit為0的**BCF**指令,反之也有將某個bit設為1的**BSF**指令,以及ㄧ些用來Rotate的指令,如**RRNCF , RLNCF , RRCF** ... 3. Control operation Branch指令是用來控制程式要跳到哪個位址做執行的指令,像是unconditional branch的**GOTO**指令,可以根據給的label,來讓程式跳到你要的地方執行。也有像是conditional branch指令,如**BC**會根據carry bit的值決定要不要跳。 ![](https://i.imgur.com/ljFOI97.png)