Last active
September 13, 2019 19:24
-
-
Save gayapedro/6324a37b510c1fb4534a8abd09fbf781 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .ORG 0x0000 | |
| RJMP main | |
| main: | |
| LDI r16,0b11111101 | |
| OUT DDRD,r16 ;CONFIGURA PD0 COMO SAÍDA (LED) E PD1 COMO ENTRADA (BOTÃO) | |
| LDI r16,0b11111100 | |
| OUT PortD,r16 ;INICIALIZA O LED COMO INICIALMENTE DESLIGADO | |
| NOP | |
| loop: | |
| SBIS PinD,PD1 ;SE O PD1 RECEBER CORRENTE (BOTÃO PRESSIONADO), PULA A PRÓXIMA INSTRUÇÃO | |
| RJMP loop | |
| soltar: | |
| SBIC PinD,PD1 ;SE O PD1 NÃO RECEBER CORRENTE (BOTÃO SOLTO), PULA A PRÓXIMA INSTRUÇÃO | |
| RJMP soltar ;SE NÃO, VOLTA AO SOLTAR | |
| RCALL atraso | |
| SBIC PortD,PD0 ;SE O PD0 NÃO RECEBER CORRENTE (LED APAGADO), PULA A PRÓXIMA INSTRUÇÃO | |
| RJMP desliga ;SE NÃO, CHAMA ROTINA PARA DESLIGAR O LED | |
| SBI PortD,PD0 ;LIGA LED | |
| RJMP loop | |
| desliga: | |
| CBI PortD,PD0 ;DESLIGA LED | |
| RJMP loop | |
| atraso: | |
| LDI r16,16 | |
| delay: | |
| DEC r3 | |
| BRNE delay | |
| DEC r4 | |
| BRNE delay | |
| DEC r16 | |
| BRNE delay | |
| RET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment