I'm trying to find all the prime factors of an inputted number. I was given the following Java code to convert to assembly.

    String getFactors(int number) {
    String answer = "";
    for(int factor=2; factor <= number; factor++) {
        if(number % factor == 0) {
            answer += factor + "*";
            number /= factor;
        return answer.substring(0, answer.length()-1);

My attempt so far:


move.w  #1,D3   
add1        #1,D3
cmp.w       input,factor
BHI     done
divu        factor,input
tst.b       input
BNE     loop1
add.w       factor,answer
move.w  answer,(A1)+
move.b  #’*’,(A1)+
add.w       factor,input
subq        #1,factor
BRA     loop1


Since you don't mention what architecture and assembler you are writing it for, it is hard to judge whether it is correct or not. I am assuming it is for the M68000 processor, correct?