summaryrefslogtreecommitdiff
path: root/frontends/calculator/CEdev/lib/shared/bdivs.src
blob: 710ad7e95b55d9b27a7cfa0e17046b51fcefcac9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
; (c) Copyright 2001-2008 Zilog Inc.
;-------------------------------------------------------------------------
; Signed Byte Division. 
; Input:
;	Operand1: 
;		  B : 8 bit dividend (numerator)
;
;	Operand2: 
;		  C : 8 bit divisor (denominator)
;
; Output:
;	Result:   A : 8 bit quotient
; Registers Used:
;	d, e
;-------------------------------------------------------------------------
	.ref __bdivu
	.def __bdivs
	.assume adl=1

__bdivs:
	push	bc
	xor	a,a
	sub	a,b
	jp	m,_L0
	ld	b,a
_L0:
	xor	a,a
	sub	a,c
	jp	m,_L1
	ld	c,a
_L1:
	call	__bdivu
	pop	bc
	push	hl
	ld	l,a
	ld	a,b
	xor	a,c
	ld	a,l
	jp	p,_L2
	neg
_L2:
	pop	hl
	ret