This repository has been archived on 2019-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
s6-up-tp/TP2/TP21.txt
2017-05-16 07:24:29 +02:00

83 lines
2 KiB
Plaintext

.equ PINA = 0x00 ; définition des adresses des ports
.equ DDRA = 0x01
.equ PORTA = 0x02
.equ EIMSK = 0x3D
.equ EICRA = 0x69
.equ EICRB = 0x6A
.equ WDTCSR = 0x60
.equ RAMEND = 0x21FF
.equ SPH = 0x3E ; initialisation de la pile
.equ SPL = 0x3D
.def chen = r19
.def port = r20
.org 0x000
; Vecteur RESET
jmp debut
.org 0x0002 ; Définition du code à éxecuter lors des interruption
jmp horaire
.org 0x0004 ; Définition du code à éxecuter lors des interruption
jmp antihoraire
.org 0x0080
debut:
DDRA@IO <- 0xFF ; Configuration des ports A et B en sortie
DDRB@IO <- 0xFF
EIMSK <- 0b00000011 ; On active les interruptions PD0 et PD1 sur front descendant
EICRA <- 0b00001010
EICRB <- 0b00000000
; On active les interruptions au niveau du µP
chen <- 0b00000001
chen <- 0xAA
port <- 0x00 ; pair : port A, impair : port B
call afficher
sei
boucle:
sleep ; On ne fait rien jusqu'à la prochaine interruption
jump boucle
horaire:
; si (port & 0x01) == 0 alors lsl chen
si (port & 0x01) == 0 alors chen <- chen * 2
; si (port & 0x01) == 1 alors lsr chen
si (port & 0x01) == 1 alors chen <- chen / 2
si chen != 0 saut finhoraire
si (port & 0x01) == 0 alors chen <- 0b10000000
si (port & 0x01) == 1 alors chen <- 0b00000001
inc port
finhoraire:
call afficher
reti
antihoraire:
; si (port & 0x01) == 0 alors lsr chen
si (port & 0x01) == 0 alors chen <- chen / 2
; si (port & 0x01) == 1 alors lsl chen
si (port & 0x01) == 1 alors chen <- chen * 2
si chen != 0 saut finantihoraire
si (port & 0x01) == 0 alors chen <- 0b00000001
si (port & 0x01) == 1 alors chen <- 0b10000000
inc port
finantihoraire:
call afficher
reti
afficher:
si (port & 0x01) == 0 alors PORTB@IO <- 0x00
si (port & 0x01) == 1 alors PORTA@IO <- 0x00
si (port & 0x01) == 0 alors PORTA@IO <- chen
si (port & 0x01) == 1 alors PORTB@IO <- chen
ret