Skip to content
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
16 changes: 8 additions & 8 deletions src/libc/ceilf.src
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@

_ceil:
_ceilf:
call __frameset0
ld bc, (ix+6)
ld a, (ix+9)
ld hl, 6
add hl, sp
ld a, (hl)
dec hl
dec hl
dec hl
ld bc, (hl)
call __fneg
ld l, a
ld h, 0
push hl
push bc
call _floor
pop bc
pop bc
push hl
ex (sp), hl
pop bc
ld a, e
call __fneg
ld e, a
push bc
pop hl
pop ix
ret

.extern __frameset0
.extern __fneg
.extern _floor

Expand Down
12 changes: 7 additions & 5 deletions src/libc/cimagf.src
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
; float cimagf(float _Complex)
_cimagf:
_cimag:
ld iy, 0
add iy, sp
ld sp, iy
ld hl, (iy + 7)
ld e, (iy + 10)
ld hl, 10
add hl, sp
ld e, (hl)
dec hl
dec hl
dec hl
ld hl, (hl)
ret
1 change: 0 additions & 1 deletion src/libc/cimagl.src
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
_cimagl:
ld iy, 0
add iy, sp
ld sp, iy
ld hl, (iy + 11)
ld de, (iy + 14)
ld bc, (iy + 17)
Expand Down
48 changes: 26 additions & 22 deletions src/libc/ez80_builtin.src
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,20 @@ ___ez80_bitreverse48:
.type ___ez80_rotateleft24, @function
___ez80_rotateleft24:
; unoptimized
ld iy, 0
lea de, iy + 0
add iy, sp
ld hl, (iy + 3)
ld a, (iy + 6)
ld c, 24
ld hl, 6
add hl, sp
ld a, (hl)
dec hl
dec hl
dec hl
ld hl, (hl)
ld de, 24
___ez80_rotateleft24.mod24:
sub a, c
sub a, e
jr nc, ___ez80_rotateleft24.mod24
add a, c
add a, e
ret z
ld e, d ; ld de, 0
ld b, a
___ez80_rotateleft24.loop:
add hl, hl
Expand All @@ -312,18 +315,17 @@ ___ez80_rotateleft24.loop:
___ez80_rotateleft48:
; unoptimized
ld iy, 0
lea bc, iy + 0
lea bc, iy + 48 ; ld bc, 48
add iy, sp
ld hl, (iy + 3)
ld de, (iy + 6)
ld a, (iy + 9)
ld c, 48
___ez80_rotateleft48.mod48:
sub a, c
jr nc, ___ez80_rotateleft48.mod48
add a, c
ret z
ld c, 0
ld c, b ; ld bc, 0
___ez80_rotateleft48.loop:
add hl, hl
ex de, hl
Expand All @@ -342,18 +344,21 @@ ___ez80_rotateleft48.loop:
.type ___ez80_rotateright24, @function
___ez80_rotateright24:
; unoptimized
ld iy, 0
lea de, iy + 0
add iy, sp
ld hl, (iy + 3)
ld a, (iy + 6)
ld c, 24
ld hl, 6
add hl, sp
ld a, (hl)
dec hl
dec hl
dec hl
ld hl, (hl)
ld de, 24
___ez80_rotateright24.mod24:
sub a, c
sub a, e
jr nc, ___ez80_rotateright24.mod24
neg
cp a, c
cp a, e
ret z
ld e, d ; ld de, 0
ld b, a
___ez80_rotateright24.loop:
add hl, hl
Expand All @@ -370,19 +375,18 @@ ___ez80_rotateright24.loop:
___ez80_rotateright48:
; unoptimized
ld iy, 0
lea bc, iy + 0
lea bc, iy + 48 ; ld bc, 48
add iy, sp
ld hl, (iy + 3)
ld de, (iy + 6)
ld a, (iy + 9)
ld c, 48
___ez80_rotateright48.mod48:
sub a, c
jr nc, ___ez80_rotateright48.mod48
neg
cp a, c
ret z
ld c, 0
ld c, b ; ld bc, 0
___ez80_rotateright48.loop:
add hl, hl
ex de, hl
Expand Down
7 changes: 3 additions & 4 deletions src/libc/strrstr.src
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ _strrstr:
ld bc, 0
cpir
sbc hl, hl
dec hl
sbc hl, bc ; carry will be cleared
scf
sbc hl, bc ; carry will be set
ex (sp), hl ; strlen(needle)
push hl ; needle

ex de, hl
push hl
ld bc, 0
ld bc, -1
cpir
sbc hl, hl
dec hl
sbc hl, bc
ex (sp), hl ; strlen(haystack)
push hl ; haystack
Expand Down
7 changes: 3 additions & 4 deletions src/libc/strstr.src
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ _strstr:
ld bc, 0
cpir
sbc hl, hl
dec hl
sbc hl, bc ; carry will be cleared
scf
sbc hl, bc ; carry will be set
ex (sp), hl ; strlen(needle)
push hl ; needle

ex de, hl
push hl
ld bc, 0
ld bc, -1
cpir
sbc hl, hl
dec hl
sbc hl, bc
ex (sp), hl ; strlen(haystack)
push hl ; haystack
Expand Down
11 changes: 5 additions & 6 deletions src/libc/wcsnlen.src
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,16 @@ _wcsnlen:
cp a, c ; cp a, 0
ret nz ; high byte was non-zero
dec hl
; ret ; We can use the RET PO below since overflow won't be set
.L.loop_lo:
ret po
.L.loop_hi:
ret

.L.loop:
inc hl
.L.loop_start:
cpi
jr nz, .L.loop_lo
ret po
jr nz, .L.loop
cp a, (hl)
jr nz, .L.loop_hi
jr nz, .L.loop
ex de, hl
pop de ; reset SP
scf
Expand Down
26 changes: 8 additions & 18 deletions src/srldrvce/srldrvce.asm
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,7 @@ srl_GetCDCStandardDescriptors:
jq nz,.noserial

ld a,3
ld hl,.device+deviceDescriptor.iSerialNumber
ld (hl),a
ld (.device+deviceDescriptor.iSerialNumber),a

ld de,.stringserialnum + 2
ld hl,ti.OP4
Expand All @@ -550,9 +549,7 @@ srl_GetCDCStandardDescriptors:
jq c,.store
add a,'A'-'9'-1
.store:
ex de,hl
ld (hl),a
ex de,hl
ld (de),a
inc de
inc de
ret
Expand Down Expand Up @@ -615,15 +612,12 @@ srl_UsbEventCallback:
push de
push de
call usb_FindDevice
pop de
pop de
pop de
ld sp, ix
Comment thread
adriweb marked this conversation as resolved.
ld de, 0
push de
push hl
call usb_GetDeviceEndpoint
pop de
pop de
ld sp, ix
Comment thread
adriweb marked this conversation as resolved.
ld de, 0
push de
push de
Expand All @@ -634,11 +628,7 @@ srl_UsbEventCallback:
push hl
call usb_ScheduleControlTransfer
ld bc, 1
pop hl
pop hl
pop hl
pop hl
pop hl
ld sp, ix
.BB0_5:
push bc
pop hl
Expand Down Expand Up @@ -668,7 +658,7 @@ get_device_type:
call next_descriptor
inc hl
inc hl
ld de,0
inc.s de ; clear UDE
ld e,(hl) ; total descriptor length
inc hl
ld d,(hl)
Expand Down Expand Up @@ -828,7 +818,7 @@ set_rate_cdc:
ld (.linecoding),hl
ld bc,0
push bc ; transferred
ld bc,50
ld c,50 ; ld bc, 50
push bc ; num retries
ld bc,.linecoding
push bc ; data
Expand Down Expand Up @@ -984,8 +974,8 @@ ring_buf_push:
sbc hl,hl ; check if bc is 0
adc hl,bc
ret z
ld hl,(xring_buf_ctrl.data_end)
ex de,hl ; hl = data
ld de,(xring_buf_ctrl.data_end)
push bc
ldir ; de = data_end + len
ld (xring_buf_ctrl.data_end),de
Expand Down
4 changes: 2 additions & 2 deletions src/usbdrvce/usbdrvce.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2952,8 +2952,8 @@ assert endpointDescriptor.wMaxPacketSize+2 = endpointDescriptor.bInterval
inc hl
ld b,(hl)
inc b
djnz .validInterval
jq .invalidParam
dec b
jq z, .invalidParam
.validInterval:
ex de,hl
inc.s hl
Expand Down
Loading