68
Architecture des microcontrôleurs © ESPRIT 2009 H.JEDIDI & M.ABDALLAH 1 Chapitre 3: Modes d’adressage et Jeu d’instructions ABDALLAH Mohamed [email protected] n JEDIDI Hassen [email protected]

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

Embed Size (px)

Citation preview

Page 1: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

1

Architecture des microcontrôleurs

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Chapitre 3: Modes d’adressage et Jeu d’instructions

ABDALLAH Mohamed

[email protected]

JEDIDI Hassen

[email protected]

Page 2: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

2

Les instructions contenues dans la mémoire programme sont une suite de mots binaires décodés puis exécutés par le microprocesseur.

Ces codes sont difficilement compréhensibles par le programmateur.

C’est la raison pour laquelle ils sont traduits en différents mots faisant partis du langage assembleur.

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Introduction

Page 3: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

3

Les modes d’adressages sont les différents moyens qui permettent au microprocesseur d’accéder à une opérande en vue de tester ou de modifier le contenu d’un registre ou d’une mémoire.

Il existe 5 modes d’adressage:

1. Mode d’adressage immédiat (littéral),2. Mode d’adressage direct,3. Mode d’adressage indirect,4. Mode d’adressage de type bit,5. Mode d’adressage relatif (instructions de saut).

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Modes d’adressage

Page 4: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

4

Avec l’ ADRESSAGE IMMEDIAT ou ADRESSAGE LITTERAL, vous pouvez dire :

« je mets 100DT en poche »

La valeur fait IMMEDIATement partie de la phrase.

J’ai donné LITTERALlement la valeur concernée.

Pas besoin d’un autre renseignement. © ESPRIT 2009 H.JEDIDI & M.ABDALLAH

ADRESSAGE IMMEDIAT ou LITTERAL

Page 5: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

5

La donné manipulée par l’instruction est codé avec l’instruction elle-même.

la donnée est appelée un «literal» (appellation adoptée par Microchip).

exemple: MOVLW k

permet de placer le literal k (une valeur quelconque sur 8 bits), dans le registre de travail W

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

ADRESSAGE IMMEDIAT ou LITTERAL (2)

Page 6: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

6

Avec l’ ADRESSAGE IMMEDIAT ou ADRESSAGE LITTERAL, vous pouvez dire :

«  je vais mettre le contenu du coffre numéro 3 dans ma poche  »

l’emplacement contenant la valeur utile est donné DIRECTement dans la phrase.

Mais il faut d’abord aller ouvrir le coffre pour savoir ce que l’on va effectivement mettre en poche.

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

ADRESSAGE DIRECT

exemple: MOVWF f

Page 7: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

7

Ce mode permet de manipuler un bit individuel dans n’importe quel registre.

Ce mode d’adressage est généralement couplé avec le mode d’adressage direct.

exemple: BCF STATUS, RP0

permet de positionner à 0 le bit RP0 du registre STATUS (Sélectionner la banque 0).

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

ADRESSAGE DE TYPE BIT

Page 8: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

8

Dans l’adressage INDIRECT on peut dire:

«  Le préposé du guichet numéro 3 va me donner le numéro du coffre qui contient la

somme que je vais mettre en poche. »

On obtient le numéro de coffre INDIRECTement par le préposé au guichet.

Cet adressage fait appel a deux registres: FSR et INDF

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

ADRESSAGE INDIRECT

Page 9: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

9

INDF: INDirect File,

Il se trouve à l’adresse 0x00.

Ce registre n’existe pas vraiment, ce n’est qu’un procédé d’accès particulier à FSR.

FSR: File Select Register

Il se trouve à l’adresse 0x04 dans les deux banques.

Dans l’exemple précédent le préposé du guichet est le registre FSR

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Les registres FSR et INDF

Page 10: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

10

1. Ecrire l’adresse pointée dans le registre FSR.2. On accède a l’adresse pointée par le registre

INDF.

INDF est le registre FSR utilisé pour accéder a la case mémoire.

LE CONTENU DE INDF EST TRADUIT PAR LE PIC COMME ETANT LE CONTENU DE L’EMPLACEMENT MEMOIRE POINTE PAR FSR

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Les registres FSR et INDF (exemple)

Page 11: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

11

L’opérande détermine une position relatif d’adresse mémoire.

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Adressage Relatif

Page 12: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

12© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Jeu d’instructions

Page 13: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

13

Un microcontrôleur PIC MidRange: instructions codées sur un mot de14 bits.

Un microcontrôleur est de type RISC: jeu d’instruction réduit (35 instructions).

L’exécution d’une instruction occupe un cycle machine (4 périodes d’horloge).

CALL,GOTO, RETFIE, RETLW et RETURN: demandent 2 cycles.

BTFSS, DECFSZ, INCFSZ : demandent un ou deux cycles

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Introduction

Page 14: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

14

Une instruction codée en mémoire sur un mot de 14 bits est subdivisée:• Un code opération: permet de spécifier le type de

l’opération;

• Un ou plusieurs opérandes: permettent de spécifier le (ou les) arguments de l’opération.

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Formats des instructions

Page 15: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

15

Groupes d’instructions:1. Opérations orientés octets:

• f représente la désignation d’un registre SFR et permet de spécifier le registre qui sera utilisé par l’instruction.

• d représente la désignation de la destination et permet de spécifier l’emplacement du résultat:

Si d=0, le résultat est placé dans le registre de travail W;Si d=1, le résultat est placé dans le registre SFR spécifié dans

l’instruction.

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 16: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

16

2. Opérations orientés bit:• b désigne un champ de type bit et permet de sélectionner le

nombre de bits affectés par l’opération.• f représente le numéro du registre dans lequel le bit est

localisé.

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 17: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

17

3. Opérations littérale et de contrôle :• K représente une constante sur 8 ou 11 bits ou une valeur

littérale.

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 18: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

18

Jeu d’instructions:1. Premier groupe:

Page 19: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

19

Jeu d’instructions:2. Deuxième groupe:

Page 20: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

20

Jeu d’instructions:3. Troisième groupe:

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 21: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

21

Description des instructions:

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 22: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

22© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 23: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

23

Exemple 1 MOVF mavariable,W

ADDWF,0

Mettre dans W le contenu de mavariable et additionner mavariable avec le contenu de W et metter le resultat dans W.

Exemple 2MOVF VentesDuMois,WADDWF,1

Mettre dans W le contenu de mavariable et additionner mavariable avec lecontenu de W et ranger le resultat dans ma variable.

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

ADDWF (2)

Page 24: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

24© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 25: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

25© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 26: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

26© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 27: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

27© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 28: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

28© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 29: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

29

Vérifie l’état logique du bit désigné de l’octet situé à l’adresse indiquée.

Est-il à zéro ? S’il est à zéro, ignore l’instruction suivante.

Selon la réponse, l’instruction prend 1 ou 2 cycles d’horloge.

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 30: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

30© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 31: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

31© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 32: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

32© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 33: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

33

Le μC sauvegarde l’adresse de retour dans la pile, puis charge dans le PC (Program Counter) l’adresse à laquelle il est invité à se rendre.

Tout sous-programme appelé par l’instruction CALL doit obligatoirement se terminer soit par l’instruction RETURN, soit par l’instruction RETLW qui renvoient au programme principal.

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

CALL (2)

Page 34: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

34© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 35: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

35© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 36: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

36© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 37: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

37© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 38: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

38© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 39: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

39

Page 40: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

40© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 41: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

41© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 42: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

42© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 43: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

43© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 44: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

44© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 45: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

45© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 46: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

46© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 47: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

47© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 48: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

48© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 49: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

49© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 50: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

50© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 51: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

51

Page 52: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

52© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 53: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

53© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 54: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

54

Page 55: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

55

Page 56: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

56© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 57: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

57

Page 58: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

58© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 59: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

59

Page 60: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

60© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 61: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

61© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 62: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

62© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Resumé

Page 63: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

63© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 64: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

64© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 65: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

65© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 66: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

66

Page 67: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

67© ESPRIT 2009 H.JEDIDI & M.ABDALLAH

Page 68: © ESPRIT 2009 H.JEDIDI & M.ABDALLAH1 Chapitre 3: Modes dadressage et Jeu dinstructions Jeu dinstructions

68© ESPRIT 2009 H.JEDIDI & M.ABDALLAH