Include 'M64DEF.INC'
ORG 0X0000
JMP main
ORG 0X0050
main:
LDI R26,0X00
LDI R27,0X10
LDI R28,0X00
LDI R29,0X30
LDI R16,2
SEI

LOOP:
LD R20,X+
MOV R21,R20
MOV R22,R20
MOV R23,R20
CPI R26,0X26
BREQ FINISH

CHECK2:
SUBI R21,2
BREQ DIVISIBLE
BRCS CHECK3
JMP  CHECK2

CHECK3:
SUBI R22,3
BREQ DIVISIBLE
BRCS CHECK5
JMP  CHECK3

CHECK5:
SUBI R23,5
BREQ DIVISIBLE
BRCS LOOP
JMP  CHECK5

DIVISIBLE:
MUL R20,R16
ST  Y+,R0
ST  Y+,R1
JMP LOOP

FINISH: 
JMP FINISH



