23
Mikroprotsessorid PIC16F876A KÄSUD

Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Embed Size (px)

Citation preview

Page 1: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Mikroprotsessorid

PIC16F876A KÄSUD

Page 2: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Instruction decode – mis teha tuleb

Loe mälust

Töötle andmeid

Kirjuta mällu

Page 3: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

1FFFh + 1 = 0000h

Käske täidetakse järjest. Peale igat käsku tehakse PC = PC + 1

Erandid: GOTO ja CALL

Page 4: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> f     Z  00 1010 dfff ffffDecrement f f-1 --> f     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode          00 0000 0110 0011

Page 5: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE 11-bitine aadress kkkkkkkkkkk

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE 8-bitine Literal kkkkkkkk

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE 3-bitinebiti aadress

bbb

7-bitine registri aadressfffffff

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE d=0: dest=Wd=1: dest=f

7-bitine registri aadressfffffff

PIC16F876A käskude struktuur Address modes

Käsud registriga

Käsud bitiga

Käsud konstandiga

Absoluutne suunamine

Käsud operandita

Page 6: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> d     Z  00 1010 dfff ffffDecrement f f-1 --> d     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode          00 0000 0110 0011

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE d=0: dest=Wd=1: dest=f

7-bitine registri aadressfffffff

f tähendab mõnda registrit sellest tabelist

W tähendab Work registrit

Kui dest=W, siis

1. võetakse registri f väärtus,

2. Tehakse sellega midagi

3. Tulemus pannakse W-sse

4. Register f ise ei muutu

Kui dest=f, siis

1. võetakse registri f väärtus,

2. Tehakse sellega midagi

3. Tulemus pannakse f-sse tagasi

4. Register W ei muutu

7 6 5 4 3 2 1 0

x3h STATUS IRP RP1 RP0 _TO _PD Z DC C

Mälupanga number tuleb registrist STATUS

Page 7: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> d     Z  00 1010 dfff ffffDecrement f f-1 --> d     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode          00 0000 0110 0011

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE d=0: dest=Wd=1: dest=f

7-bitine registri aadressfffffff

Move

LiidaLahuta

Loogika

Rotate

LiidaLahuta+Tingimuslik suunamine

Page 8: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> d     Z  00 1010 dfff ffffDecrement f f-1 --> d     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode          00 0000 0110 0011

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE 3-bitinebiti aadress

bbb

7-bitine registri aadressfffffff

Biti seadmine

Tingimuslik suunamine

f tähendab mõnda registrit sellest tabelist

bbb tähendab biti numbrit (0...7)

Page 9: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> d     Z  00 1010 dfff ffffDecrement f f-1 --> d     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode          00 0000 0110 0011

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE 8-bitine Literal kkkkkkkk

NB! Kõik Literali käsud on ainult registriga W

Move

LiidaLahuta

Loogika

Return

Page 10: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> d     Z  00 1010 dfff ffffDecrement f f-1 --> d     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode          00 0000 0110 0011

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE 11-bitine aadress kkkkkkkkkkk

7 6 5 4 3 2 1 0

xAh PCLATH A12 A11

Go

Aadressi vanemad 2 bitti tulevad registrist PCLATH

12 11 10 9 8 7 6 5 4 3 2 1 0

Page 11: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> d     Z  00 1010 dfff ffffDecrement f f-1 --> d     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode Sleep         00 0000 0110 0011

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE

Page 12: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE 11-bitine aadress kkkkkkkkkkk

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE 8-bitine Literal kkkkkkkk

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE 3-bitinebiti aadress

bbb

7-bitine registri aadressfffffff

13 12 11 10 9 8 7 6 5 4 3 2 1 0

OPCODE d=0: dest=Wd=1: dest=f

7-bitine registri aadressfffffff

PIC16F876A käskude struktuur Address modes

Käsud registriga

Käsud bitiga

Käsud konstandiga

Absoluutne suunamine

Käsud operandita

Page 13: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Port B

Register = 0x55

Kirjuta Register Porti B

Inverteeri Register

Näide: Genereeri PortB abil impulsse

Page 14: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> f     Z  00 1010 dfff ffffDecrement f f-1 --> f     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode          00 0000 0110 0011

Register = 0x55

Kirjuta Register Porti B

Inverteeri Register

Page 15: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> f     Z  00 1010 dfff ffffDecrement f f-1 --> f     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode          00 0000 0110 0011

Aadress Bin Hex

0x55 -> W: 11 0000 0101 0101 30 550000

Move Literal to W k->W 11 00xx kkkk kkkk

Register = 0x55

Kirjuta Register Porti B

Inverteeri Register

Page 16: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> f     Z  00 1010 dfff ffffDecrement f f-1 --> f     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode          00 0000 0110 0011

Aadress Bin Hex0x55 -> W: 11 0000 0101 0101 30 550000

Move W to f W->f 00 0000 1fff ffff

W -> 20h: 00 0000 1010 0000 00 A00001

Register = 0x55

Kirjuta Register Porti B

Inverteeri Register

Page 17: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> f     Z  00 1010 dfff ffffDecrement f f-1 --> f     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode          00 0000 0110 0011

Aadress Bin Hex0x55 -> W: 11 0000 0101 0101 30 550000

Move W to f W->f 00 0000 1fff ffff

W -> 20h: 00 0000 1010 0000 00 A00001

W -> PORTB: 00 0000 1000 0110 00 860002

Register = 0x55

Kirjuta Register Porti B

Inverteeri Register

Page 18: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> f     Z  00 1010 dfff ffffDecrement f f-1 --> f     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode          00 0000 0110 0011

Aadress Bin Hex0x55 -> W: 11 0000 0101 0101 30 550000

W -> 20h: 00 0000 1010 0000 00 A00001

W -> PORTB: 00 0000 1000 0110 00 860002

Invert 20h: 00 1001 1010 0000

09 A00003

Complement f 00 1001 dfff ffff

Register = 0x55

Kirjuta Register Porti B

Inverteeri Register

d=0: dest=Wd=1: dest=f

Page 19: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> f     Z  00 1010 dfff ffffDecrement f f-1 --> f     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode          00 0000 0110 0011

Aadress Bin Hex0x55 -> W: 11 0000 0101 0101 30 550000

W -> 20h: 00 0000 1010 0000 00 A00001

W -> PORTB: 00 0000 1000 0110 00 860002

Invert 20h: 00 1001 1010 0000

09 A00003

Move f to d 00 1000 dfff ffff

20h -> W: 00 1000 0010 0000

08 200004

Register = 0x55

Kirjuta Register Porti B

Inverteeri Register

d=0: dest=Wd=1: dest=f

Page 20: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> f     Z  00 1010 dfff ffffDecrement f f-1 --> f     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode          00 0000 0110 0011

Aadress Bin Hex0x55 -> W: 11 0000 0101 0101 30 550000

W -> 20h: 00 0000 1010 0000 00 A00001

W -> PORTB: 00 0000 1000 0110 00 860002

Invert 20h: 00 1001 1010 0000

09 A00003

Go to address 10 1kkk kkkk kkkk

20h -> W: 00 1000 0010 0000

08 200004

Go to 0002: 10 1000 0000 0010 28 020005

Register = 0x55

Kirjuta Register Porti B

Inverteeri Register

Page 21: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

Move Literal to W k --> W        11 00xx kkkk kkkkMove W to f W --> f     Z  00 0000 1fff ffffMove f to d f --> d     Z  00 1000 dfff ffffClear W 0 --> W     Z  00 0001 0xxx xxxxClear f 0 --> f     Z  00 0001 1fff ffffSwap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffAdd Literal and W W+k --> W C DC Z  11 111x kkkk kkkkAdd W and f W+f --> d C DC Z  00 0111 dfff ffffSubtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSubtract f from W W-f --> d C DC Z  00 0010 dfff ffffIncrement f f+1 --> f     Z  00 1010 dfff ffffDecrement f f-1 --> f     Z  00 0011 dfff ffffAND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkAND W with f W .AND. f --> d     Z  00 0101 dfff ffffOR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkOR W with f W .OR. f --> d     Z  00 0100 dfff ffffXOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffComplement f f --> d     Z  00 1001 dfff ffffRotate f Left through carry   C      00 1101 dfff ffffRotate f Right through carry   C      00 1100 dfff ffffBit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGo to address          10 1kkk kkkk kkkkCall subroutine          10 0kkk kkkk kkkkReturn from subroutine          00 0000 0000 1000Return with Literal in W          11 01xx kkkk kkkkReturn from Interrupt          00 0000 0000 1001Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDecrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNo Operation          00 0000 0xx0 0000Clear Watchdog Timer          00 0000 0110 0100Go into Standby Mode          00 0000 0110 0011

Aadress Bin Hex0x55 -> W: 11 0000 0101 0101 30 550000

W -> 20h: 00 0000 1010 0000 00 A00001

W -> PORTB: 00 0000 1000 0110 00 860002

Invert 20h: 00 1001 1010 0000

09 A00003

20h -> W: 00 1000 0010 0000

08 200004

Go to 0002: 10 1000 0000 0010 28 020005

Tehtud! Kas see programm töötab ka?

7 6 5 4 3 2 1 0

x3h STATUS IRP RP1 RP0 _TO _PD Z DC C

7 6 5 4 3 2 1 0

xAh PCLATH A12 A11

Registrite adresseerimisel peab Banga number olema registris STATUS!

GOTO 2 vanemat bitti peavad olema registris PCLATH!

Page 22: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

MOVLW k Move Literal to W k --> W        11 00xx kkkk kkkkMOVWF f Move W to f W --> f     Z  00 0000 1fff ffffMOVF f,d Move f to d f --> d     Z  00 1000 dfff ffffCLRW   Clear W 0 --> W     Z  00 0001 0xxx xxxxCLRF f Clear f 0 --> f     Z  00 0001 1fff ffffSWAPF f,d Swap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffADDLW k Add Literal and W W+k --> W C DC Z  11 111x kkkk kkkkADDWF f,d Add W and f W+f --> d C DC Z  00 0111 dfff ffffSUBLW k Subtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSUBWF f,d Subtract f from W W-f --> d C DC Z  00 0010 dfff ffffINCF f,d Increment f f+1 --> f     Z  00 1010 dfff ffffDECF f,d Decrement f f-1 --> f     Z  00 0011 dfff ffffANDLW k AND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkANDWF f,d AND W with f W .AND. f --> d     Z  00 0101 dfff ffffIORLW k OR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkIORWF f,d OR W with f W .OR. f --> d     Z  00 0100 dfff ffffXORLW k XOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXORWF f,d XOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffCOMF f,d Complement f f --> d     Z  00 1001 dfff ffffRLF f,d Rotate f Left through carry   C      00 1101 dfff ffffRRF f,d Rotate f Right through carry   C      00 1100 dfff ffffBCF f,b Bit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBSF f,b Bit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGOTO k Go to address          10 1kkk kkkk kkkkCALL k Call subroutine          10 0kkk kkkk kkkkRETURN   Return from subroutine          00 0000 0000 1000RETLW k Return with Literal in W          11 01xx kkkk kkkkRETFIE   Return from Interrupt          00 0000 0000 1001BTFSC f,b Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBTFSS f,b Bit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDECFSZ f,d Decrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINCFSZ f,d INcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNOP   No Operation          00 0000 0xx0 0000CLRWDT   Clear Watchdog Timer          00 0000 0110 0100SLEEP   Go into Standby Mode          00 0000 0110 0011

Page 23: Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

MOVLW k Move Literal to W k --> W        11 00xx kkkk kkkkMOVWF f Move W to f W --> f     Z  00 0000 1fff ffffMOVF f,d Move f to d f --> d     Z  00 1000 dfff ffffCLRW   Clear W 0 --> W     Z  00 0001 0xxx xxxxCLRF f Clear f 0 --> f     Z  00 0001 1fff ffffSWAPF f,d Swap nibbles in f f(7:4)(3:0)->f(3:0)(7:4)        00 1110 dfff ffffADDLW k Add Literal and W W+k --> W C DC Z  11 111x kkkk kkkkADDWF f,d Add W and f W+f --> d C DC Z  00 0111 dfff ffffSUBLW k Subtract Literal from W W-k --> W C DC Z  11 110x kkkk kkkkSUBWF f,d Subtract f from W W-f --> d C DC Z  00 0010 dfff ffffINCF f,d Increment f f+1 --> f     Z  00 1010 dfff ffffDECF f,d Decrement f f-1 --> f     Z  00 0011 dfff ffffANDLW k AND Literal with W W .AND. k --> W     Z  11 1101 kkkk kkkkANDWF f,d AND W with f W .AND. f --> d     Z  00 0101 dfff ffffIORLW k OR Literal with W W .OR. k --> W     Z  11 1000 kkkk kkkkIORWF f,d OR W with f W .OR. f --> d     Z  00 0100 dfff ffffXORLW k XOR Literal with W W .XOR. k --> W     Z  11 1010 kkkk kkkkXORWF f,d XOR W with f W .XOR. f --> d     Z  00 0110 dfff ffffCOMF f,d Complement f f --> d     Z  00 1001 dfff ffffRLF f,d Rotate f Left through carry   C      00 1101 dfff ffffRRF f,d Rotate f Right through carry   C      00 1100 dfff ffffBCF f,b Bit Clear bit b of f 0 --> f(b)        01 00bb bfff ffffBSF f,b Bit Set bit b of f 1 --> f(b)        01 01bb bfff ffffGOTO k Go to address          10 1kkk kkkk kkkkCALL k Call subroutine          10 0kkk kkkk kkkkRETURN   Return from subroutine          00 0000 0000 1000RETLW k Return with Literal in W          11 01xx kkkk kkkkRETFIE   Return from Interrupt          00 0000 0000 1001BTFSC f,b Bit Test f, Skip if Clear skip next if f(b)=0        01 10bb bfff ffffBTFSS f,b Bit Test f, Skip if Set skip next if f(b)=1        01 11bb bfff ffffDECFSZ f,d Decrement f, Skip if 0 f-1->d, skip next if Z=1        00 1011 dfff ffffINCFSZ f,d INcrement f, Skip if 0 f+1->d, skip next if Z=1        00 1111 dfff ffffNOP   No Operation          00 0000 0xx0 0000CLRWDT   Clear Watchdog Timer          00 0000 0110 0100SLEEP   Go into Standby Mode          00 0000 0110 0011

Aadress0x55 -> W:0000

W -> 20h:0001

W -> PORTB:0002

Invert 20h:0003

20h -> W:0004

Go to 0002:0005

PROCESSOR 16F876A#include "P16F876A.INC"

ORG 0x00

MOVLW 0x55MOVWF 0x20

LoopMOVWF PORTBCOMF 0x20,1MOVF 0x20,0GOTO LoopEnd

1: PROCESSOR 16F876A

2: #include "P16F876A.INC“

3:4: ORG 0x005:

0000 3055 MOVLW 0x55 6: MOVLW 0x550001 00A0 MOVWF 0x20 7: MOVWF 0x20

8: Loop0002 0086 MOVWF 0x6 9: MOVWF PORTB0003 09A0 COMF 0x20, F 10: COMF 0x20,10004 0820 MOVF 0x20, W 11: MOVF 0x20,00005 2802 GOTO 0x2 12: GOTO Loop

Hex30 5500 A000 8609 A008 2028 02