From 2997ffb95ad192bfd424f72440fc0acbf8c7a012 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Fri, 19 May 2017 15:38:28 +0200 Subject: [PATCH] Peut affecter des valeurs à des tableaux (RAM) --- ram.txt | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/gram.txt | 8 ++++++++ 2 files changed, 69 insertions(+), 0 deletions(-) create mode 100644 ram.txt diff --git a/ram.txt b/ram.txt new file mode 100644 index 0000000..adc9f13 --- /dev/null +++ b/ram.txt @@ -0,0 +1,61 @@ +.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 TEST = 0x0200 + +.equ RAMEND = 0x21FF +.equ SPH = 0x3E ; initialisation de la pile +.equ SPL = 0x3D + +.org 0x000 + ; Vecteur RESET + jmp debut + + +.org 0x0080 + + +debut: + DDRA@IO <- 0xFF + DDRC@IO <- 0xFF + PORTC@IO <- 0x00 + PORTA@IO <- 0x00 + r11 <- 0x00 + r10 <- 0x00 + +boucle: + + test[2] <- 0x22 + PORTA@IO <- test[2] + + jmp sl + ; test <- 0x22 + + LDI r16,0xAA + + LDI r26,0x02 + LDI r27,0x00 + + ST X,r16 + + LD r10,X + + ;PORTA@IO <- test[1] + +sl: + sleep + saut sl + +tempo: + ldi r24,8 +tempoA: + subi r22,1 + sbci r23,0 + sbci r24,0 + brcc tempoA + ret + diff --git a/scripts/gram.txt b/scripts/gram.txt index a4d1674..b948f87 100644 --- a/scripts/gram.txt +++ b/scripts/gram.txt @@ -48,6 +48,14 @@ eti{NUM0}: [blanc]* [VariableIO]:var [blanc]* [SymboleAffectation] [blanc]* [Expression]:exp [blanc]* [fin] {exp} OUT {var},R16 +[blanc]* [Tableau]:var [Expression]:ind [blanc]* "]" [blanc]* [SymboleAffectation] [blanc]* [Expression]:exp [blanc]* [fin] +{ind} LDI R26,low({var}) + LDI R27,high({var}) + CLR R17 + ADD R26,R16 + ADC R27,R17 +{exp} ST X,R16 + [blanc]* [Variable]:var [blanc]* [SymboleAffectation] [blanc]* [Expression]:exp [blanc]* [fin] {exp} STS {var},R16 -- libgit2 0.21.2