Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Mikroprotsessorid PIC16F876A KÄSUD. Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu."— Presentation transcript:

1 Mikroprotsessorid PIC16F876A KÄSUD

2 Instruction decode – mis teha tuleb Loe mälust Töötle andmeid Kirjuta mällu

3 1FFFh + 1 = 0000h Käske täidetakse järjest. Peale igat käsku tehakse PC = PC + 1 Erandid: GOTO ja CALL

4 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> f Z 001010dfffffff Decrement ff-1 --> f Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby Mode 00000001100011

5 131211109876543210 OPCODE 131211109876543210 OPCODE11-bitine aadress kkkkkkkkkkk 131211109876543210 OPCODE8-bitine Literal kkkkkkkk 131211109876543210 OPCODE3-bitine biti aadress bbb 7-bitine registri aadress fffffff 131211109876543210 OPCODEd=0: dest=W d=1: dest=f 7-bitine registri aadress fffffff PIC16F876A käskude struktuurAddress modes Käsud registriga Käsud bitiga Käsud konstandiga Absoluutne suunamine Käsud operandita

6 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> d Z 001010dfffffff Decrement ff-1 --> d Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby Mode 00000001100011 131211109876543210 OPCODEd=0: dest=W d=1: dest=f 7-bitine registri aadress fffffff 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 76543210 x3hSTATUSIRPRP1RP0_TO_PDZDCC Mälupanga number tuleb registrist STATUS

7 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> d Z 001010dfffffff Decrement ff-1 --> d Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby Mode 00000001100011 131211109876543210 OPCODEd=0: dest=W d=1: dest=f 7-bitine registri aadress fffffff Move Liida Lahuta Loogika Rotate Liida Lahuta + Tingimuslik suunamine

8 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> d Z 001010dfffffff Decrement ff-1 --> d Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby Mode 00000001100011 131211109876543210 OPCODE3-bitine biti aadress bbb 7-bitine registri aadress fffffff Biti seadmine Tingimuslik suunamine f tähendab mõnda registrit sellest tabelist bbb tähendab biti numbrit (0...7)

9 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> d Z 001010dfffffff Decrement ff-1 --> d Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby Mode 00000001100011 131211109876543210 OPCODE8-bitine Literal kkkkkkkk NB! Kõik Literali käsud on ainult registriga W Move Liida Lahuta Loogika Return

10 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> d Z 001010dfffffff Decrement ff-1 --> d Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby Mode 00000001100011 131211109876543210 OPCODE 11-bitine aadress kkkkkkkkkkk 76543210 xAhPCLATHA12A11 Go Aadressi vanemad 2 bitti tulevad registrist PCLATH 1211109876543210

11 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> d Z 001010dfffffff Decrement ff-1 --> d Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby ModeSleep 00000001100011 131211109876543210 OPCODE

12 131211109876543210 OPCODE 131211109876543210 OPCODE11-bitine aadress kkkkkkkkkkk 131211109876543210 OPCODE8-bitine Literal kkkkkkkk 131211109876543210 OPCODE3-bitine biti aadress bbb 7-bitine registri aadress fffffff 131211109876543210 OPCODEd=0: dest=W d=1: dest=f 7-bitine registri aadress fffffff PIC16F876A käskude struktuurAddress modes Käsud registriga Käsud bitiga Käsud konstandiga Absoluutne suunamine Käsud operandita

13 Port B Register = 0x55 Kirjuta Register Porti B Inverteeri Register Näide: Genereeri PortB abil impulsse

14 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> f Z 001010dfffffff Decrement ff-1 --> f Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby Mode 00000001100011 Register = 0x55 Kirjuta Register Porti B Inverteeri Register

15 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> f Z 001010dfffffff Decrement ff-1 --> f Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby Mode 00000001100011 AadressBinHex 0x55 -> W:11 0000 0101 010130 550000 Move Literal to W k->W11 00xx kkkk kkkk Register = 0x55 Kirjuta Register Porti B Inverteeri Register

16 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> f Z 001010dfffffff Decrement ff-1 --> f Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby Mode 00000001100011 AadressBinHex 0x55 -> W:11 0000 0101 010130 550000 Move W to f W->f00 0000 1fff ffff W -> 20h:00 0000 1010 000000 A00001 Register = 0x55 Kirjuta Register Porti B Inverteeri Register

17 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> f Z 001010dfffffff Decrement ff-1 --> f Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby Mode 00000001100011 AadressBinHex 0x55 -> W:11 0000 0101 010130 550000 Move W to f W->f00 0000 1fff ffff W -> 20h:00 0000 1010 000000 A00001 W -> PORTB:00 0000 1000 011000 860002 Register = 0x55 Kirjuta Register Porti B Inverteeri Register

18 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> f Z 001010dfffffff Decrement ff-1 --> f Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby Mode 00000001100011 AadressBinHex 0x55 -> W:11 0000 0101 010130 550000 W -> 20h:00 0000 1010 000000 A00001 W -> PORTB:00 0000 1000 011000 860002 Invert 20h: 00 1001 1 010 0000 09 A00003 Complement f 00 1001 dfff ffff Register = 0x55 Kirjuta Register Porti B Inverteeri Register d=0: dest=W d=1: dest=f

19 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> f Z 001010dfffffff Decrement ff-1 --> f Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby Mode 00000001100011 AadressBinHex 0x55 -> W:11 0000 0101 010130 550000 W -> 20h:00 0000 1010 000000 A00001 W -> PORTB:00 0000 1000 011000 860002 Invert 20h: 00 1001 1 010 0000 09 A00003 Move f to d 00 1000 dfff ffff 20h -> W: 00 1000 0 010 0000 08 200004 Register = 0x55 Kirjuta Register Porti B Inverteeri Register d=0: dest=W d=1: dest=f

20 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> f Z 001010dfffffff Decrement ff-1 --> f Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby Mode 00000001100011 AadressBinHex 0x55 -> W:11 0000 0101 010130 550000 W -> 20h:00 0000 1010 000000 A00001 W -> PORTB:00 0000 1000 011000 86 0002 Invert 20h: 00 1001 1 010 0000 09 A0 0003 Go to address 10 1kkk kkkk kkkk 20h -> W: 00 1000 0 010 0000 08 200004 Go to 0002:10 1000 0000 001028 020005 Register = 0x55 Kirjuta Register Porti B Inverteeri Register

21 Move Literal to Wk --> W 1100xxkkkk Move W to fW --> f Z 0000001fffffff Move f to df --> d Z 001000dfffffff Clear W0 --> W Z 0000010xxxxxxx Clear f0 --> f Z 0000011fffffff Swap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff Add Literal and WW+k --> WCDCZ 11111xkkkk Add W and fW+f --> dCDCZ 000111dfffffff Subtract Literal from WW-k --> WCDCZ 11110xkkkk Subtract f from WW-f --> dCDCZ 000010dfffffff Increment ff+1 --> f Z 001010dfffffff Decrement ff-1 --> f Z 000011dfffffff AND Literal with WW.AND. k --> W Z 111101kkkk AND W with fW.AND. f --> d Z 000101dfffffff OR Literal with WW.OR. k --> W Z 111000kkkk OR W with fW.OR. f --> d Z 000100dfffffff XOR Literal with WW.XOR. k --> W Z 111010kkkk XOR W with fW.XOR. f --> d Z 000110dfffffff Complement ff --> d Z 001001dfffffff Rotate f Left through carry C 001101dfffffff Rotate f Right through carry C 001100dfffffff Bit Clear bit b of f0 --> f(b) 0100bbbfffffff Bit Set bit b of f1 --> f(b) 0101bbbfffffff Go to address 101kkkkkkk Call subroutine 100kkkkkkk Return from subroutine 000000 1000 Return with Literal in W 1101xxkkkk Return from Interrupt 000000 1001 Bit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff Bit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff Decrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff No Operation 0000000xx00000 Clear Watchdog Timer 00000001100100 Go into Standby Mode 00000001100011 AadressBinHex 0x55 -> W:11 0000 0101 010130 550000 W -> 20h:00 0000 1010 000000 A00001 W -> PORTB:00 0000 1000 011000 86 0002 Invert 20h: 00 1001 1 010 0000 09 A0 0003 20h -> W: 00 1000 0 010 0000 08 200004 Go to 0002:10 1000 0000 001028 020005 Tehtud!Kas see programm töötab ka? 76543210 x3hSTATUSIRPRP1RP0_TO_PDZDCC 76543210 xAhPCLATHA12A11 Registrite adresseerimisel peab Banga number olema registris STATUS! GOTO 2 vanemat bitti peavad olema registris PCLATH!

22 MOVLWkMove Literal to Wk --> W 1100xxkkkk MOVWFfMove W to fW --> f Z 0000001fffffff MOVFf,dMove f to df --> d Z 001000dfffffff CLRW Clear W0 --> W Z 0000010xxxxxxx CLRFfClear f0 --> f Z 0000011fffffff SWAPFf,dSwap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff ADDLWkAdd Literal and WW+k --> WCDCZ 11111xkkkk ADDWFf,dAdd W and fW+f --> dCDCZ 000111dfffffff SUBLWkSubtract Literal from WW-k --> WCDCZ 11110xkkkk SUBWFf,dSubtract f from WW-f --> dCDCZ 000010dfffffff INCFf,dIncrement ff+1 --> f Z 001010dfffffff DECFf,dDecrement ff-1 --> f Z 000011dfffffff ANDLWkAND Literal with WW.AND. k --> W Z 111101kkkk ANDWFf,dAND W with fW.AND. f --> d Z 000101dfffffff IORLWkOR Literal with WW.OR. k --> W Z 111000kkkk IORWFf,dOR W with fW.OR. f --> d Z 000100dfffffff XORLWkXOR Literal with WW.XOR. k --> W Z 111010kkkk XORWFf,dXOR W with fW.XOR. f --> d Z 000110dfffffff COMFf,dComplement ff --> d Z 001001dfffffff RLFf,dRotate f Left through carry C 001101dfffffff RRFf,dRotate f Right through carry C 001100dfffffff BCFf,bBit Clear bit b of f0 --> f(b) 0100bbbfffffff BSFf,bBit Set bit b of f1 --> f(b) 0101bbbfffffff GOTOkGo to address 101kkkkkkk CALLkCall subroutine 100kkkkkkk RETURN Return from subroutine 000000 1000 RETLWkReturn with Literal in W 1101xxkkkk RETFIE Return from Interrupt 000000 1001 BTFSCf,bBit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff BTFSSf,bBit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff DECFSZf,dDecrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INCFSZf,dINcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff NOP No Operation 0000000xx00000 CLRWDT Clear Watchdog Timer 00000001100100 SLEEP Go into Standby Mode 00000001100011

23 MOVLWkMove Literal to Wk --> W 1100xxkkkk MOVWFfMove W to fW --> f Z 0000001fffffff MOVFf,dMove f to df --> d Z 001000dfffffff CLRW Clear W0 --> W Z 0000010xxxxxxx CLRFfClear f0 --> f Z 0000011fffffff SWAPFf,dSwap nibbles in ff(7:4)(3:0)->f(3:0)(7:4) 001110dfffffff ADDLWkAdd Literal and WW+k --> WCDCZ 11111xkkkk ADDWFf,dAdd W and fW+f --> dCDCZ 000111dfffffff SUBLWkSubtract Literal from WW-k --> WCDCZ 11110xkkkk SUBWFf,dSubtract f from WW-f --> dCDCZ 000010dfffffff INCFf,dIncrement ff+1 --> f Z 001010dfffffff DECFf,dDecrement ff-1 --> f Z 000011dfffffff ANDLWkAND Literal with WW.AND. k --> W Z 111101kkkk ANDWFf,dAND W with fW.AND. f --> d Z 000101dfffffff IORLWkOR Literal with WW.OR. k --> W Z 111000kkkk IORWFf,dOR W with fW.OR. f --> d Z 000100dfffffff XORLWkXOR Literal with WW.XOR. k --> W Z 111010kkkk XORWFf,dXOR W with fW.XOR. f --> d Z 000110dfffffff COMFf,dComplement ff --> d Z 001001dfffffff RLFf,dRotate f Left through carry C 001101dfffffff RRFf,dRotate f Right through carry C 001100dfffffff BCFf,bBit Clear bit b of f0 --> f(b) 0100bbbfffffff BSFf,bBit Set bit b of f1 --> f(b) 0101bbbfffffff GOTOkGo to address 101kkkkkkk CALLkCall subroutine 100kkkkkkk RETURN Return from subroutine 000000 1000 RETLWkReturn with Literal in W 1101xxkkkk RETFIE Return from Interrupt 000000 1001 BTFSCf,bBit Test f, Skip if Clearskip next if f(b)=0 0110bbbfffffff BTFSSf,bBit Test f, Skip if Setskip next if f(b)=1 0111bbbfffffff DECFSZf,dDecrement f, Skip if 0f-1->d, skip next if Z=1 001011dfffffff INCFSZf,dINcrement f, Skip if 0f+1->d, skip next if Z=1 001111dfffffff NOP No Operation 0000000xx00000 CLRWDT Clear Watchdog Timer 00000001100100 SLEEP Go into Standby Mode 00000001100011 Aadress 0x55 -> W:0000 W -> 20h:0001 W -> PORTB: 0002 Invert 20h: 0003 20h -> W:0004 Go to 0002:0005 PROCESSOR 16F876A #include "P16F876A.INC" ORG0x00 MOVLW0x55 MOVWF0x20 Loop MOVWFPORTB COMF0x20,1 MOVF0x20,0 GOTOLoop End 1:PROCESSOR 16F876A 2: #include "P16F876A.INC“ 3: 4: ORG0x00 5: 0000 3055 MOVLW 0x556: MOVLW0x55 0001 00A0 MOVWF 0x207: MOVWF0x20 8: Loop 0002 0086 MOVWF 0x69: MOVWFPORTB 0003 09A0 COMF 0x20, F10: COMF0x20,1 0004 0820 MOVF 0x20, W11: MOVF0x20,0 0005 2802 GOTO 0x212: GOTOLoop Hex 30 55 00 A0 00 86 09 A0 08 20 28 02


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

Similar presentations


Ads by Google