circuitos eletrÔnicos embarcados psi2612 aula 03
DESCRIPTION
CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03. ASSUNTO: CONJUNTO DE INSTRUÇÕES ROTEIRO 1. Introdução 2, Descrição das Instruções 3. Exemplos 4. Complementos do hardware. 1. INTRODUÇÃO. NÚMERO DE INSTRUÇÕES : 35 GRUPOS - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/1.jpg)
CIRCUITOS ELETRÔNICOS EMBARCADOSPSI2612
AULA 03
ASSUNTO: CONJUNTO DE INSTRUÇÕES
ROTEIRO
1. Introdução
2, Descrição das Instruções
3. Exemplos
4. Complementos do hardware
![Page 2: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/2.jpg)
1. INTRODUÇÃO
NÚMERO DE INSTRUÇÕES : 35
GRUPOS
> Operações envolvendo todo o byte dos registradores: 18
> Operações envolvendo apenas um bit dos registradores: 4
> Operações com valores literais ou de controle: 13
Transmitter (USART/SCI) with 9-bit addressdetectionPIC16F877/874
![Page 3: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/3.jpg)
TABELA 13-1:DESCRIÇÃO DOS CÖDIGOS UTILIZADOS NOS CAMPOS DAS INSTRUÇÕES
![Page 4: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/4.jpg)
FIGURA 13.1: FORMATO GERAL PARA AS INSTRUÇÕES
![Page 5: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/5.jpg)
TABELA 13-2 : CONJUNTO DE INSTRUÇÕES DO PIC
![Page 6: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/6.jpg)
TABELA 13-2 :CONJUNTO DE INSTRUÇÕES DO PIC
![Page 7: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/7.jpg)
TABELA 13-2 :CONJUNTO DE INSTRUÇÕES DO PIC
![Page 8: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/8.jpg)
2. CONJUNTO DE INSTRUÇÕES
DESCRIÇÃO
![Page 9: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/9.jpg)
DESCRIÇÃO DA INSTRUÇÃO ADDLWADDLW Add Literal and W-------------------------------------------------------Syntax [label] ADDLW k
Operands: 0 k 255 Operation: (W) + k (W)
Status Affected: C, DC, Z
Description: The contents of the Wregister are added to the eight bit literal ’k’ and the result is placed in the W register.
![Page 10: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/10.jpg)
DESCRIÇÃO DA INSTRUÇÃO ADDWF
ADDWF Add W and F---------------------------------------------------- Syntax: [label] ADDWF f,dOperands: 0 f 127
d [0,1]
Operation: (W) + (f) (destination)
Status Affected: C, DC, Z
Description: Add the contents of the W register with register ’f’. If ’d’ is 0, the resultis stored in the W register. If ’d’ is1, the result is stored back in register ’f’.
![Page 11: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/11.jpg)
DESCRIÇÃO DA INSTRUÇÃO ADDWFANDLW AND Literal with W--------------------------------------------------------Syntax: [label] ANDLW k
Operands: 0 k 255
Operation: (W) .AND. (k) (W)
Status Affected: Z
Description: The contents of W register areAND’ed with the eight bit literal'k'. The result is placed in the Wregister.
![Page 12: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/12.jpg)
DESCRIÇÃO DA INSTRUÇÃO ANDWFANDWF AND W with f---------------------------------------------------------Syntax: [label] ANDWF f,d
Operands: 0 f 127d [0,1]
Operation: (W) .AND. (f) (destination)
Status Affected: Z
Description: AND the W register with register 'f'. If 'd’ is 0, the result is stored in the W register. If 'd' is 1, the resultis stored back in register 'f'.
![Page 13: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/13.jpg)
DESCRIÇÃO DA INSTRUÇÃO BCF
BCF Bit Clear f----------------------------------------------Syntax: [label] BCF f,b
Operands: 0 f 1270 b 7
Operation: 0 (f<b>)
Status Affected: None
Description Bit 'b' in register 'f' is cleared.
![Page 14: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/14.jpg)
DESCRIÇÃO DA INSTRUÇÃO BSF
BSF Bit Set f---------------------------------------------------Syntax: [label] BSF f,b
Operands: 0 f 1270 b 7
Operation: 1 (f<b>)
Status Affected: None
Description: Bit 'b' in register 'f' is set.
![Page 15: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/15.jpg)
DESCRIÇÃO DA INSTRUÇÃO BTFSSBTFSS Bit Test f, Skip if Set-----------------------------------------------------Syntax: [label] BTFSS f,b
Operands: 0 f 1270 b 7
Operation: skip if (f<b>) = 1
Status Affected: None
Description: If bit 'b' in register 'f' is '0', the nextinstruction is executed.If bit 'b' is '1', then the next instructionis discarded and a NOP is executed instead, making this a 2TCY instruction.
![Page 16: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/16.jpg)
DESCRIÇÃO DA INSTRUÇÃO BTFSCBTFSC Bit Test, Skip if Clear-------------------------------------------------------------Syntax: [label] BTFSC f,b
Operands: 0 f 1270 b 7
Operation: skip if (f<b>) = 0
Status Affected: None
Description: If bit 'b' in register 'f' is '1', the nextinstruction is executed.If bit 'b', in register 'f', is '0', the next instruction is discarded, and a NOP is executed instead, making this a 2TCY instruction.
![Page 17: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/17.jpg)
DESCRIÇÃO DA INSTRUÇÃO CALLCALL Call Subroutine----------------------------------------------------------------------------Syntax: [ label ] CALL k
Operands: 0 k 2047
Operation: (PC)+ 1 TOS,k PC<10:0>,(PCLATH<4:3>) PC<12:11>
Status Affected: None
Description: Call Subroutine. First, return address (PC+1) is pushed onto the stack. The eleven-bit immediate address is loaded into PC bits <10:0>. The upper bits of the PC are loaded from PCLATH. CALL is a two-cycle instruction.
![Page 18: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/18.jpg)
DESCRIÇÃO DA INSTRUÇÃO CLRFCLRF Clear f------------------------------------------------Syntax: [label] CLRF f
Operands: 0 f 127
Operation: 00h (f)1 Z
Status Affected: Z
Description: The contents of register ’f’ arecleared and the Z bit is set.
![Page 19: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/19.jpg)
DESCRIÇÃO DA INSTRUÇÃO CLRW
CLRW Clear W---------------------------------------------------------------Syntax: [ label ] CLRW
Operands: None
Operation: 00h (W)1 Z
Status Affected Z
Description: W register is cleared. Zero bit (Z) is set.
![Page 20: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/20.jpg)
DESCRIÇÃO DA INSTRUÇÃO CLRWDT
CLRWDT Clear Watchdog Timer-------------------------------------------------------------------Syntax: [ label ] CLRWDT
Operands: None
Operation: 00h WDT0 WDT prescaler,1 TO1 PD
Status Affected: TO, PD
Description: CLRWDT instruction resets the Watchdog Timer. It also resets the prescaler of the WDT. Status bits TO and PD are set.
![Page 21: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/21.jpg)
DESCRIÇÃO DA INSTRUÇÃO COMF
COMF Complement f----------------------------------------------------------------------Syntax: [ label ] COMF f,d
Operands: 0 f 127d . [0,1]
Operation: (f) (destination)
Status Affected: Z
Description: The contents of register ’f’ are complemented. If ’d’ is 0, theresult is stored in W. If ’d’ is 1, theresult is stored back in register ’f’.
![Page 22: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/22.jpg)
DESCRIÇÃO DA INSTRUÇÃO DECF
DECF Decrement f-------------------------------------------------------------Syntax: [label] DECF f,d
Operands: 0 f 127d [0,1]
Operation: (f) - 1 (destination)
Status Affected: Z
Description: Decrement register ’f’. If ’d’ is 0,the result is stored in the Wregister. If ’d’ is 1, the result isstored back in register ’f’.
![Page 23: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/23.jpg)
DESCRIÇÃO DA INSTRUÇÃO DECFSZ DECFSZ Decrement f, Skip if 0--------------------------------------------------------------------------Syntax: [ label ] DECFSZ f,d
Operands: 0 f 127d [0,1]
Operation: (f) - 1 (destination);skip if result = 0
Status Affected: None
Description: The contents of register ’f’ are decremented. If ’d’ is 0, the result is placed in the W register. If ’d’ is 1, the result is placed back in register ’f’.If the result is 1, the next instruction is executed. If the result is 0, then a NOP is executed instead making it a 2TCYinstruction.
![Page 24: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/24.jpg)
DESCRIÇÃO DA INSTRUÇÃO GOTOGOTO Unconditional Branch-------------------------------------------------------------------------------Syntax: [ label ] GOTO k
Operands: 0 k 2047
Operation: k PC<10:0>PCLATH<4:3> PC<12:11>
Status Affected: None
Description: GOTO is an unconditional branch.The eleven-bit immediate value isloaded into PC bits <10:0>. Theupper bits of PC are loaded fromPCLATH<4:3>. GOTO is a twocycleinstruction.
![Page 25: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/25.jpg)
DESCRIÇÃO DA INSTRUÇÃO INCFINCF Increment f-------------------------------------------------------------------------Syntax: [ label ] INCF f,d
Operands: 0 f 127d . [0,1
Operation: (f) + 1 (destination)
Status Affected Z
Description: The contents of register ’f’ areincremented. If ’d’ is 0, the resultis placed in the W register. If ’d’ is1, the result is placed back inregister ’f’.
![Page 26: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/26.jpg)
DESCRIÇÃO DA INSTRUÇÃO INCFSZINCFSZ Increment f, Skip if 0-------------------------------------------------------------------------Syntax: [ label ] INCFSZ f,d
Operands: 0 f 127d [0,1]
Operation: (f) + 1 (destination),skip if result = 0
Status Affected: None
Description: The contents of register ’f’ are incremented. If ’d’ is 0, the result is placed in the W register. If ’d’ is 1, the result is placed back in register ’f’. If the result is 1, the next instruction is executed. If the result is 0,a NOP is executed instead, making
![Page 27: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/27.jpg)
DESCRIÇÃO DA INSTRUÇÃO IORLW
IORLW Inclusive OR Literal with W---------------------------------------------------------------------Syntax: [ label ] IORLW k
Operands: 0 k 255
Operation: (W) .OR. k (W)
Status Affected: Z
Description: The contents of the W register areOR’ed with the eight bit literal 'k'.The result is placed in the Wregister.
![Page 28: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/28.jpg)
DESCRIÇÃO DA INSTRUÇÃO IORWFIORWF Inclusive OR W with f----------------------------------------------------------------------------Syntax: [ label ] IORWF f,d
Operands: 0 f 127d [0,1]
Operation: (W) .OR. (f) (destination)
Status Affected: Z
Description: Inclusive OR the W register withregister 'f'. If 'd' is 0 the result isplaced in the W register. If 'd' is 1the result is placed back inregister 'f'.
![Page 29: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/29.jpg)
DESCRIÇÃO DA INSTRUÇÃO MOVFMOVF Move f-----------------------------------------------------------------------Syntax: [ label ] MOVF f,d
Operands: 0 f 127d [0,1]
Operation: (f) (destination)Status Affected: Z
Description: The contents of register f are moved to a destination dependant upon the status of d. If d = 0, destination is W register. If d = 1, the destination is file register f itself. d = 1 is useful to test a file register, since status flag Z is affected.
![Page 30: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/30.jpg)
DESCRIÇÃO DA INSTRUÇÃO MOVLW
MOVLW Move Literal to W---------------------------------------------------------------------Syntax: [ label ] MOVLW k
Operands: 0 k 255
Operation: k (W)
Status Affected: None
Description: The eight bit literal ’k’ is loadedinto W register. The don’t careswill assemble as 0’s.
![Page 31: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/31.jpg)
DESCRIÇÃO DA INSTRUÇÃO MOVWF
MOVWF Move W to f--------------------------------------------------------Syntax: [ label ] MOVWF f
Operands: 0 f 127
Operation: (W) (f)
Status Affected: None
Description: Move data from W register to register 'f'.
![Page 32: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/32.jpg)
DESCRIÇÃO DA INSTRUÇÃO NOP
NO No Operation---------------------------------------------------Syntax: [ label ] NOP
Operands: None
Operation: No operation
Status Affected: None
Description: No operation.
![Page 33: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/33.jpg)
DESCRIÇÃO DA INSTRUÇÃO RETFIE
RETFIE Return from Interrupt--------------------------------------------------------------Syntax: [ label ] RETFIE
Operands: None
Operation: TOS PC,1 GIE
Status Affected: None
![Page 34: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/34.jpg)
DESCRIÇÃO DA INSTRUÇÃO RETLWRETLW Return with Literal in W-----------------------------------------------------------------------Syntax: [ label ] RETLW k
Operands: 0 k 255
Operation: k (W);TOS PC
Status Affected: None
Description: The W register is loaded with theeight bit literal 'k'. The programcounter is loaded from the top ofthe stack (the return address).This is a two-cycle instruction.
![Page 35: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/35.jpg)
DESCRIÇÃO DA INSTRUÇÃO RLFRLF Rotate Left f through Carry-------------------------------------------------------------------------------Syntax: [ label ] RLF f,d
Operands: 0 f 127d [0,1]
Operation: See description below
Status Affected: C
Description: The contents of register ’f’ are rotatedone bit to the left through the CarryFlag. If ’d’ is 0, the result is placed inthe W register. If ’d’ is 1, the result isstored back in register ’f’.
![Page 36: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/36.jpg)
DESCRIÇÃO DA INSTRUÇÃO RETURN
RETURN Return from Subroutine-------------------------------------------------------Syntax: [ label ] RETURN
Operands: None
Operation: TOS PC Status Affected: None
Description: Return from subroutine. The stackis POPed and the top of the stack(TOS) is loaded into the programcounter. This is a two-cycleinstruction.
![Page 37: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/37.jpg)
DESCRIÇÃO DA INSTRUÇÃO RRFRRF Rotate Right f through Carry--------------------------------------------------------------------------Syntax: [ label ] RRF f,d
Operands: 0 f 127d [0,1]
Operation: See description below
Status Affected: C
Description: The contents of register ’f’ are rotated one bit to the right through the Carry Flag. If ’d’ is 0, the result is placed in the W register. If ’d’ is1, the result is placed back in register ’f’.
![Page 38: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/38.jpg)
DESCRIÇÃO DA INSTRUÇÃO SLEEPSLEEP----------------------------------------------------------------Syntax: [ label ] SLEEP
Operands: NoneOperation: 00h WDT,
0 WDT prescaler,1 TO,0 PD
Status Affected: TO, PD
Description: The power-down status bit, PD is cleared. Time-out status bit, TO is set. Watchdog Timer and its prescaler are cleared.The processor is put into SLEEPmode with the oscillator stopped.
![Page 39: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/39.jpg)
DESCRIÇÃO DA INSTRUÇÃO SUBLW
SUBLW Subtract W from Literal-----------------------------------------------------------------Syntax: [ label ] SUBLW k
Operands: 0 k 255
Operation: k - (W) (W)
Status Affected: C, DC, Z
Description: The W register is subtracted (2’scomplement method) from theeight-bit literal 'k'. The result isplaced in the W register.
![Page 40: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/40.jpg)
DESCRIÇÃO DA INSTRUÇÃO SUBWF
SUBWF Subtract W from f---------------------------------------------------------------------Syntax: [ label ] SUBWF f,d
Operands: 0 f 127d [0,1]
Operation: (f) - (W) (destination)
Status Affected: C, DC, Z
Description Subtract (2’s complement method) W register from register 'f'. If 'd' is 0, the result is stored in the W register. If 'd' is 1, the result is stored back in register 'f'.
![Page 41: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/41.jpg)
DESCRIÇÃO DA INSTRUÇÃO SWAPFSWAPF Swap Nibbles in f--------------------------------------------------------------Syntax: [ label ] SWAPF f,d
Operands: 0 f 127d [0,1]
Operation: (f<3:0>) (destination<7:4>),(f<7:4>) (destination<3:0>)
Status Affected: None
Description: The upper and lower nibbles ofregister ’f’ are exchanged. If ’d’ is0, the result is placed in the Wregister. If ’d’ is 1, the result isplaced in register ’f’.
![Page 42: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/42.jpg)
DESCRIÇÃO DA INSTRUÇÃO XORLW
XORLW Exclusive OR Literal with W----------------------------------------------------------------------Syntax: [label] XORLW k
Operands: 0 k 255
Operation: (W) .XOR. k (W)
Status Affected: Z
Description: The contents of the W registerare XOR’ed with the eight-bit literal'k'. The result is placed inthe W register.
![Page 43: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/43.jpg)
DESCRIÇÃO DA INSTRUÇÃO XORWFXORWF Exclusive OR W with f----------------------------------------------------------------------Syntax: [label] XORWF f,d
Operands: 0 f 127d [0,1]
Operation: (W) .XOR. (f) (destination)
Status Affected Z
Description: Exclusive OR the contents of theW register with register 'f'. If 'd' is0, the result is stored in the Wregister. If 'd' is 1, the result isstored back in register 'f'.
![Page 44: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/44.jpg)
3. EXEMPLOS
![Page 45: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/45.jpg)
EXEMPLO 01
LEITURA DE DADOS DA EEPROM
EEPROM(EEADR) EEDATA
![Page 46: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/46.jpg)
ARQUITETURA DO PIC16F87X
![Page 47: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/47.jpg)
MAPA DOS REGISTRADORES
![Page 48: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/48.jpg)
REGISTRADOR DE STATUS
![Page 49: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/49.jpg)
REGISTRADOR EECON1
![Page 50: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/50.jpg)
EXEMPLO DE PROGRAMA
![Page 51: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/51.jpg)
EXEMPLO 2
ESCRITA NA MEMÓRIA FLASH DE PROGRAMA
![Page 52: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/52.jpg)
REGISTRADORES ASSOCIADOS À MEMÓRIA FLASH DE PROGRAMA
![Page 53: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/53.jpg)
EXEMPLO 2
![Page 54: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/54.jpg)
EXEMPLO 3 São dados dois Microcontroladores , A e B
Desenvolver um programa para o microcontrolador A que receberá de B um bloco de no máximo 61 bytes.
O programa deverá ser armazenado na Memória de Programa a partir da posição X.
O primeiro dado recebido informa o número de bytes que virão a seguir(desconsiderar este ), e que será armazenado na posição 20h
Os dados seguintes deverão ser guardados alternadamente na memória de dados a partir das posições 31h e 61h.
![Page 55: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/55.jpg)
ADOTAR. O microcontrolador A receberá um byte de cada vez através dos pinos <RB7-RB0>.. A utilizará RA0 como informação de entrada para controle e RA1 para saída. SEQUÊNCIA1. A comunica B( que está receptivo ) que inicializou o programa colocando RA1 0,1,0 ,permanecendo neste último.2. A consulta a disponibilidade de um byte em <RB7-RB0> através de RA0 .3. Quando RA0 for 1 (inicialmente 0 ) o dado estará disponível .4. A lê a informação ,armazena e envia através de RA1(=1) informação que já registrou o dado ,ficando operando 02 NOP e RA1 volta para zero( B está recptivo )5. B recebe a informação e zera RA0 e disponibiliza novo byte de dado ,setando RA0 ,6. Aoperação se repete aié o término dos dados .
![Page 56: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/56.jpg)
PROGRAMAX BSF STATUS,RP0
BCF STATUS,RP1 ,banco 1MOVLW 01h ,direcionaMOVWF TRISA ,portaAMOVLW FF ,direcionaMOVWF TRISB ,portaBBCF STATUS,RP0 ,banco 0BCF PORTAA,1NOPNOPBSF PORTAA,1NOPNOPBCF PORTAA,1
Y MOVF PORTAA,PORTAA ,d=1 lêBTFSS PORTAA,0GOTO Y
![Page 57: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/57.jpg)
PROGRAMA (continuação)
MOVWF NUMDAD(20h)MOVLW 31hMOVWF ENDA(21h)MOVLW 61hMOVWF ENDB(22h)
U MOVF ENDA(21),W ,d=0CALL ZINCF ENDA(21)MOVF ENDB(22h),W ,d=0CALL ZINCF ENDB(22h)DECF NUMDAD(20) ,DECFZ NUMDAD(20) GOTO UEND
MOVF PORTAB,PORTAB ,d=1lêMOVF PORTAB,W ,d=0
![Page 58: CIRCUITOS ELETRÔNICOS EMBARCADOS PSI2612 AULA 03](https://reader035.vdocuments.site/reader035/viewer/2022062316/56814af0550346895db7fee6/html5/thumbnails/58.jpg)
SUBROTINA
Z MOVWF FSRBSF POTAA,1NOPNOPBCF PORTAA,1
Z+5 MOVF PORTA,PORTAA ,d=1 lêBTFSS PORTAA,0GOTO Z+5MOVF PORTAB,PORTAB ,d=1 lêMOVF PORTAB,WMOVWF INDEF ,M(FSR) WRETURN