Architecture : ircuits Numériques et Eléments d Architecture Examen de re session ENSIMAG A Année scolaire 8 9 Durée : 3h. Tous documents et calculatrices autorisés. Le barème est donné à titre indicatif. Les exercices sont indépendants et peuvent être traités dans le désordre. Dans tout l examen, les réponses précises et concises seront favorisées. VOUS DEVE RENDRE LES 3 EXERIES SUR DES OPIES SÉPARÉES Ex. : onception MOS (5 pts) Note : les questions, 3 et 4 (et partiellement la 5) de cet exercice peuvent être traitées même si vous n avez réussi à déchiffrer le masque de la question. Soit le masque donné en annexe, dont la légende est la suivante : les pistes hachurées de la gauche vers la droite (en bas) correspondent à du dopage N+ ; les pistes hachurées de la droite vers la gauche (en haut) correspondent à du dopage P + ; les pistes quadrillées correspondent à du polysilicium ; le rectangle en trait pointillés est un caisson N ; les pistes blanches correspondent à du métal. Question Donner le schéma en transistors MOS correspondant à ce masque.
Vdd t x z Vss y Question Dessiner le schéma MOS correspondant à l équation d = a.b + a.c en utilisant la méthode par synthèse globale (i.e. PMOS en haut, NMOS en bas, comme en TD). Vdd Vdd a b a c Vss a d b c Vss Question 3 est son nom? Soit le circuit calculant e = d. Donner la table de vérité de ce circuit. Quel a c b e 0 e 0 e e 0 e 0 e e Il s agit d un MUX b ( ). Question 4 En utilisant le théorème de De Morgan, exprimer l équation de e uniquement en termes de NAND à entrées et d inverseurs. Dessiner le schéma MOS du circuit
correspondant à cette équation par composition des schémas MOS du NAND et du NOT vus en TD. e = a.b + a.c = a.b.a.c = nand(nand(a, b), nand(not(a), c)) Vdd a b Vdd a b Vdd a Vss d Vss Vdd c Vss c Vss Question 5 omparer les 3 circuits MOS dessinés dans cet exercice et conclure. On a 6 transistors dans la version du MUX en interrupteurs MOS, (en comptant l inverseur à ajouter pour calculer e = d) dans la version en synthèse globale et 4 dans la version par synthèse NAND. La version en interrupteurs MOS est donc moins coûteuse en nombre de transistors. Ex. : Programmation d un micro-contrôleur (4 pts) On va travailler dans cet exercice sur le micro-contrôleur PI utilisé lors du TP5. Les documentations utiles se trouvent en annexe du sujet. Question Désassembler le code PI ci-dessous (i.e. retrouver les instructions en assembleur PI correspondant au code hexadécimal donné). 3
Hexadécimal 0x683 0x085 0x08 0x08B 0x83 Assembleur Hexadécimal 0x09 0x0A9 0x08 0x85 0x806 Assembleur On donne les définitions de constantes à titre indicatif, les codes hexadécimaux donnés correspondent aux instructions entre l étiquette Start et la directive END. LIST p=6f84 OPT_REG EQU STATUS EQU 3 TRISA EQU 5 TRISB EQU 6 PORTA EQU 5 PORTB EQU 6 INTON EQU 0xB EQU 0 EQU RP0 EQU 5 ORG 0 Start Boucle bsf STATUS, RP0 clrf TRISA clrf OPT_REG clrf INTON bcf STATUS, RP0 clrf 0x incf 0x, F movf 0x, W movwf PORTA goto Boucle END Question Que fait le programme ci-dessus? On ne vous demande pas de détailler ce que fait chaque instruction mais d expliquer le but général du programme (e.g. «ce programme calcule les 04 premières décimales de π»). e programme énumère dans la variable 0x toutes les valeurs entre 0 et 55 inclus, et pour chaque valeur, l envoie sur le port A qui est relié à l afficheur 7-segments. et afficheur étant capable d afficher des valeurs entre 0 et 3 inclus (le 5 e bit de l afficheur est matérialisé par un point), on obtient donc sur l affichage un compteur modulo 3. Question 3 Expliquer le rôle de la première instruction du programme. Vous serez noté sur la précision de votre réponse. bsf STATUS, RP0 sert à sélectionner le banc de registres, pour pouvoir accéder aux registres de configuration des ports TRISA et TRISB. Ex. 3 : onception d un processeur ( pts) On va travailler dans cet exercice sur le processeur dont on a étudié les parties contrôle et opérative lors des TD et. On rappelle la PO en annexe. On considère que ce processeur est connecté à une mémoire asynchrone via un bus d adresses sur 6 bits et un bus de données sur 8 bits, comme vu en TD. 4
On souhaite ajouter au processeur la gestion de trois instructions supplémentaires : MV #imm, SP : cette instruction copie dans le registre SP la valeur immédiate contenue dans l instruction ; PUSH %ri : cette instruction commence par soustraire à SP, puis elle stoce le contenu du registre %ri dans la case mémoire dont l adresse est contenue dans SP (la valeur de SP prise en compte est celle après la décrémentation) ; POP %ri : cette instruction stoce dans le registre %ri le contenu de la case mémoire d adresse SP puis ajoute à SP. On doit donc ajouter un nouveau registre à la PO : le registre SP dont le rôle est de contenir l adresse d une zone de la mémoire où on va ranger des données. On donne ci-dessous la table de vérité de ce registre : Entrées Sortie RST D(7: 0) LDH LDL IN DE K SP (5: 0) SP (5:0) = 0 0 X(7:0) 0 SP (5:8) = X(7:0) 0 X(7:0) 0 SP (7:0) = X(7:0) 0 0 0 0 SP = SP prec + 0 0 0 0 SP = SP prec e registre a donc le fonctionnement suivant : si RST =, le registre est mis à 0 de façon asynchrone ; si LDH = et LDL = 0, on charge dans les 8 bits de poids fort de SP la valeur en entrée du registre ; si LDH = 0 et LDL =, on charge dans les 8 bits de poids faible de SP la valeur en entrée du registre ; si LDH = LDL = DE = 0 et IN =, on incrémente le contenu de SP ; si LDH = LDL = IN = 0 et DE =, on décrémente le contenu de SP ; on ne doit pas avoir en même temps LDH et LDL (resp. IN et DE) à. Question omment peut-on très simplement relier la sortie de SP au bus adresse (indication : un seul composant de la PO à modifier)? Il suffit de remplacer le MUX SELAD par un MUX 6b (4 ) et de brancher la sortie de SP à l entrée numéro 0 de ce MUX (l entrées du MUX ne sera pas utilisée ici). Question A quoi doit-on relier l entrée D(7: 0) du registre SP pour pouvoir implanter l instruction MV #imm, SP? Justifier brièvement. Il faut relier cette entrée au bus de données DATAIN puisque la valeur immédiate est stocée en mémoire programme dans l instruction MV #imm, SP. connu sous le nom de «pointeur de pile» (Stac Pointer). en général appelée «pile» (stac). 5
Dans les questions ci-dessous, on demande systématiquement la description RTL et la liste exhaustives des signaux de contrôle de la PO. On ne demande pas de rappeler les états du fetch ni de préciser le décodage des instructions. Dans toutes les descriptions demandées, on considérera que tous les signaux de contrôle non-précisés valent 0, sauf les signaux de contrôle de la mémoire qui valent par défaut. Vous donnerez systématiquement la description la plus parallélisée possible. Question 3 Donner la description RTL de l instruction MV #imm, SP, puis lister tous les signaux de contrôle associés aux différents états de l automate. Vous utiliserez des signaux de contrôle portant le même nom que les entrées des registres (e.g. LDH, IN,...). N oubliez pas de préciser les signaux de contrôle de la mémoire! RTL : [MVSP] SPH := MEM(P) ; P := P + [MVSP] SPL := MEM(P) ; P := P + Signaux : [MVSP] E* := 0 OE* := 0 SELAD := 0 LDH := EP := [MVSP] E* := 0 OE* := 0 SELAD := 0 LDL := EP := Question 4 Donner la description RTL de l instruction POP %ri, puis lister tous les signaux de contrôle associés aux états. RTL : [POP] %ri := MEM(SP) ; SP := SP + Signaux : [POP] E* := 0 OE* := 0 SELAD := 0 SOURER := SELREG := %ri ERITURER := IN := On va maintenant implanter l instruction PUSH %ri. Dans une première version, on considère que l écriture dans la mémoire peut se faire en cycle sans problème de stabilisation. Question 5 Donner la description RTL de l instruction PUSH %ri, puis lister tous les signaux de contrôle associés aux états. 6
RTL : [PUSH] SP := SP - [PUSH] MEM(SP) := %ri Signaux : [PUSH] DE := [PUSH] E* := 0 WE* := 0 ERAM := SELB := %ri SELAD := 0 On considère les deux chronogrammes ci-dessous, correspondant à l exécution de l instruction PUSH %r0 avec SP valant initialement 64 et %r0 contenant la valeur (ces deux chronogrammes correspondent à deux traces d exécution théoriquement possibles de l instruction). K E OE W E bus de données bus d adresses état courant fetch 0xFF 64 63 decode push push hronogramme. 7
K E OE W E bus de données 0xFF 0x80 bus d adresses état courant fetch 63 decode push push hronogramme. Question 6 Expliquer précisément pourquoi dans l état suivant push, on trouve que : pour l exécution correspondant au chronogramme, la valeur est écrite aux adresses 63 et 64 ; pour l exécution correspondant au chronogramme, la valeur 8 est écrite à l adresse 63. Pour le chronogramme, on écrit par erreur le contenu de %r0 à l adresse 64 car l adresse sur le bus d adresse change trop lentement : lorsque WE* passe à 0, l adresse sur le bus est encore 64, et comme la mémoire est asynchrone, on écrit immédiatement la donnée. Puis l adresse change sur le bus, et on écrit la valeur à l adresse 63. Pour le chronogramme, on écrase la valeur écrite à l adresse 63 car WE* repasse trop lentement de 0 à : la valeur sur le bus de données est déjà passée à 8 alors que WE* vaut encore 0, donc on écrit une deuxième fois dans la même case mémoire. Question 7 Donner une description RTL de l instruction PUSH %ri qui ne présente pas ces risques d erreur, puis lister tous les signaux de contrôle associés aux états. On utilisera la notation <- pour symboliser la non-écriture mémoire en RTL. Le principe est le suivant : dans le premier cycle, on doit stabiliser l adresse destination sur le bus adresse et la valeur à écrire sur le bus donnée, mais sans donner le signal d écriture à la mémoire ; dans le deuxième cycle, on ne change surtout pas l adresse et la donnée sur les bus correspondant, et on donne le signal d écriture à la mémoire ; dans le troisième cycle, on maintient l adresse et la donnée sur les bus, mais on ne donne plus le signal d écriture à la mémoire. RTL : [PUSH] SP := SP - 8
[PUSH] MEM(SP) <- %ri [PUSH3] MEM(SP) := %ri [PUSH4] MEM(SP) <- %ri Signaux : [PUSH] DE := [PUSH] E* := 0 ERAM := SELB := %ri SELAD := 0 [PUSH3] E* := 0 WE* := 0 ERAM := SELB := %ri SELAD := 0 [PUSH4] E* := 0 ERAM := SELB := %ri SELAD := 0 Les instructions PUSH et POP sont notamment utilisées pour passer des paramètres à des fonctions et procédures. Soit par exemple la procédure Affiche(A, B, : in haracter) qui affiche à l écran les caractères (sur 8 bits chacun) passés en paramètre. ette procédure s attend à trouver ses paramètres dans la pile : le paramètre A est en sommet de pile, le paramètre B juste en dessous, et le paramètre encore en dessous. Question 8 En utilisant les instructions PUSH et POP, ainsi que toutes les instructions supportées par le processeur étudié dans les TD et, écrire la séquence d instructions correspondant à l appel de la procédure Affiche avec pour paramètres (dans l ordre) a, b et c. Autrement dit, vous devez écrire la séquence d instructions correspondant aux étapes suivantes :. mettre les valeurs à passer en paramètre dans des registres ;. copier ces registres dans la pile ; 3. appeler la fonction Affiche ; 4. remettre la pile dans l état où elle était avant l étape. Pour l étape 3, vous écrirez simplement ALL Affiche. -- Etape : on pourrait aussi entrelacer les Etapes et -- pour n utiliser qu un seul registre LI a, %r0 LI b, %r LI c, %r -- Etape : attention a l ordre des parametres PUSH %r PUSH %r 9
PUSH %r0 -- Etape 3 ALL Affiche -- Etape 4 : on doit remettre SP a sa valeur initiale : -- les registres destination n ont pas d importance POP %r0 POP %r POP %r 0
3 3 4 4 5 5 6 6 7 7 8 8 A A B B D D A(7:0) B(7:0) S(7:0) IN ual op(:0) FLAGS(3:0) E0(7:0) E(7:0) E(7:0) E3(7:0) S(7:0) SEL(:0) E0(7:0) E(7:0) E(7:0) E3(7:0) S(7:0) SEL(:0) E LR D[7:0] Q[7:0] FD8E E LR D[7:0] Q[7:0] FD8E E LR D[7:0] Q[7:0] FD8E E0(7:0) E(7:0) S(7:0) SEL DATAIN(7:0) E LR D[7:0] Q[7:0] FD8E IR R0 R R R3 LK LDIR LK LK LK LK LK LDMEMH LDMEML fd6cehl LDH LDL LR D(7:0) Q(5:0) E0(5:0) E(5:0) S(5:0) SEL ADMEMR(5:0) ADMEMR P(5:0) E LR D[7:0] Q[7:0] FD8E AD(5:0) SourceR cpt6 L E LR D(5:0) Q(5:0) LDP EP LK SUAL(7:0) E DATA(7:0) DATAIN(7:0) ERAM SELAD P IR(7:0) LK op(:0) D(3:0) LD Q(3:0) FLAGS(3:0) LDFLAGS E A A0 D3 D D D0 D_4E EcritureR SelReg0 SelReg SelA(:0) SelB(:0) STATUS 3 0 Sel[:0] SelIN(:0) FLAGS(0) =out
! Microchip Technology Inc. DS357B-page 5 The vector is at h and the interrupt vector is at 04h. The PI6FXX has a 3-bit program counter capable of addressing an 8K x 4 program memory space. For the PI6F84A, the first K x 4 (h-03ffh) are physically implemented (Figure -). Accessing a location above the physically implemented address will cause a wraparound. For example, for locations 0h, 40h, 80h, 0h, 00h, 40h, 80h, and 0h, the instruction will be the same. FFFh. Program Memory Organization 3FFh Additional information on device memory may be found in the PImicro Mid-Range Reference Manual, (DS3303). The data memory area also contains the data EEPROM memory. This memory is not directly mapped into the data memory, but is indirectly mapped. That is, an indirect address pointer specifies the address of the data EEPROM memory to read/write. The 64 bytes of data EEPROM memory have the address range 0h-3Fh. More details on the EEPROM memory can be found in Section 3.0. User Memory Space The data memory can further be broen down into the general purpose RAM and the Special Function Registers (SFRs). The operation of the SFRs that control the core are described here. The SFRs used to control the peripheral modules are described in the section discussing each individual peripheral module. Peripheral Interrupt Vector 04h Vector h Stac Level 8 Stac Level There are two memory blocs in the PI6F84A. These are the program memory and the data memory. Each bloc has its own bus, so that access to each bloc can occur during the same oscillator cycle. ALL, RETURN RETFIE, RETLW 3 P<:0>.0 MEMORY ORGANIATION FIGURE -: PROGRAM MEMORY MAP AND STAK - PI6F84A PI6F84A PI6F84A. Data Memory Organization The data memory is partitioned into two areas. The first is the Special Function Registers (SFR) area, while the second is the General Purpose Registers (GPR) area. The SFRs control the operation of the device. Portions of data memory are baned. This is for both the SFR area and the GPR area. The GPR area is baned to allow greater than 6 bytes of general purpose RAM. The baned areas of the SFR are for the registers that control the peripheral functions. Baning requires the use of control bits for ban selection. These control bits are located in the STATUS Register. Figure - shows the data memory map organization. Instructions MOVWF and MOVF can move values from the W register to any location in the register file ( F ), and vice-versa. The entire data memory can be accessed either directly using the absolute address of each register file or indirectly through the File Select Register (FSR) (Section.5). Indirect addressing uses the present value of the RP0 bit for access into the baned areas of data memory. Data memory is partitioned into two bans which contain the general purpose registers and the special function registers. Ban 0 is selected by clearing the RP0 bit (STATUS<5>). Setting the RP0 bit selects Ban. Each Ban extends up to 7Fh (8 bytes). The first twelve locations of each Ban are reserved for the Special Function Registers. The remainder are General Purpose Registers, implemented as static RAM... GENERAL PURPOSE REGISTER FILE FIGURE -: REGISTER FILE MAP - PI6F84A File Address File Address h Indirect addr. () Indirect addr. () 80h 0h 0h 03h 04h 05h 06h 07h 08h 09h 0Ah 0Bh 0h 4Fh 50h TMR0 OPTION_REG PL STATUS FSR PORTA PORTB EEDATA EEADR PLATH INTON 68 General Purpose Registers (SRAM) PL STATUS FSR TRISA TRISB EEON EEON () PLATH INTON Mapped (accesses) in Ban 0 8h 8h 83h 84h 85h 86h 87h 88h 89h 8Ah 8Bh 8h Fh D0h Each General Purpose Register (GPR) is 8-bits wide and is accessed either directly or indirectly through the FSR (Section.5). The GPR addresses in Ban are mapped to addresses in Ban 0. As an example, addressing location 0h or 8h will access the same GPR. 7Fh Ban 0 Ban FFh Unimplemented data memory location, read as 0. Note : Not a physical register. DS357B-page 6! Microchip Technology Inc.
PI6F84A.3 Special Function Registers The Special Function Registers (Figure - and Table -) are used by the PU and Peripheral functions to control the device operation. These registers are static RAM. The special function registers can be classified into two sets, core and peripheral. Those associated with the core functions are described in this section. Those related to the operation of the peripheral features are described in the section for that specific feature. TABLE -: SPEIAL FUNTION REGISTER FILE SUMMARY Addr Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit Bit Bit 0 Value on Details Power-on on page Ban 0 h INDF Uses contents of FSR to address Data Memory (not a physical register) ---- ---- 0h TMR0 8-bit Real-Time loc/ounter xxxx xxxx 0 0h PL Low Order 8 bits of the Program ounter (P) 03h STATUS () IRP RP RP0 TO PD D 0 xxx 8 04h FSR Indirect Data Memory Address Pointer 0 xxxx xxxx 05h PORTA (4) RA4/T0KI RA3 RA RA RA0 ---x xxxx 6 06h PORTB (5) RB7 RB6 RB5 RB4 RB3 RB RB RB0/INT xxxx xxxx 8 07h Unimplemented location, read as '0' 08h EEDATA EEPROM Data Register xxxx xxxx 3,4 09h EEADR EEPROM Address Register xxxx xxxx 3,4 0Ah PLATH Write Buffer for upper 5 bits of the P () ---0 0Bh INTON GIE EEIE T0IE INTE RBIE T0IF INTF RBIF 0x 0 Ban 80h INDF Uses ontents of FSR to address Data Memory (not a physical register) ---- ---- 8h OPTION_REG RBPU INTEDG T0S T0SE PSA PS PS PS0 9 8h PL Low order 8 bits of Program ounter (P) 83h STATUS () IRP RP RP0 TO PD D 0 xxx 8 84h FSR Indirect data memory address pointer 0 xxxx xxxx 85h TRISA PORTA Data Direction Register --- 6 86h TRISB PORTB Data Direction Register 8 87h Unimplemented location, read as '0' 88h EEON EEIF WRERR WREN WR RD ---0 x0 3 89h EEON EEPROM ontrol Register (not a physical register) ---- ---- 4 0Ah PLATH Write buffer for upper 5 bits of the P () ---0 0Bh INTON GIE EEIE T0IE INTE RBIE T0IF INTF RBIF 0x 0 Legend: x = unnown, u = unchanged. - = unimplemented, read as '0', q = value depends on condition Note : The upper byte of the program counter is not directly accessible. PLATH is a slave register for P<:8>. The contents of PLATH can be transferred to the upper byte of the program counter, but the contents of P<:8> are never transferred to PLATH. : The TO and PD status bits in the STATUS register are not affected by a MLR Reset. 3: Other (non power-up) S include: external through MLR and the Watchdog Timer Reset. 4: On any device, these pins are configured as inputs. 5: This is the value that will be in the port output latch.! Microchip Technology Inc. DS357B-page 7 PI6F84A.3. STATUS REGISTER The STATUS register contains the arithmetic status of the ALU, the status and the ban select bit for data memory. As with any register, the STATUS register can be the destination for any instruction. If the STATUS register is the destination for an instruction that affects the, D or bits, then the write to these three bits is disabled. These bits are set or cleared according to device logic. Furthermore, the TO and PD bits are not writable. Therefore, the result of an instruction with the STATUS register as destination may be different than intended. For example, LRF STATUS will clear the upper three bits and set the bit. This leaves the STATUS register as 0u uuu (where u = unchanged). Only the BF, BSF, SWAPF and MOVWF instructions should be used to alter the STATUS register (Table 7-), because these instructions do not affect any status bit. Note : The IRP and RP bits (STATUS<7:6>) are not used by the PI6F84A and should be programmed as cleared. Use of these bits as general purpose R/W bits is NOT recommended, since this may affect upward compatibility with future products. : The and D bits operate as a borrow and digit borrow out bit, respectively, in subtraction. See the SUBLW and SUBWF instructions for examples. 3: When the STATUS register is the destination for an instruction that affects the, D or bits, then the write to these three bits is disabled. The specified bit(s) will be updated according to device logic REGISTER -: STATUS REGISTER (ADDRESS 03h, 83h) R/W-0 R/W-0 R/W-0 R- R- R/W-x R/W-x R/W-x IRP RP RP0 TO PD D bit 7 bit 0 bit 7-6 Unimplemented: Maintain as 0 bit 5 RP0: Register Ban Select bits (used for direct addressing) 0 = Ban (80h - FFh) = Ban 0 (h - 7Fh) bit 4 TO: Time-out bit = After power-up, LRWDT instruction, or SLEEP instruction 0 = A WDT time-out occurred bit 3 PD: Power-down bit = After power-up or by the LRWDT instruction 0 = By execution of the SLEEP instruction bit : ero bit = The result of an arithmetic or logic operation is zero 0 = The result of an arithmetic or logic operation is not zero bit D: Digit carry/borrow bit (ADDWF, ADDLW,SUBLW,SUBWF instructions) (for borrow, the polarity is reversed) = A carry-out from the 4th low order bit of the result occurred 0 = No carry-out from the 4th low order bit of the result bit 0 : arry/borrow bit (ADDWF, ADDLW,SUBLW,SUBWF instructions) (for borrow, the polarity is reversed) = A carry-out from the Most Significant bit of the result occurred 0 = No carry-out from the Most Significant bit of the result occurred Note: A subtraction is executed by adding the two s complement of the second operand. For rotate (RRF, RLF) instructions, this bit is loaded with either the high or low order bit of the source register. Legend: R = Readable bit W = Writable bit U = Unimplemented bit, read as 0 - n = Value at POR = Bit is set 0 = Bit is cleared x = Bit is unnown DS357B-page 8! Microchip Technology Inc.
PI6F84A 7.0 INSTRUTION SET SUMMARY Each PI6XX instruction is a 4-bit word, divided into an OPODE which specifies the instruction type and one or more operands which further specify the operation of the instruction. The PI6XX instruction set summary in Table 7- lists byte-oriented, bit-oriented, and literal and control operations. Table 7- shows the opcode field descriptions. For byte-oriented instructions, f represents a file register designator and d represents a destination designator. The file register designator specifies which file register is to be used by the instruction. The destination designator specifies where the result of the operation is to be placed. If d is zero, the result is placed in the W register. If d is one, the result is placed in the file register specified in the instruction. For bit-oriented instructions, b represents a bit field designator which selects the number of the bit affected by the operation, while f represents the address of the file in which the bit is located. For literal and control operations, represents an eight or eleven bit constant or literal value. TABLE 7-: OPODE FIELD DESRIPTIONS Field Description f Register file address (0x to 0x7F) W Woring register (accumulator) b Bit address within an 8-bit file register Literal field, constant data or label x Don't care location (= 0 or ) The assembler will generate code with x = 0. It is the recommended form of use for compatibility with all Microchip software tools. d Destination select; d = 0: store result in W, d = : store result in file register f. Default is d = P Program ounter TO Time-out bit PD Power-down bit The instruction set is highly orthogonal and is grouped into three basic categories: Byte-oriented operations Bit-oriented operations Literal and control operations All instructions are executed within one single instruction cycle, unless a conditional test is true or the program counter is changed as a result of an instruction. In this case, the execution taes two instruction cycles with the second cycle executed as a NOP. One instruction cycle consists of four oscillator periods. Thus, for an oscillator frequency of 4 MHz, the normal instruction execution time is µs. If a conditional test is true or the program counter is changed as a result of an instruction, the instruction execution time is µs. Table 7- lists the instructions recognized by the MPASM Assembler. Figure 7- shows the general formats that the instructions can have. Note: To maintain upward compatibility with future PI6XX products, do not use the OPTION and TRIS instructions. All examples use the following format to represent a hexadecimal number: 0xhh where h signifies a hexadecimal digit. FIGURE 7-: GENERAL FORMAT FOR INSTRUTIONS Byte-oriented file register operations 3 8 7 6 0 OPODE d f (FILE #) d = 0 for destination W d = for destination f f = 7-bit file register address Bit-oriented file register operations 3 0 9 7 6 0 OPODE b (BIT #) f (FILE #) b = 3-bit bit address f = 7-bit file register address Literal and control operations General 3 8 7 0 OPODE (literal) = 8-bit immediate value ALL and GOTO instructions only 3 0 0 OPODE (literal) = -bit immediate value A description of each instruction is available in the PImicro Mid-Range Reference Manual (DS3303).! 0 Microchip Technology Inc. DS357B-page 35 PI6F84A TABLE 7-: PI6XXX INSTRUTION SET Mnemonic, Operands Description ycles 4-Bit Opcode MSb LSb Status Affected Notes BYTE-ORIENTED FILE REGISTER OPERATIONS ADDWF ANDWF LRF LRW OMF DEF DEFS INF INFS IORWF MOVF MOVWF NOP RLF RRF SUBWF SWAPF XORWF f - f - Add W and f AND W with f lear f lear W omplement f Decrement f Decrement f, Sip if 0 Increment f Increment f, Sip if 0 Inclusive OR W with f Move f Move W to f No Operation Rotate Left f through arry Rotate Right f through arry Subtract W from f Swap nibbles in f Exclusive OR W with f () () 0 0 0 0 0 0 0 0 0 lfff 0xxx lfff 0xx0 xxxx,d,,d,,,,,,,3,,,3,,,,,,, BIT-ORIENTED FILE REGISTER OPERATIONS BF BSF BTFS BTFSS ADDLW ANDLW ALL LRWDT GOTO IORLW MOVLW RETFIE RETLW RETURN SLEEP SUBLW XORLW f, b f, b f, b f, b - - - - Bit lear f Bit Set f Bit Test f, Sip if lear Bit Test f, Sip if Set Add literal and W AND literal with W all subroutine lear Watchdog Timer Go to address Inclusive OR literal with W Move literal to W Return from interrupt Return with literal in W Return from Subroutine Go into standby mode Subtract W from literal Exclusive OR literal with W () () 0 0 0 0 LITERAL AND ONTROL OPERATIONS 0 0 bb 0bb 0bb bb x 0 0 xx 0xx 0x bfff bfff bfff bfff 0 0,D, TO,PD TO,PD,D, Note : When an I/O register is modified as a function of itself ( e.g., MOVF PORTB, ), the value used will be that value present on the pins themselves. For example, if the data latch is for a pin configured as input and is driven low by an external device, the data will be written bac with a 0. : If this instruction is executed on the TMR0 register (and, where applicable, d = ), the prescaler will be cleared if assigned to the Timer0 Module. 3: If Program ounter (P) is modified or a conditional test is true, the instruction requires two cycles. The second cycle is executed as a NOP.,, 3 3 Note: Additional information on the mid-range instruction set is available in the PImicro Mid-Range MU Family Reference Manual (DS3303). DS357B-page 36! 0 Microchip Technology Inc.