Inspired by the VDC questions lately, I've hacked in a small routine which multiplies the value of A by 80 decimal. The version following below uses exactly 32 bytes.
I know that a table lookup would be faster, but it consumes n times 2 bytes memory (50 bytes for a 25line lookup), aswell as n times add 80d to the result in a loop would be shorter, but definitely slower.
Anyone who can explain "how does this multiply with right-shifts = division by 2 ?" receives a rep.-point
;ZP-adresses used
ResLo = $FC
ResHi = $FD
;on entry A is the multiplicator, the result is returned in ResLo = lo byte and ResHi = hi byte (ResHi also in A on return)
;X and Y are used to hold intermediate results
Mul80:
ldx #$00
stx ResLo
lsr
ror ResLo
lsr
ror ResLo
ldy ResLo
sta ResHi
lsr
ror ResLo
lsr
ror ResLo
tax
tya
adc ResLo
sta ResLo
txa
adc ResHi
sta ResHi
RTS
I know that a table lookup would be faster, but it consumes n times 2 bytes memory (50 bytes for a 25line lookup), aswell as n times add 80d to the result in a loop would be shorter, but definitely slower.
Anyone who can explain "how does this multiply with right-shifts = division by 2 ?" receives a rep.-point

;ZP-adresses used
ResLo = $FC
ResHi = $FD
;on entry A is the multiplicator, the result is returned in ResLo = lo byte and ResHi = hi byte (ResHi also in A on return)
;X and Y are used to hold intermediate results
Mul80:
ldx #$00
stx ResLo
lsr
ror ResLo
lsr
ror ResLo
ldy ResLo
sta ResHi
lsr
ror ResLo
lsr
ror ResLo
tax
tya
adc ResLo
sta ResLo
txa
adc ResHi
sta ResHi
RTS