PIC18 Serisi Komut Seti
Posted on 2015-05-05 by Burak Hamdi TUFAN
Electronic 
Bu yazıda sizlere PIC18 setinin komut serisini paylaşacağım. Açıklamalarıda yanında mevcut durumdadır...
PIC18 Byte-Oriented Register Operations (Bayt yönlendirmeli kütük işlemleri) | |||||||
Hex | Mnemonic | Türkçe Açıklama | Description | Function | |||
27f* | ADDWF | f,d,a | W ile f ’yi topla | ADD WREG to f | WREG+f → dest | ||
23f* | ADDWFC | f,d,a | W ile f ' yi topla Carry bitini f ' ye ekle | ADD WREG and Carry bit to f | WREG+f+C → dest | ||
17f* | ANDWF | f,d,a | W ile f ’yi VE işlemine tabi tut. | AND WREG with f | WREG .AND. f → dest | ||
6Bf* | CLRF | f,a | f ’yi sıfırla. | Clear f | 0 → f | ||
1Ff* | COMF | f,d,a | f ’in tersini al | Complement f | .NOT. f → dest | ||
63f* | CPFSEQ | f,a | Compare f with WREG, skip if f=WREG | f-WREG, if f=WREG, PC+4 → PC | |||
WREG ile f ' yi karşılaştır.Eşitse alttaki komuta atla | else PC+2 → PC | ||||||
65f* | CPFSGT | f,a | Compare f with WREG, skip if f > WREG | f-WREG, if f > WREG, PC+4 → PC | |||
WREG ile f ' yi karşılaştır.WREG küçükse alttaki komuta atla | else PC+2 → PC | ||||||
07f* | DECF | f,d,a | f ’teki sayıyı bir azalt. | Decrement f | f-1 → dest | ||
2Ff* | DECFSZ | f,d,a | f’teki sayıyı bir azalt, | Decrement f, skip if 0 | f-1 → dest, if dest=0, PC+4 → PC | ||
sonuç 0’sa altındaki komutu atla. | else PC+2 → PC | ||||||
4Ff* | DCFSNZ | f,d,a | f’teki sayıyı bir azalt, | Decrement f, skip if not 0 | f-1 → dest, if dest ¼ 0, PC+4 → PC | ||
sonuç 0’dan farklı ise altındaki komutu atla. | else PC+2 → PC | ||||||
2Bf* | INCF | f,d,a | f’teki sayıyı bir arttır. | Increment f | f+1 → dest | ||
3Ff* | INCFSZ | f,d,a | f’teki sayıyı bir arttırır, | Increment f, skip if 0 | f+1 → dest, if dest=0, PC+4 → PC | ||
sonuç 0’sa altındaki komutu atla. | else PC+2 → PC | ||||||
4Bf* | INFSNZ | f,d,a | f’teki sayıyı bir arttırır, | Increment f, skip if not 0 | f+1 → dest, if dest ¼ 0, PC+4 → PC | ||
sonuç 0’değilse altındaki komutu atla. | else PC+2 → PC | ||||||
13f* | IORWF | f,d,a | W ile f’i VEYA işlemine tabi tut. | Inclusive OR WREG with f | WREG .OR. f → dest | ||
53f* | MOVF | f,d,a | f’teki sayıyı hedefe taşı. | Move f | f → dest | ||
Cf' | MOVFF | f',f" | Move f' to fd" (second word) | f' → f" | |||
Ff" | f’teki sayıyı ikinci word e taşı | ||||||
6Ff* | MOVWF | f,a | W’deki sayıyı f’te hedefe taşı. | Move WREG to f | WREG → f | ||
03f* | MULWF | f,a | f 'deki sayıyı WREG ile çarp | Multiply WREG with f | Bitmap Bitmap Bitmap Bitmap
|
||
6Df* | NEGF | f,a | f 'yi negatif yap | Negate f | -f → f | ||
37f* | RLCF | f,d,a | f’teki 8 biti başa Status, | Rotate left f through Carry | |||
0 bitini ekleyerek sola kaydır, | |||||||
dokuzuncu bitteki değeri sıfırıncı bite ata. | |||||||
47f* | RLNCF | f,d,a | f’teki 8 biti başa Status, | Rotate left f (no carry) | |||
0 bitini ekleyerek sola kaydır, | |||||||
33f* | RRCF | f,d,a | f’teki 8 biti başa Status, | Rotate right f through Carry | |||
0 bitini ekleyerek sağa kaydır, | |||||||
dokuzuncu bitteki değeri sıfırıncı bite ata. | |||||||
43f* | RRNCF | f,d,a | f’teki 8 biti başa Status, | Rotate right f (no carry) | |||
0 bitini ekleyerek sağa kaydır, | |||||||
69f* | SETF | f,a | f 'yi 1 yap | Set f | 0xFF → f | ||
57f* | SUBFWB | f,d,a | Carry kullanarak WREG den f 'yi çıkart | Subtract f from WREG with Borrow | WREG-f-C → dest | ||
5Ff* | SUBWF | f,d,a | W’deki sayıyı f’teki sayıdan çıkart. | Subtract WREG from f | f-WREG → dest | ||
5Bf* | SUBWFB | f,d,a | W’deki sayıyı f’teki sayıdan çıkart.Carry'yi değiştir. | Subtract WREG from f with Borrow | f-WREG-C → dest | ||
3Bf* | SWAPF | f,d,a | İlk dört bitle son dört bitin yerlerini değiştir. | Swap nibbles of f | f(3:0) → dest(7:4), f(7:4) → dest(3:0) | ||
67f* | TSTFSZ | f,a | f 'yi test et 0 ise sonraki komuta atla | Test f, skip if 0 | PC+4 → PC, if f=0, else PC+2 → PC | ||
1Bf* | XORWF | f,d,a | W ile f’i XOR işlemine tabi tut. | Exclusive OR WREG with f | WREG .XOR. f → dest | ||
* Assuming default bit values for d and a. | |||||||
PIC18 Bit-Oriented Register Operations (Bit yönlendirmeli Kütük işlemleri) | |||||||
Hex | Mnemonic | Türkçe Açıklama | Description | Function | |||
91f* | BCF | f,b,a | f’teki bir biti sıfırla. | Bit Clear f | 0 → f(b) | ||
81f* | BSF | f,b,a | f’teki bir biti set et. | Bit Set f | 1 → f(b) | ||
B1f* | BTFSC | f,b,a | f’teki sayı 0’sa altındaki komutu atla | Bit test f, skip if clear | if f(b)=0, PC+4→PC, else PC+2→PC | ||
A1f* | BTFSS | f,b,a | f’teki sayı 1’se altındaki komutu atla. | Bit test f, skip if set | if f(b)=1, PC+4→PC, else PC+2→PC | ||
71f* | BTG | f,b,a | f deki biti tersle | Bit Toggle f | f(b) → f(b) | ||
* Assuming b = 0 and default bit value for a. | |||||||
PIC18 Control Operations (Kontrol işlemleri) | |||||||
Hex | Mnemonic | Türkçe Açıklama | Description | Function | |||
E2n | BC | n | Elde (Carry) varsa n adresine gidilir. | Branch if Carry | if C=1, PC+2+2*n→ PC, else PC+2→PC | ||
E6n | BN | n | Sayı negatif ise n adresine gider | Branch if Negative | if N=1, PC+2+2*n→PC,else PC+2→PC | ||
E3n | BNC | n | Elde (Carry) yoksa n adresine gidilir. | Branch if Not Carry | if C=0, PC+2+2*n→PC, else PC+2→PC | ||
E7n | BNN | n | Sayı Negatif değilse n adresine gider | Branch if Not Negative | if N=0, PC+2+2*n→PC, else PC+2→PC | ||
E5n | BNOV | n | Taşma yoksa n adresine gidilir. | Branch if Not Overflow | if OV=0, PC+2+2*n→PC, else PC+2→PC | ||
E1n | BNZ | n | Z=0 ise n adresine gidilir. | Branch if Not Zero | if Z=0, PC+2+2*n→PC, else PC+2→PC | ||
E4n | BOV | n | Taşma varsa n adresine gidilir. | Branch if Overflow | if OV=1, PC+2+2*n→PC, else PC+2→PC | ||
D'0'n | BRA | n | n adresine gidilir. | Branch Unconditionally | PC+2+2*n→ PC | ||
E0n | BZ | n | Z=1 ise n adresine gidilir. | Branch if Zero | if Z=1, PC+2+2*n→PC, else PC+2→PC | ||
ECkk* | CALL | n,s | Call Subroutine 1st word | PC+4 → TOS, n → PC(20:1), | |||
Fkkk | 2nd word | if s=1, WREG → WREGs, | |||||
Alt programı çağır | STATUS → STATUSs, BSR → BSRs | ||||||
0004 | CLRWDT | Clear Watchdog Timer | 0 → WDT, 0 → WDT postscaler, | ||||
WDT’deki değeri sıfırla. | 1 → TO,1 → PD | ||||||
0007 | DAW | Decimal Adjust WREG | if WREG(3:0) >9 or DC=1, WREG(3:0)+6→WREG(3:0), | ||||
else WREG(3:0) → WREG(3:0); | |||||||
if WREG(7:4) >9 or C=1, WREG(7:4)+6→WREG(7:4), | |||||||
WREG i desimal düzelt | else WREG(7:4) → WREG(7:4); | ||||||
EFkk | GOTO | n | Programda istenilen yere atla. | Go to address 1st word | n → PC(20:1) | ||
Fkkk | 2nd word | ||||||
0000 | NOP | işlem yapma | No Operation | No Operation | |||
Fxxx | NOP | işlem yapma 2word | No Operation | No Operation (2-word instructions) | |||
0006 | POP | Yığına AT | Pop top of return stack (TOS) | TOS-1 → TOS | |||
0005 | PUSH | Yığından AL | Push top of return stack (TOS) | PC +2→ TOS | |||
D'1'n | RCALL | n | n kadar ilerdeki komutu Göreli Çağır. | Relative Call | PC+2 → TOS, PC+2+2*n→PC | ||
00FF | RESET | Yazılımla RESET | Software device reset | Same as MCLR reset | |||
0010* | RETFIE | s | Return from interrupt | TOS → PC, 1 → GIE/GIEH or PEIE/GIEL, | |||
(and enable interrupts) | if s=1, WREGs → WREG, STATUSs → STATUS, | ||||||
Kesme sonunda yapılan işlemden normal programa dön. | BSRs → BSR, PCLATU/PCLATH unchngd. | ||||||
0012* | RETURN | s | Return from subroutine | TOS → PC, if s=1, WREGs → WREG, | |||
STATUSs → STATUS, BSRs → BSR, | |||||||
Call’la çağırılan alt programın sonu. | PCLATU/PCLATH are unchanged | ||||||
0003 | SLEEP | Enter SLEEP Mode | 0 → WDT, 0 → WDT postscaler, | ||||
Uyku moduna geç. | 1 → TO, 0 → PD | ||||||
* Assuming default bit value for s. | |||||||
PIC18 Literal Operations (Sade yalın işlemler) | |||||||
Hex | Mnemonic | Türkçe Açıklama | Description | Function | |||
0Fkk | ADDLW | kk | Verilen sabit sayıyı W’deki sayıya ekle. | Add literal to WREG | WREG+kk → WREG | ||
0Bkk | ANDLW | kk | Verilen sabit sayıyla W’deki sayıyı VE işl. tab tu | AND literal with WREG | WREG .AND. kk → WREG | ||
09kk | IORLW | kk | Verilen sabit sayıyla W’deki sayıyı VEYA işlemine tabi tut. | Inclusive OR literal with WREG | WREG .OR. kk → WREG | ||
EErk | LFSR | r,kk | Move literal (12 bit) 2nd word | kk → FSRr | |||
F0kk | 1.Word değeri 2.Word e kopyele | to FSRr 1st word | |||||
010k | MOVLB | k | k Bank Seçme Registerine yazılır | Move literal to BSR(3:0) | kk → BSR | ||
0Ekk | MOVLW | kk | Verilen sabit sayıyı W’nin içine ata. | Move literal to WREG | kk → WREG | ||
0Dkk | MULLW | kk | WREG i kk ile Çarp | Multiply literal with WREG | WREG * kk→ PRODH:PRODL | ||
0Ckk | RETLW | kk | Tablolama sırasında sayı değerini W’ye ata | Return with literal in WREG | kk → WREG | ||
08kk | SUBLW | kk | W’deki sayıyı verilen sabit sayıdan çıkart. | Subtract WREG from literal | kk-WREG → WREG | ||
0Akk | XORLW | kk | Verilen sabit sayıyla W’deki sayıyı ÖZELVEYA işlemine tabi tut | Exclusive OR literal with WREG | WREG .XOR. kk → WREG | ||
PIC18 Memory Operations | |||||||
Hex | Mnemonic | Description | Türkçe Açıklama | Function | |||
0008 | TBLRD* | Table Read | Prog Mem (TBLPTR) → TABLAT | ||||
0009 | TBLRD*+ | Table Read with post-increment | Prog Mem (TBLPTR) → TABLAT | ||||
TBLPTR +1 → TBLPTR | |||||||
000A | TBLRD*- | Table Read with post-decrement | Prog Mem (TBLPTR) → TABLAT | ||||
TBLPTR -1 → TBLPTR | |||||||
000B | TBLRD+* | Table Read with pre-increment | TBLPTR +1 → TBLPTR | ||||
Prog Mem (TBLPTR) → TABLAT | |||||||
000C | TBLWT* | Table Write | TABLAT → Prog Mem(TBLPTR) | ||||
000D | TBLWT*+ | Table Write with post-increment | TABLAT → Prog Mem(TBLPTR) | ||||
TBLPTR +1 → TBLPTR | |||||||
000E | TBLWT*- | Table Write with post-decrement | TABLAT → Prog Mem(TBLPTR) | ||||
TBLPTR -1 → TBLPTR | |||||||
000F | TBLWT+* | Table Write with pre-increment | TBLPTR +1 → TBLPTR | ||||
TABLAT → Prog Mem(TBLPTR) | |||||||
|
|||||||
PIC18 Extended Instructions | |||||||
Hex | Mnemonic | Türkçe Açıklama | Description | Function | |||
E8fk | ADDFSR | f,k | Add literal to FSR | FSR(f)+k → FSR(f) | |||
E8Ck | ADDULNK | k | Add literal to FSR2 and return | FSR2+k → FSR2, (TOS) → PC | |||
14 | CALLW | Call subroutine using WREG | (PC + 2) → TOS, (W) → PCL, | ||||
(PCLATH) → PCH, (PCLATU) → PCU | |||||||
EB'0'z | MOVSF | z',f" | Move z' (source) to 1st word, | ((FSR2)+z') → f" | |||
Ffff | f" (destination)2nd word | ||||||
EB'1'z | MOVSS | z',z" | Move z' (source) to 1st word, | ((FSR2)+z') → ((FSR2)+z") | |||
Fxzz | z" (destination)2nd word | ||||||
EAkk | PUSHL | k | Store literal at FSR2, | k → (FSR2), | |||
decrement FSR2 | FSR2-1 → FSR2 | ||||||
E9fk | SUBFSR | f,k | Subtract literal from FSR | FSR(f-k) → FSR(f) | |||
E9Ck | SUBULNK | k | Subtract literal from FSR2 and return | FSR2-k → FSR2, (TOS) → PC | |||
RAM access bit | |||||||
a = 0: RAM location in Access RAM (BSR register is ignored) | |||||||
a = 1: RAM bank is specified by BSR register (default) | |||||||
b = Bit address within an 8-bit file register (0 to 7). | |||||||
Destination select bit | |||||||
d = 0: store result in WREG | |||||||
d = 1: store result in file register f (default) | |||||||
Fast Call/Return mode select bit | |||||||
s = 0: do not update into/from shadow registers (default) | |||||||
s = 1: certain registers loaded into/from shadow registers (Fast mode) | |||||||
Literal field, constant data or label. | |||||||
k 4-bit. | |||||||
kk 8-bit. | |||||||
kkk 12-bit. | |||||||
n = The relative address (2's complement number) for relative branch instructions, or the direct address for Call/Branch and Return instructions. | |||||||
Indirect addressing offset. | |||||||
z' 7-bit offset value for indirect addressing of register files (source). | |||||||
z" 7-bit offset value for indirect addressing of register files (destination). | |||||||
r = 0, 1 or 2 for FSR number. | |||||||
Register file address. | |||||||
f 8-bit (0x00 to 0xFF). | |||||||
f' 12-bit (0x000 to 0xFFF). This is the source address. | |||||||
f" 12-bit (0x000 to 0xFFF). This is the destination address. | |||||||