Correction Examen Architecture et Microprocesseur
Session Principale Mai 2009
Exercice1 :
1- .
1
0
Compteur 2
1
1
Charger LSB puis MSB
0
1
Mode 2
0
0
Binaire
= B6h
Mov AL,B6h
mov DX,7003h
out DX,AL
mov DX,7002h
mov AL,FDh
out DX,AL
mov AX,04h
out DX,AL
2- .
a.
0
0
Compteur 0
0
Charger LSB
1
0
1
Mode 3
1
1
BCD
= 17h
N=Fclk / F0 = 4
Mov AL,17h
mov DX,7003h
out DX,AL
Advertisement
mov DX,7000h
mov AL,04h
out DX,AL
b. On a N=4 d’ou le chronogramme de Out 0 est le suivant:
1µs
Clk0
Out0
3- Signal carré d’où le mode est 3. Avec N=5 .
0
1
Compteur 1
0
Charger LSB
1
0
1
Mode 3
1
1
BCD
= 57h
Mov AL,57h
mov DX,7003h
out DX,AL
mov DX,7001h
mov AL,05h
out DX,AL
1
ENSI Architecture et Microprocesseur TOUMI Tarek II1C
Exercice2: (La solution n’est pas unique… mais voici l’une des idées)
Data Segment
Heure db 4 dup(?)
Quitter db « appuier sur ESC pour quitter »
data Ends
Code Segment
Assume CS :Code, DS :Data
Code EndS
;chargement de l’heure
;stockage de l’heure dans le tableau
;initialisation des registres
;30 est le code ascii de zéro
;code ascii de ‘ :’
Debut :
Afficher :
Advertisement
En_decimal :
Mov ah,2Ch
int 21h
xor si,si
Lea si,Heure
mov [si],CX
mov [si+2],DX
mov bl,4h
mov cx,4h
Xor si,si
lea si,heure
mov ah,2h
push cx
xor cx,cx
Mov cl,[si]
mov al,0h
inc al
daa
loop En_decimal
mov dl,al
and dl,F0h
shr al,bl
add al,30h
int 21h
add dl,30h
mov al,dl
int 21h
mov al,3Ah
int 21h
inc si
pop cx
loop Afficher
Xor si,si
Lea si,Quitter
mov ah,9h
int 21h
mov ah,1h
2
ENSI Architecture et Microprocesseur TOUMI Tarek II1C
int 21h
cmp al,1Bh
jz fin
jmp debut
Fin :
Advertisement
mov ax,4C00h
int 21h
Exercice3 :
1- INIT Proc Near
mov al,82h
mov dx,333h
out dx,al
RET
;controle
INIT Endp
2- Lecture proc Near
;@ port B
mov dx,331h
in al,dx
RET
Lecture Endp
3- Afficher proc Near
encore :
trouver :
mov dl,4h
shr al,dl
xor si,si
shr al,1h
jc trouver
inc si
jmp encore
mov al,TAB[si] ;TAB est un tableau qui contient les mots des niveaux a afficher
mov dx,330h
out dx,al
; @port A
Afficher Endp
4- Command proc Near
mov ah,al
and ah,0Fh
mov dl,4h
shr al,dl
cmp al,ah
jz arret
jc monte
mov al,0h
jmp action
mov al,08h
jmp action
mov al,88h
Advertisement
mov dx,332h
out dx,al
RET
arret :
monte :
action :
Command Endp
; le niveau actuel et le nombre de commande se trouvent dans al
; ah contient le niveau demandé
;niveau actuel se trouve dans al
;si le niveau actuel et le niveau demandé sont égaux
;si ah (niveau demandé) supérieur à al(niveau actuel)
;sinon on a une descente
;@port C
3
ENSI Architecture et Microprocesseur TOUMI Tarek II1C
5- Data segment
TAB db FCh,60h,DAh,F2h
Data Ends
Code Segment
Assume CS:Code, DS:Data
Main :
CALL INIT
CALL Lecture
CALL Affiche
CALL Lecture
CALL Command
jmp Main
Code Ends
Exercice4:
il n’est pas nécessaire de comprendre le fonctionnement du programme, il suffit de remarquer qu’il y a 2 LOOP a la fin
sans initialisation de CX entre eux, donc logiquement il y a un push et pop, dans la 1ere et la 3eme instruction.
On remarque aussi qu’on utilise le registre si pour le parcours du tableau, donc il nous faux une instruction qui prend
des valeurs de la case mémoire [si] et les met dans un registre mais quel registre ?? on peut facilement le trouver c’est
ah car on prend des valeurs de ah et on les met dans al (l’instruction qui suit instruction 2) d’où c’est le registre ah qu’il
faut utilisé. Je résume :
INSTRUCTION1 : PUSH CX
INSTRUCTION2 : MOV AH,[SI]
INSTRUCTION3 : POP CX
4
ENSI Architecture et Microprocesseur TOUMI Tarek II1C