Re: A86: Division in assembly


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

Re: A86: Division in assembly




In a message dated 9/17/97 7:19:08 AM, you wrote:

>ariwsi@juno.com wrote:
>> 
>> On Tue, 16 Sep 1997 15:29:51 -0700 DeComPro@dnc.net (David Buttolph)
>> writes:
>> 
>> >Can someone tell me how to divide in z80 assembly, it's not DIV is it?
>> 
>> The following routine will divide C into HL, storing the quotient
>> in HL and the remainder in A:
>> 
>> Divide:                     ;C = divisor, HL = dividend
>>     XOR     A
>>     LD      B,$10
>> divloop:
>>     ADD     HL,HL
>>     RLA
>>     CP      C
>>     JR      C,too_low
>>     SUB     C
>>     INC     L
>> too_low:
>>     DJNZ    divloop
>>     RET                    ;A = remainder, HL = quotient
>>     ; Cycles = 715 - 763
>
>its simpler to use the OPs because then you can display them more easily
>(thats probably what he wants to do)

The OPs are very easy to display also:

ld		a,$30		;Displays OP1

call	$5191

ld		hl,$C09F

call	_vputs