Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize 24-bit and 32-bit and/or/xor operations #449

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions src/crt/and.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
assume adl=1

section .text
public __land

if PREFER_OS_CRT

__land := 0001A4h

else

__land:
; CC: 28*r(PC)+11*r(SPL)+10*w(SPL)+1
push af
and a, e
ld e, a
; jr __iand.hijack_land
virtual
ld a, 0
load .ld_a: byte from $$
end virtual
db .ld_a ; push af -> ld a,*
require __iand

end if

section .text
public __iand

if PREFER_OS_CRT

__iand := 000134h

else

__iand:
; CC: 24*r(PC)+11*r(SPL)+10*w(SPL)+1
push af
private __iand.hijack_land
.hijack_land:
push hl
scf
sbc hl, hl
add hl, sp
push bc
ld a, (hl)
inc hl
ld sp, hl
inc hl
inc hl
and a, (hl)
ld (hl), a
pop hl
ld a, h
and a, b
ld h, a
ld a, l
and a, c
ld l, a
pop af
ret

end if
40 changes: 40 additions & 0 deletions src/crt/and_fast.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
assume adl=1

section .text
public __land_fast
__land_fast:
; CC: 24*r(PC)+8*r(SPL)+7*w(SPL)+1
and a, e
ld e, a
require __iand_fast

section .text
public __iand_fast
__iand_fast:
; CC: 22*r(PC)+8*r(SPL)+7*w(SPL)+1
push hl
scf
sbc hl, hl
add hl, sp
push bc
ld a, (hl)
inc hl
ld sp, hl
inc hl
inc hl
and a, (hl)
ld (hl), a
pop hl
require __sand_fast

section .text
public __sand_fast
__sand_fast:
; CC: 8*r(PC)+3*r(SPL)+1
ld a, h
and a, b
ld h, a
ld a, l
and a, c
ld l, a
ret
36 changes: 0 additions & 36 deletions src/crt/iand.src

This file was deleted.

25 changes: 0 additions & 25 deletions src/crt/iand_fast.src

This file was deleted.

36 changes: 0 additions & 36 deletions src/crt/ior.src

This file was deleted.

25 changes: 0 additions & 25 deletions src/crt/ior_fast.src

This file was deleted.

36 changes: 0 additions & 36 deletions src/crt/ixor.src

This file was deleted.

25 changes: 0 additions & 25 deletions src/crt/ixor_fast.src

This file was deleted.

38 changes: 0 additions & 38 deletions src/crt/land.src

This file was deleted.

27 changes: 0 additions & 27 deletions src/crt/land_fast.src

This file was deleted.

38 changes: 0 additions & 38 deletions src/crt/lor.src

This file was deleted.

Loading
Loading