This repository has been archived on 2019-08-09. You can view files and clone it, but cannot push or open issues or pull requests.
s6-up-tp/TP2/TP23.txt

135 lines
1.9 KiB
Plaintext
Raw Normal View History

2017-05-04 18:39:58 +02:00
.equ PINA = 0x00 ; d<>finition des adresses des ports
.equ DDRA = 0x01
.equ PORTA = 0x02
.equ PINB = 0x03
.equ DDRB = 0x04
.equ PORTB = 0x05
.equ PIND = 0x09
.equ DDRD = 0x0A
.equ PORTD = 0x0B
.equ SREG = 0x3F
.equ WDTCSR = 0x60
.equ TCCR0A = 0x24
.equ TCCR0B = 0x25
.equ TIMSK0 = 0x6E
.equ TIFR0 = 0x35
.equ EIMSK = 0x3D
.equ EICRA = 0x69
.equ EICRB = 0x6A
.equ RAMEND = 0x21FF
.equ SPH = 0x3E ; initialisation de la pile
.equ SPL = 0x3D
.def d1 = r20
.def d0 = r21
.def route = r22
.org 0x000
; Vecteur RESET
jmp debut
.org 0x0002
jmp b10s
.org 0x0004
jmp b1s
.org 0x0006
jmp marche
.org 0x0008
jmp arret
.org 0x0018
jmp wd
.org 0x0080
afficheur:
.DB 0x7E, 0x0C, 0x37, 0x9F, 0x4D, 0xDB, 0xFB, 0x0E, 0xFF, 0xDF
; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
debut:
d1 <- 0
d0 <- 0
route <- 0
cli
SREG <- 0b10000000
; Configuration des ports
DDRA@IO <- 0xFF
DDRB@IO <- 0xFF
DDRD@IO <- 0x80
; Interruptions
EIMSK <- 0b00001111 ; On active les interruptions PD[3:0] sur front descendant
EICRA <- 0b10101010
EICRB <- 0b00000000
; Watchdog toutes les secondes
WDTCSR <- 0x10
WDTCSR <- 0b01000110
sei
call affiche
boucle:
sleep
jump boucle
b1s:
inc d0
si d0 < 10 saut finb1s
d0 <- 0
jump b10s
finb1s:
call affiche
reti
b10s:
inc d1
si d1 < 10 saut finb10s
d0 <- 9
d1 <- 9
finb10s:
call affiche
reti
affiche:
PORTA@IO <- afficheur@ROM[d1]
PORTB@IO <- afficheur@ROM[d0]
ret
marche:
route <- 1
PORTD@IO <- 0x80
reti
arret:
route <- 0
d0 <- 0
d1 <- 0
call affiche
reti
wd:
si route = 0 saut finwd
dec d0
si d0 < 10 saut prefinwd
d0 <- 9
dec d1
si d1 < 10 saut prefinwd
route <- 0
PORTD@IO <- 0x00
d0 <- 0
d1 <- 0
prefinwd:
call affiche
finwd:
reti