Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Pretende-se controlar o estados leds D1...D8 utilizando para isso os interruptores SW. O estados dos leds deve obedecer à seguinte tabela:
- ; Interruptor Activo | Leds Ligados
- ; SW1 | D1, D8
- ; SW2 | D2, D7
- ; SW3 | D3, D6
- ; SW4 | D4, D5
- ; SW6 | LEDs desligados
- .include<m128def.inc>
- .cseg
- .org 0
- jmp main
- main:
- ; saida
- ser r16
- out DDRA, r16
- ser r16
- out PORTA,r16
- ; entrada
- clr r16
- out DDRE, r16
- clr r16
- out PORTE,r16
- test:
- in r17,PINE
- mov r16, r17
- andi r16, 0x01; 0b00000001
- breq sw10
- mov r16, r17
- andi r16, 0x02; 0b00000010
- breq sw20
- mov r16, r17
- andi r16, 0x04; 0b00000100
- breq sw30
- mov r16, r17
- andi r16, 0x08; 0b00001000
- breq sw40
- mov r16, r17
- andi r16, 0x10; 0b00010000
- breq sw50
- mov r16, r17
- andi r16, 0x20; 0b00100000
- breq sw60
- jmp test
- sw10:
- ldi r16, 0x7E; 0b01111110
- out PORTA, r16
- jmp test
- sw20:
- ldi r16, 0xBD; 0b10111101
- out PORTA, r16
- jmp test
- sw30:
- ldi r16, 0xDB; 0b11011011
- out PORTA, r16
- jmp test
- sw40:
- ldi r16, 0xE7; 0b11100111
- out PORTA, r16
- jmp test
- sw50:
- ldi r16, 0x42; 0b01000010
- out PORTA, r16
- jmp test
- sw60:
- ldi r16, 0xFF; 0b11111111
- out PORTA, r16
- jmp test
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement