Include 'M64DEF.INC'
ORG 0X0000
JMP main
ORG 0X0004
JMP EXT_INT1_ISR
ORG 0X0006
JMP EXT_INT2_ISR
ORG 0X0010
JMP EXT_INT7_ISR
ORG 0X0050
main:
LDI R16,low(RAMEND)
OUT SPL,R16
LDI R16,high(RAMEND)
OUT SPH,R16
LDI R16,0X2C
OUT EICRA,R16 
LDI R16,0X40
OUT EICRB,R16
LDI R16,0X86
OUT EIMSK, R16
LDI R16,0X00
OUT DDRA,R16
OUT DDRB,R16
LDI R16,0X0FF
OUT DDRC,R16
OUT DDRD,R16
LDI R20,0 ;a=0
LDI R21,2 ;b=2
SEI

main_loop:
IN R23,PINA
IN R24,PINB
MUL R23,R20 ;aA
OUT PORTC,R0
MUL R24,R21 ;bB
MOV R25,R0
OUT PORTD,R0
JMP main_loop

EXT_INT1_ISR:
MOV R20,R23
RETI


EXT_INT2_ISR:
MOV R21,R25
RETI

EXT_INT7_ISR:
LDI R20,0
LDI R21,2
RETI