Skip to content

Commit d0e0ddc

Browse files
committed
optimized constant loading for ez80_rotate routines
1 parent 859c3c4 commit d0e0ddc

1 file changed

Lines changed: 26 additions & 22 deletions

File tree

src/libc/ez80_builtin.src

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -285,17 +285,20 @@ ___ez80_bitreverse48:
285285
.type ___ez80_rotateleft24, @function
286286
___ez80_rotateleft24:
287287
; unoptimized
288-
ld iy, 0
289-
lea de, iy + 0
290-
add iy, sp
291-
ld hl, (iy + 3)
292-
ld a, (iy + 6)
293-
ld c, 24
288+
ld hl, 6
289+
add hl, sp
290+
ld a, (hl)
291+
dec hl
292+
dec hl
293+
dec hl
294+
ld hl, (hl)
295+
ld de, 24
294296
___ez80_rotateleft24.mod24:
295-
sub a, c
297+
sub a, e
296298
jr nc, ___ez80_rotateleft24.mod24
297-
add a, c
299+
add a, e
298300
ret z
301+
ld e, d ; ld de, 0
299302
ld b, a
300303
___ez80_rotateleft24.loop:
301304
add hl, hl
@@ -312,18 +315,17 @@ ___ez80_rotateleft24.loop:
312315
___ez80_rotateleft48:
313316
; unoptimized
314317
ld iy, 0
315-
lea bc, iy + 0
318+
lea bc, iy + 48 ; ld bc, 48
316319
add iy, sp
317320
ld hl, (iy + 3)
318321
ld de, (iy + 6)
319322
ld a, (iy + 9)
320-
ld c, 48
321323
___ez80_rotateleft48.mod48:
322324
sub a, c
323325
jr nc, ___ez80_rotateleft48.mod48
324326
add a, c
325327
ret z
326-
ld c, 0
328+
ld c, b ; ld bc, 0
327329
___ez80_rotateleft48.loop:
328330
add hl, hl
329331
ex de, hl
@@ -342,18 +344,21 @@ ___ez80_rotateleft48.loop:
342344
.type ___ez80_rotateright24, @function
343345
___ez80_rotateright24:
344346
; unoptimized
345-
ld iy, 0
346-
lea de, iy + 0
347-
add iy, sp
348-
ld hl, (iy + 3)
349-
ld a, (iy + 6)
350-
ld c, 24
347+
ld hl, 6
348+
add hl, sp
349+
ld a, (hl)
350+
dec hl
351+
dec hl
352+
dec hl
353+
ld hl, (hl)
354+
ld de, 24
351355
___ez80_rotateright24.mod24:
352-
sub a, c
356+
sub a, e
353357
jr nc, ___ez80_rotateright24.mod24
354358
neg
355-
cp a, c
359+
cp a, e
356360
ret z
361+
ld e, d ; ld de, 0
357362
ld b, a
358363
___ez80_rotateright24.loop:
359364
add hl, hl
@@ -370,19 +375,18 @@ ___ez80_rotateright24.loop:
370375
___ez80_rotateright48:
371376
; unoptimized
372377
ld iy, 0
373-
lea bc, iy + 0
378+
lea bc, iy + 48 ; ld bc, 48
374379
add iy, sp
375380
ld hl, (iy + 3)
376381
ld de, (iy + 6)
377382
ld a, (iy + 9)
378-
ld c, 48
379383
___ez80_rotateright48.mod48:
380384
sub a, c
381385
jr nc, ___ez80_rotateright48.mod48
382386
neg
383387
cp a, c
384388
ret z
385-
ld c, 0
389+
ld c, b ; ld bc, 0
386390
___ez80_rotateright48.loop:
387391
add hl, hl
388392
ex de, hl

0 commit comments

Comments
 (0)