Re: LZ: Question with programming


[Prev][Next][Index][Thread]

Re: LZ: Question with programming



Michael Wyman wrote:
= 
> There is no multiplication instruction in assembly language.  Your
> instruction mul b, 6 is invalid and will not work.  To do any
> multiplication you must use a routine which shifts the multiplier to the
> right, tests the carry bit.  If the carry bit is set, you add the
> multiplicand to your result (at this point, zero) then shift the
> multiplicand one to the left.  Then you repeat until you are done with your
> eight bits.
>
Thgis is okey if you want to mulytiply to registers, but it is too slow
if you want to multiply a register with an immidiate. To do this add
a shift and add instructions. To multiply hl by ten do the following

add hl,hl ;*2
push hl
add hl,hl ;*4
add hl,hl ;*8
pop de
add hl,de ;*8+*2=*10

This is a lot faster.
-- 
_______________________________________

Dines Justesen
Email: dines@post1.com or
       c958362@student.dtu.dk
WWW  : http://www.gbar.dtu.dk/~c958362/
_______________________________________


References: