Date : Fri, 20 Nov 2009 22:48:40 +0100
From : rick@... (Rick Murray)
Subject: Quine
Mick Champion wrote:
> CLC
> LDA byte1
> LDX #0
> .loop
> ADC byte1
> STA byte1
> BCC a
> INC byte2
> .a
> INX
> CPX#4
> BNE loop
Am I thick or do I not see what you are multiplying BY?
Are you trying 'byte1' times four? (LDX #0 --> CPX #4)?
As 4 is a power of two, a bit of shifting would prob. do that in less
code/cycles, though for a more flexible multiplier you'll want to use
variables in both cases.
If it is for a fixed sum in a program:
If the number is a power of two, shift it. Like 'n' times 8.
If the number isn't, cheat.
Want to multiply by nine? It will probably quicker to shift to
multiply by eight, and then add another, thus *9!
I Googled this for you:
http://www.cyberroach.com/analog/an19/boot_camp.htm
Might help explain?
There's another cheat you can use. Count DOWN in your loop, not up. When
you hit zero, the Z flag will be set so you can BNE loop (until zero...)
disposing of the need to CMP.
Best wishes,
Rick.
--
Rick Murray, eeePC901 & ADSL WiFI'd into it, all ETLAs!
BBC B: DNFS, 2 x 5.25" floppies, EPROM prog, Acorn TTX
E01S FileStore, A3000/A5000/RiscPC/various PCs/blahblah...
>> TO PRIVATE MAIL ME, REMOVE [BBC-Micro] FROM SUBJECT <<