Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; --------------------------------------------------------------
- ; -- Memory layout in SRAM
- .dseg
- .org SRAM_START
- HIGHSCORE:
- .byte 1
- MULT_SCORE:
- .byte 1
- .cseg
- INIT:
- ldi r16,HIGH(RAMEND)
- out SPH,r16
- ldi r16,LOW(RAMEND)
- out SPL,r16
- clr r16
- out DDRD,r16
- sts MULT_SCORE,r16
- sts HIGHSCORE,r16
- FIND_HIT:
- sbic PIND,0
- rjmp HIT
- rjmp NO_HIT
- NO_HIT:
- clr r16
- sts MULT_SCORE,r16 // Nollställ så att vi bara får 1 poäng
- rjmp FIND_HIT
- HIT:
- lds r16,MULT_SCORE // Hur många i rad?
- inc r16
- sts MULT_SCORE,r16
- HITX:
- lds r16,MULT_SCORE
- cpi r16,10
- brsh HIT_THREE_TIMES // Har vi minst 10 träffar i rad?
- cpi r16,5
- brsh HIT_TWO_TIMES // Har vi minst 5 träffar i rad?
- ldi r17,1
- rjmp LOOP
- HIT_THREE_TIMES:
- ldi r17,3
- rjmp LOOP
- HIT_TWO_TIMES:
- ldi r17,2
- rjmp LOOP
- LOOP:
- lds r16,HIGHSCORE
- LOOPA: //Öka på Highscore beroende på hur många träffar vi har i rad
- inc r16
- dec r17
- brne LOOPA
- STORE_HIGHSCORE:
- sts HIGHSCORE,r16
- call PRINT
- rjmp FIND_HIT
- PRINT:
- lds r16,HIGHSCORE
- ret // Här ska den liveprinta skärmen
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement