Skip to content

Commit dbb4b78

Browse files
committed
cleaned up code for ineg/inot and added timings
1 parent 9e250a3 commit dbb4b78

File tree

4 files changed

+53
-14
lines changed

4 files changed

+53
-14
lines changed

src/crt/ineg.src

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,40 @@ __ineg := 000160h
99

1010
else
1111

12+
if 1
13+
1214
__ineg:
13-
if 0
14-
push de
15-
end if
15+
; UHL = -UHL
16+
; CC: 10*r(PC)+3*r(SPL)+1
17+
; CC: 9 bytes | 10F + 3R + 1
1618
add hl, de ; uhl=UHL+UDE
1719
ex de, hl ; ude=UHL+UDE, uhl=UDE
1820
or a, a
1921
sbc hl, de ; uhl=UDE-(UHL+UDE)
2022
; =UDE-UHL-UDE
2123
; =-UHL
22-
if 0
23-
pop de
24-
else
2524
ex de, hl ; ude=-UHL, uhl=UHL+UDE
2625
add hl, de ; uhl=UHL+UDE+-UHL
2726
; =UDE
2827
ex de, hl ; ude=UDE, uhl=-UHL
29-
end if
3028
ret
3129

30+
else
31+
32+
__ineg:
33+
; UHL = -UHL
34+
; CC: 9*r(PC)+6*r(SPL)+3*w(SPL)+1
35+
; CC: 8 bytes | 9F + 6R + 3W + 1
36+
push de
37+
add hl, de ; uhl=UHL+UDE
38+
ex de, hl ; ude=UHL+UDE, uhl=UDE
39+
or a, a
40+
sbc hl, de ; uhl=UDE-(UHL+UDE)
41+
; =UDE-UHL-UDE
42+
; =-UHL
43+
pop de
44+
ret
45+
46+
end if
47+
3248
end if

src/crt/ineg_fast.src

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
section .text
44
public __ineg_fast
55
__ineg_fast:
6+
; UHL = -UHL
7+
; CC: 7*r(PC)+3*r(SPL)+1
8+
; CC: 6 bytes | 7F + 3R + 1
69
add hl, de ; uhl=UHL+UDE
710
ex de, hl ; ude=UHL+UDE, uhl=UDE
811
or a, a

src/crt/inot.src

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,45 @@ __inot := 000164h
99

1010
else
1111

12+
if 1
13+
1214
__inot:
13-
if 0
14-
push de
15-
end if
15+
; UHL = ~UHL
16+
; CC: 11*r(PC)+3*r(SPL)+1
17+
; CC: 10 bytes | 11F + 3R + 1
1618
add hl, de ; uhl=UHL+UDE
1719
ex de, hl ; ude=UHL+UDE, uhl=UDE
1820
scf
1921
sbc hl, de ; uhl=UDE-(UHL+UDE)-1
2022
; =UDE-UHL-UDE-1
2123
; =-UHL-1
2224
; =~UHL
23-
if 0
24-
pop de
25-
else
2625
ex de, hl ; ude=~UHL, uhl=UHL+UDE
2726
add hl, de ; uhl=UHL+UDE+~UHL
2827
; =UHL+UDE+(-UHL-1)
2928
; =UHL+UDE-UHL-1
3029
; =UDE-1
3130
inc hl ; uhl=UDE
3231
ex de, hl ; ude=UDE, uhl=~UHL
33-
end if
3432
ret
3533

34+
else
35+
36+
__inot:
37+
; UHL = ~UHL
38+
; CC: 9*r(PC)+6*r(SPL)+3*w(SPL)+1
39+
; CC: 8 bytes | 9F + 6R + 3W + 1
40+
push de
41+
add hl, de ; uhl=UHL+UDE
42+
ex de, hl ; ude=UHL+UDE, uhl=UDE
43+
scf
44+
sbc hl, de ; uhl=UDE-(UHL+UDE)-1
45+
; =UDE-UHL-UDE-1
46+
; =-UHL-1
47+
; =~UHL
48+
pop de
49+
ret
50+
51+
end if
52+
3653
end if

src/crt/inot_fast.src

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
section .text
44
public __inot_fast
55
__inot_fast:
6+
; UHL = ~UHL
7+
; CC: 7*r(PC)+3*r(SPL)+1
8+
; CC: 6 bytes | 7F + 3R + 1
69
add hl, de ; uhl=UHL+UDE
710
ex de, hl ; ude=UHL+UDE, uhl=UDE
811
scf

0 commit comments

Comments
 (0)