I've got a question about using the 6800 emulator to create a program which counts the number of factors of an input variable. The input is stored at the end of the program in the variable n. The output should be stored in a variable called numFactors. Now, i've attempted it, this is what i've done in the quote below.

ldaa n
ldab x
startloop suba numFactors
dec x
bmi stop
bra startloop
n .byte 15
x .byte 1
numFactors .byte 1
stop .end