Skip to content

Commit

Permalink
Implement enough junk for my long long test program to link
Browse files Browse the repository at this point in the history
  • Loading branch information
runer112 committed Jun 4, 2021
1 parent dfa34fd commit c5ca508
Show file tree
Hide file tree
Showing 13 changed files with 448 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/std/linked/linked.src
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ __ixor := 000198h
__ladd := 00019Ch
public __land
__land := 0001A4h
public __lcmps
__lcmps := 0001A8h
public __lcmpu
__lcmpu := 0001ACh
public __lcmpzero
__lcmpzero := 0001B0h
public __lmuls
Expand Down
12 changes: 12 additions & 0 deletions src/std/shared/lcmps_fast.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public __lcmps_fast
__lcmps_fast:
ld d, a
ld a, e
sub a, d
ret nz
sbc hl, bc
ret z
sbc a, a
ret nz
inc a
ret
8 changes: 8 additions & 0 deletions src/std/shared/lcmpu_fast.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
public __lcmpu_fast
__lcmpu_fast:
sub a, e
ccf
ret nz
or a, a
sbc hl, bc
ret
53 changes: 53 additions & 0 deletions src/std/shared/llcmpu.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
public __llcmpu
__llcmpu:
if 0
ld iy, 0
add iy, sp
ld a, b
sub a, (iy + 10)
ret nz
ld a, c
sub a, (iy + 9)
ret nz
ex de, hl
ld bc, (iy + 6)
sbc hl, bc
ret nz
ex de, hl
ld bc, (iy + 3)
sbc hl, bc
ret
else
ld a, c
ld iyh, b
pop bc
or a, a
sbc hl, bc
ex de, hl
pop bc
pop de
jr nz, .ne24
sbc hl, bc
jr nz, .ne48
sbc a, e
jr nz, .ne56
ld a, iyh
sbc a, d
ld hl, 9
add hl, sp
ld sp, hl
ret
.ne24:
sbc hl, bc
.ne48:
sbc a, e
.ne56:
ld a, iyh
sbc a, d
ld hl, 9
add hl, sp
ld sp, hl
ret nz
inc a
ret
end if
53 changes: 53 additions & 0 deletions src/std/shared/llcmpu_fast.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
public __llcmpu_fast
__llcmpu_fast:
if 1
ld iy, 0
add iy, sp
ld a, b
sub a, (iy + 10)
ret nz
ld a, c
sub a, (iy + 9)
ret nz
ex de, hl
ld bc, (iy + 6)
sbc hl, bc
ret nz
ex de, hl
ld bc, (iy + 3)
sbc hl, bc
ret
else
ld a, c
ld iyh, b
pop bc
or a, a
sbc hl, bc
ex de, hl
pop bc
pop de
jr nz, .ne24
sbc hl, bc
jr nz, .ne48
sbc a, e
jr nz, .ne56
ld a, iyh
sbc a, d
ld hl, 9
add hl, sp
ld sp, hl
ret
.ne24:
sbc hl, bc
.ne48:
sbc a, e
.ne56:
ld a, iyh
sbc a, d
ld hl, 9
add hl, sp
ld sp, hl
ret nz
inc a
ret
end if
27 changes: 27 additions & 0 deletions src/std/shared/lldivu_b_fast.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
public __lldivu
__lldivu:
public __lldivu_b_fast
__lldivu_b_fast:
; Not well-optimized
ld iy, 0
add iy, sp
ld iy, (iy + 3)
ld iyh, 64
.loop:
adc hl, hl
ex de, hl
adc hl, hl
ex de, hl
rl c
rl b
rla
jr c, .1
cp a, iyl
jr nc, .0
.1:
sub a, iyl
inc l
.0:
dec iyh
jr nz, .loop
ret
63 changes: 63 additions & 0 deletions src/std/shared/llmulu_b_fast.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
public __llmulu
__llmulu:
public __llmulu_b_fast
__llmulu_b_fast:
ld iy, 0
add iy, sp
push de
push hl
ld a, (iy + 3)
ld h, a
mlt hl
ld (iy - 6), l
ld d, a
ld e, (iy - 5)
mlt de
ld l, h
ld h, 0
add hl, de
ld (iy - 5), l
ld d, a
ld e, (iy - 4)
mlt de
ld l, h
ld h, 0
add hl, de
ld (iy - 4), l
ld d, a
ld e, (iy - 3)
mlt de
ld l, h
ld h, 0
add hl, de
ld (iy - 3), l
ld d, a
ld e, (iy - 2)
mlt de
ld l, h
ld h, 0
add hl, de
ld (iy - 2), l
ld d, a
ld e, (iy - 1)
mlt de
ld l, h
ld h, 0
add hl, de
ld (iy - 1), l
ld d, a
ld e, c
mlt de
ld l, h
ld h, 0
add hl, de
ld c, l
ld d, a
ld e, b
mlt de
ld a, h
add a, e
ld b, a
pop hl
pop de
ret
31 changes: 31 additions & 0 deletions src/std/shared/llshrs.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
public __llshrs
__llshrs:
; Not well-optimized, but it probably works
push iy
ld iy, 0
add iy, sp
push af
ld a, c
ld c, b
ld b, (iy + 6)
inc b
dec b
jr z, .finish
push de
push hl
.loop:
sra c
rra
rr (iy - 1)
rr d
rr e
rr (iy - 4)
rr h
rr l
djnz .loop
ld b, c
ld c, a
.finish:
pop af
pop iy
ret
Loading

0 comments on commit c5ca508

Please sign in to comment.