diff --git a/TP1/TP10.asm b/TP1/TP10.asm new file mode 100644 index 0000000..a91f109 --- /dev/null +++ b/TP1/TP10.asm @@ -0,0 +1,25 @@ +.equ PINA = 0x00 ; définition des adresses des ports +.equ DDRA = 0x01 +.equ PORTA = 0x02 + +.equ RAMEND = 0x21FF +.equ SPH = 0x3E ; initialisation de la pile +.equ SPL = 0x3D + +.org 0x000 + ; Vecteur RESET + jmp debut + +.org 0x0080 + +debut: + ldi r16,0x01 ; config direction port A + out DDRA,r16 + +boucle: + in r16,PINA ; Lecture du port A + lsr r16 ; décalage vers la gauche : LED → bouton + ; ldi r16,0x01 ; Test pour vérifier la LED + out PORTA,r16 ; Écriture du port A + jmp boucle ; On recommence + diff --git a/TP1/TP11.asm b/TP1/TP11.asm new file mode 100644 index 0000000..7cfa3fa --- /dev/null +++ b/TP1/TP11.asm @@ -0,0 +1,110 @@ +.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 RAMEND = 0x21FF +.equ SPH = 0x3E ; initialisation de la pile +.equ SPL = 0x3D + +.org 0x000 + ; Vecteur RESET + jmp debut + +.org 0x0080 + +debut: + ldi r16,0xFF ; config direction ports + out DDRA,r16 + out DDRB,r16 + ; r17 <- 0x01 ; 8 places de chenillard + LDI R16,0x01 + MOV R17,R16 + + + +boucleA: + ; On affiche l'état courant + out porta,r17 + + call tempo + + ; On calcule l'état suivant + + lsl r17 + ; si r17 > 0 saut boucleA + MOV R16,R17 + PUSH R16 + LDI R16,0 + POP R17 + CP R17,R16 + BREQ eti0 + BRLO eti0 + LDI R16,0x01 + RJMP eti1 +eti0: + CLR R16 +eti1: + TST R16 + BREQ eti2 + JMP boucleA +eti2: + + + out porta,r17 + ; r17 <- 0b10000000 + LDI R16,0b10000000 + MOV R17,R16 + + ; saut boucleB + JMP boucleB + + +boucleB: + ; On affiche l'état courant + out portb,r17 + + call tempo; + + ; On calcule l'état suivant + + lsr r17 + ; si r17 > 0 saut boucleB + MOV R16,R17 + PUSH R16 + LDI R16,0 + POP R17 + CP R17,R16 + BREQ eti3 + BRLO eti3 + LDI R16,0x01 + RJMP eti4 +eti3: + CLR R16 +eti4: + TST R16 + BREQ eti5 + JMP boucleB +eti5: + + + out portb,r17 + ; r17 <- 0x01 + LDI R16,0x01 + MOV R17,R16 + + ; saut boucleA + JMP boucleA + + +tempo: + ; On fait une pause + ldi r24,8 +tempoA: + subi r22,1 + sbci r23,0 + sbci r24,0 + brcc tempoA + ret diff --git a/TP1/TP11.txt b/TP1/TP11.txt new file mode 100644 index 0000000..40fca29 --- /dev/null +++ b/TP1/TP11.txt @@ -0,0 +1,63 @@ +.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 RAMEND = 0x21FF +.equ SPH = 0x3E ; initialisation de la pile +.equ SPL = 0x3D + +.org 0x000 + ; Vecteur RESET + jmp debut + +.org 0x0080 + +debut: + ldi r16,0xFF ; config direction ports + out DDRA,r16 + out DDRB,r16 + r17 <- 0x01 ; 8 places de chenillard + + +boucleA: + ; On affiche l'état courant + out porta,r17 + + call tempo + + ; On calcule l'état suivant + + lsl r17 + si r17 > 0 saut boucleA + + out porta,r17 + r17 <- 0b10000000 + saut boucleB + +boucleB: + ; On affiche l'état courant + out portb,r17 + + call tempo; + + ; On calcule l'état suivant + + lsr r17 + si r17 > 0 saut boucleB + + out portb,r17 + r17 <- 0x01 + saut boucleA + +tempo: + ; On fait une pause + ldi r24,8 +tempoA: + subi r22,1 + sbci r23,0 + sbci r24,0 + brcc tempoA + ret \ No newline at end of file diff --git a/TP1/TP12.asm b/TP1/TP12.asm new file mode 100644 index 0000000..47ee8e4 --- /dev/null +++ b/TP1/TP12.asm @@ -0,0 +1,91 @@ +.equ PINA = 0x00 ; définition des adresses des ports +.equ DDRA = 0x01 +.equ PORTA = 0x02 +.equ PINC = 0x06 +.equ DDRC = 0x07 +.equ PORTC = 0x08 + +.equ RAMEND = 0x21FF +.equ SPH = 0x3E ; initialisation de la pile +.equ SPL = 0x3D + +.def compteur = r20 +.def seg = r21 + +.org 0x000 + ; Vecteur RESET + jmp debut + +.org 0x0080 + +afficheur: + .DB 0x7E, 0x0C, 0x37, 0x9F, 0x4D, 0xDB, 0xFB, 0x0E, 0xFF, 0xDF + ;.DB 0x7E, 0x30, 0x6D, 0x79, 0x33, 0x5B, 0x5F, 0x70, 0x7F, 0x7B + ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + + +debut: + ldi r16,0xFF ; config direction ports + out DDRA,r16 + out DDRC,r16 + + ldi r16,0x40 ; On sélectionne l'afficheur du millieu + out PORTC,r16 + ; compteur <- 0 + LDI R16,0 + STS compteur,R16 + + + +boucle: + + ; On affiche compteur sur le 7 segments + ; seg <- afficheur@ROM[compteur] + LDS R16,compteur + LDI R30,low(afficheur<<1) + LDI R31,high(afficheur<<1) + CLR R17 + ADD R30,R16 + ADC R31,R17 + LPM R16,Z + STS seg,R16 + + out porta,seg + + ; On incrémente compteur + inc compteur + ; si compteur > 9 alors compteur <- 0 + LDS R16,compteur + PUSH R16 + LDI R16,9 + POP R17 + CP R17,R16 + BREQ eti0 + BRLO eti0 + LDI R16,0x01 + RJMP eti1 +eti0: + CLR R16 +eti1: + TST R16 + BREQ eti2 + LDI R16,0 + STS compteur,R16 +eti2: + + + ; On attend et on recommence + call tempo + ; saut boucle + JMP boucle + + +tempo: + ldi r24,8 +tempoA: + subi r22,1 + sbci r23,0 + sbci r24,0 + brcc tempoA + ret + diff --git a/TP1/TP12.txt b/TP1/TP12.txt new file mode 100644 index 0000000..4a17b38 --- /dev/null +++ b/TP1/TP12.txt @@ -0,0 +1,57 @@ +.equ PINA = 0x00 ; définition des adresses des ports +.equ DDRA = 0x01 +.equ PORTA = 0x02 +.equ PINC = 0x06 +.equ DDRC = 0x07 +.equ PORTC = 0x08 + +.equ RAMEND = 0x21FF +.equ SPH = 0x3E ; initialisation de la pile +.equ SPL = 0x3D + +.def compteur = r20 +.def seg = r21 + +.org 0x000 + ; Vecteur RESET + jmp debut + +.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: + ldi r16,0xFF ; config direction ports + out DDRA,r16 + out DDRC,r16 + + ldi r16,0x40 ; On sélectionne l'afficheur du millieu + out PORTC,r16 + compteur <- 0 + + +boucle: + + ; On affiche compteur sur le 7 segments + seg <- afficheur@ROM[compteur] + out porta,seg + + ; On incrémente compteur + inc compteur + si compteur > 9 alors compteur <- 0 + + ; On attend et on recommence + call tempo + saut boucle + +tempo: + ldi r24,8 +tempoA: + subi r22,1 + sbci r23,0 + sbci r24,0 + brcc tempoA + ret diff --git a/TP1/TP13.asm b/TP1/TP13.asm new file mode 100644 index 0000000..fee20b6 --- /dev/null +++ b/TP1/TP13.asm @@ -0,0 +1,130 @@ +.equ PINA = 0x00 ; définition des adresses des ports +.equ DDRA = 0x01 +.equ PORTA = 0x02 +.equ PINC = 0x06 +.equ DDRC = 0x07 +.equ PORTC = 0x08 + +.equ RAMEND = 0x21FF +.equ SPH = 0x3E ; initialisation de la pile +.equ SPL = 0x3D + +.def numero = r20 +.def io = r21 +.def test = r19 + +.org 0x000 + ; Vecteur RESET + jmp debut + +.org 0x0080 + +afficheur: + .DB 0x7E, 0x0C, 0x37, 0x9F, 0x4D, 0xDB, 0xFB, 0x0E, 0xFF, 0xDF + ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + +touche: + .DB 0x41, 0x88, 0x48, 0x28, 0x84, 0x44, 0x24, 0x82, 0x42, 0x22 + ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + + +debut: + ldi r16,0xFF ; Port A : 7 segments + out DDRA,r16 + + ldi r16,0x0F ; Port C : Clavier + out DDRC,r16 + + ; numero <- 0 + LDI R16,0 + STS numero,R16 + + +boucle: + ; On lit le bouton + ; test <- 0 + LDI R16,0 + STS test,R16 + +boucleTest: + ; io <- touche@ROM[test] + LDS R16,test + LDI R30,low(touche<<1) + LDI R31,high(touche<<1) + CLR R17 + ADD R30,R16 + ADC R31,R17 + LPM R16,Z + STS io,R16 + + out portc,io + in io,pinc + ; si io = touche@ROM[test] alors numero <- test + LDS R16,io + PUSH R16 + LDS R16,test + LDI R30,low(touche<<1) + LDI R31,high(touche<<1) + CLR R17 + ADD R30,R16 + ADC R31,R17 + LPM R16,Z + POP R17 + CP R17,R16 + BREQ eti0 + CLR R16 + RJMP eti1 +eti0: + LDI R16,0x01 +eti1: + TST R16 + BREQ eti2 + LDS R16,test + STS numero,R16 +eti2: + + inc test + ; si test < 10 saut boucleTest + LDS R16,test + PUSH R16 + LDI R16,10 + POP R17 + CP R17,R16 + BRLO eti3 + CLR R16 + RJMP eti4 +eti3: + LDI R16,0x01 +eti4: + TST R16 + BREQ eti5 + JMP boucleTest +eti5: + + + ; On affiche compteur sur le 7 segments + ; io <- afficheur@ROM[numero] + LDS R16,numero + LDI R30,low(afficheur<<1) + LDI R31,high(afficheur<<1) + CLR R17 + ADD R30,R16 + ADC R31,R17 + LPM R16,Z + STS io,R16 + + out porta,io + + ; On continue + ; saut boucle + JMP boucle + + +tempo: + ldi r24,8 +tempoA: + subi r22,1 + sbci r23,0 + sbci r24,0 + brcc tempoA + ret diff --git a/TP1/TP13.txt b/TP1/TP13.txt new file mode 100644 index 0000000..086f13a --- /dev/null +++ b/TP1/TP13.txt @@ -0,0 +1,65 @@ +.equ PINA = 0x00 ; définition des adresses des ports +.equ DDRA = 0x01 +.equ PORTA = 0x02 +.equ PINC = 0x06 +.equ DDRC = 0x07 +.equ PORTC = 0x08 + +.equ RAMEND = 0x21FF +.equ SPH = 0x3E ; initialisation de la pile +.equ SPL = 0x3D + +.def numero = r20 +.def io = r21 +.def test = r19 + +.org 0x000 + ; Vecteur RESET + jmp debut + +.org 0x0080 + +afficheur: + .DB 0x7E, 0x0C, 0x37, 0x9F, 0x4D, 0xDB, 0xFB, 0x0E, 0xFF, 0xDF + ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + +touche: + .DB 0x41, 0x88, 0x48, 0x28, 0x84, 0x44, 0x24, 0x82, 0x42, 0x22 + ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + + +debut: + ldi r16,0xFF ; Port A : 7 segments + out DDRA,r16 + + ldi r16,0x0F ; Port C : Clavier + out DDRC,r16 + + numero <- 0 + +boucle: + ; On lit le bouton + test <- 0 +boucleTest: + io <- touche@ROM[test] + out portc,io + in io,pinc + si io = touche@ROM[test] alors numero <- test + inc test + si test < 10 saut boucleTest + + ; On affiche compteur sur le 7 segments + io <- afficheur@ROM[numero] + out porta,io + + ; On continue + saut boucle + +tempo: + ldi r24,8 +tempoA: + subi r22,1 + sbci r23,0 + sbci r24,0 + brcc tempoA + ret \ No newline at end of file diff --git a/TP1/TP13debug.asm b/TP1/TP13debug.asm new file mode 100644 index 0000000..d3587cd --- /dev/null +++ b/TP1/TP13debug.asm @@ -0,0 +1,66 @@ +.equ PINA = 0x00 ; définition des adresses des ports +.equ DDRA = 0x01 +.equ PORTA = 0x02 +.equ PINC = 0x06 +.equ DDRC = 0x07 +.equ PORTC = 0x08 + +.equ RAMEND = 0x21FF +.equ SPH = 0x3E ; initialisation de la pile +.equ SPL = 0x3D + +.def io = r21 +.def ib = r19 + +.org 0x000 + ; Vecteur RESET + jmp debut + +.org 0x0080 + +afficheur: + .DB 0x7E, 0x0C, 0x37, 0x9F, 0x4D, 0xDB, 0xFB, 0x0E, 0xFF, 0xDF + ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + +touche: + .DB 0x41, 0x88, 0x48, 0x28, 0x84, 0x44, 0x24, 0x82, 0x42, 0x22 + ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + + +debut: + ldi r16,0xFF ; Port A : 7 segments + out DDRA,r16 + + ldi r16,0x0F ; Port C : Clavier + out DDRC,r16 + +boucle: + call tempo + ; io <- 0x02 + LDI R16,0x02 + STS io,R16 + + out portc,io + call tempo + in io,pinc + call tempo + out porta,io + + ; ib <- 0x00 + LDI R16,0x00 + STS ib,R16 + + out portc,ib + in ib,pinc + ; saut boucle + JMP boucle + + +tempo: + ldi r24,8 +tempoA: + subi r22,1 + sbci r23,0 + sbci r24,0 + brcc tempoA + ret diff --git a/TP1/TP13debug.txt b/TP1/TP13debug.txt new file mode 100644 index 0000000..840cb86 --- /dev/null +++ b/TP1/TP13debug.txt @@ -0,0 +1,58 @@ +.equ PINA = 0x00 ; définition des adresses des ports +.equ DDRA = 0x01 +.equ PORTA = 0x02 +.equ PINC = 0x06 +.equ DDRC = 0x07 +.equ PORTC = 0x08 + +.equ RAMEND = 0x21FF +.equ SPH = 0x3E ; initialisation de la pile +.equ SPL = 0x3D + +.def io = r21 +.def ib = r19 + +.org 0x000 + ; Vecteur RESET + jmp debut + +.org 0x0080 + +afficheur: + .DB 0x7E, 0x0C, 0x37, 0x9F, 0x4D, 0xDB, 0xFB, 0x0E, 0xFF, 0xDF + ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + +touche: + .DB 0x41, 0x88, 0x48, 0x28, 0x84, 0x44, 0x24, 0x82, 0x42, 0x22 + ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + + +debut: + ldi r16,0xFF ; Port A : 7 segments + out DDRA,r16 + + ldi r16,0x0F ; Port C : Clavier + out DDRC,r16 + +boucle: + call tempo + io <- 0x02 + out portc,io + call tempo + in io,pinc + call tempo + out porta,io + + ib <- 0x00 + out portc,ib + in ib,pinc + saut boucle + +tempo: + ldi r24,8 +tempoA: + subi r22,1 + sbci r23,0 + sbci r24,0 + brcc tempoA + ret \ No newline at end of file diff --git a/TP1/TP13prof.txt b/TP1/TP13prof.txt new file mode 100644 index 0000000..5723db3 --- /dev/null +++ b/TP1/TP13prof.txt @@ -0,0 +1,72 @@ +.equ PINA = 0x00 ; définition des adresses des ports +.equ DDRA = 0x01 +.equ PORTA = 0x02 +.equ PINC = 0x06 +.equ DDRC = 0x07 +.equ PORTC = 0x08 + +.equ RAMEND = 0x21FF +.equ SPH = 0x3E ; initialisation de la pile +.equ SPL = 0x3D + +.def numero = r20 +.def io = r21 +.def test = r19 + +.org 0x000 + ; Vecteur RESET + jmp debut + +.org 0x0080 + +afficheur: + .DB 0x7E, 0x0C, 0x37, 0x9F, 0x4D, 0xDB, 0xFB, 0x0E, 0xFF, 0xDF + ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + +touche: + .DB 0x41, 0x88, 0x48, 0x28, 0x84, 0x44, 0x24, 0x82, 0x42, 0x22 + ; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + + +debut: + ldi r16,0xFF ; Port A : 7 segments + out DDRA,r16 + + ldi r16,0x0F ; Port C : Clavier + out DDRC,r16 + + numero <- 0 + +boucle: + ; On lit le bouton + test <- 0 +boucleTest: + io <- touche@ROM[test] + out portc,io + in io,pinc + si io = touche@ROM[test] alors numero <- test + inc test + + io <- touche@ROM[0] + out portc,io + call tempo + in io,pinc + call tempo + + si test < 10 saut boucleTest + + ; On affiche compteur sur le 7 segments + io <- afficheur@ROM[numero] + out porta,io + + ; On continue + saut boucle + +tempo: + ldi r24,8 +tempoA: + subi r22,1 + sbci r23,0 + sbci r24,0 + brcc tempoA + ret \ No newline at end of file