Analyse what it does, time the worst case, and assemble it by hand. Analizar qué hace, cronometrar el peor caso y ensamblarla a mano.
Santi Scagliusi, PhD
One input in R12. Half of these are emulated aliases. Una entrada en R12. La mitad son alias emulados.
Is the number of 1-bits in R12 even or odd?¿El número de bits a 1 en R12 es par o impar?
Each 1 that falls into the carry flips R13. Flip an even count of times and you land back on 0. Cada 1 que cae en el carry invierte R13. Invierte un número par de veces y vuelves a 0.
The loop runs until R12 empties, so the lowest 1-bit sets the count. Worst case: a 1 in bit 0, like R12 = 0xFFFF, gives the full 16 passes.El bucle gira hasta vaciar R12, así que el 1 más bajo marca la cuenta. Peor caso: un 1 en el bit 0, como R12 = 0xFFFF, da las 16 vueltas completas.
Every instruction is one word: 8 words · 16 bytes. Cada instrucción ocupa una palabra: 8 palabras · 16 bytes.
Half the program is emulated aliases: clr, rla, tst and ret are MOV, ADD, CMP and a pop in disguise.La mitad del programa son alias emulados: clr, rla, tst y ret son MOV, ADD, CMP y un pop disfrazados.
Timing follows the worst case: the loop runs longest when the lowest bit is 1, so R12 = 0xFFFF takes all 16 passes.El tiempo lo marca el peor caso: el bucle gira más cuando el bit más bajo es 1, así que R12 = 0xFFFF da las 16 vueltas.
A jump offset counts words from the next instruction: +1 forward, −5 backward in two's complement.El offset de un salto cuenta palabras desde la instrucción siguiente: +1 hacia delante, −5 hacia atrás en complemento a 2.