File tree 3 files changed +330
-74
lines changed
test/floating_point/float64_arithmetic/src
3 files changed +330
-74
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 4
4
5
5
public __dcmp
6
6
7
- ; int _dcmp_c(f64_cmp_arg const *__restrict const arg)
8
7
__dcmp:
9
- ; f64_cmp_arg*_ret_i24
10
- push bc, de, hl
11
- or a, a
12
- sbc hl, hl
13
- add hl, sp
14
- push iy, af
15
- push hl ; f64_cmp_arg*
16
- call __dcmp_c
17
- pop af
18
- pop af, iy
19
- ; Set the comparison flags
20
- add hl, de
21
- or a, a
22
- sbc hl, de
23
- pop hl, de, bc
8
+ push iy
9
+ ld iy, 0
10
+ add iy, sp
11
+ push bc
12
+ push hl
13
+ ld hl, (iy + 12) ; y.hi
14
+ rlc b
15
+ sla h ; Carry = signbit y
16
+ bit 0, b ; signbit x
17
+ jr z, .positve_x
18
+ ccf
19
+ .positve_x:
20
+ res 0, b
21
+ ; H and B now have their signbits cleared
22
+ jr c, .different_sign
23
+ ; same_sign
24
+ sbc.s hl, bc ; y.hi - x.hi
25
+ jr nz, .not_equal
26
+ ld hl, (iy + 9) ; y.md
27
+ sbc hl, de ; y.md - x.md
28
+ jr nz, .not_equal
29
+ ld bc, (iy - 6) ; x.lo
30
+ ld hl, (iy + 6) ; y.lo
31
+ sbc hl, bc ; y.lo - x.lo
32
+ jr z, .equal
33
+ .not_equal:
34
+ ld l, a ; preserve A
35
+ rra ; bit 7 of A = Carry
36
+ cpl
37
+ .ret_flags:
38
+ xor a, (iy - 2) ; bit 7 of B = sign of x
39
+ rla
40
+ sbc a, a ; A is 0 or -1
41
+ ccf ; carry is set when A is 0, so A will be 1 or -1 in the end
42
+ adc a, e
43
+ sub a, e
44
+ ld a, l ; restore A
45
+ .equal:
46
+ .finish_zero:
47
+ pop hl
48
+ pop bc
49
+ pop iy
24
50
ret
25
51
26
- extern __dcmp_c
52
+ .different_sign:
53
+ ; test for zero
54
+ ; x[hi-md-lo]
55
+ ; y[hi-md-lo]
56
+ add.s hl, bc
57
+ adc hl, de
58
+ jr nz, .non_zero ; path taken by normal, inf, and NaN
59
+ jr c, .non_zero
60
+ ; both x and y are subnormal or zero
61
+ ; x[00-00-lo]
62
+ ; y[00-md-lo]
63
+ ; HL is zero, Carry is reset
64
+ ld hl, (iy + 6) ; y.lo
65
+ ld bc, (iy + 9) ; y.md
66
+ add hl, bc
67
+ ld bc, (iy - 6) ; x.lo
68
+ adc hl, bc
69
+ jr nz, .non_zero
70
+ jr nc, .finish_zero ; Z, NC, and P
71
+ .non_zero:
72
+ ld l, a ; preserve A
73
+ xor a, a
74
+ jr .ret_flags
You can’t perform that action at this time.
0 commit comments