Skip to content

Optimize loading constants #47

Description

@ZERICO2005
	ld	de, (ix - 30)
	ld	hl, (ix + 12)
	ld	iy, 12
	lea	bc, iy + 0
	ldir
	ld	de, (ix + 12)
	ld	iy, (ix - 27)
	lea	hl, iy + 0
	ld	bc, 12 ; can be changed to ld c, 12
	ldir
	lea	de, iy + 0
	ld	hl, (ix - 30)
	ld	bc, 12 ; can be changed to ld c, 12
	ldir

LDIR sets BC to 0, so the compiler can use this information to change ld bc, 12 to ld c, 12

	ld	hl, (ix + 21)
	ld	iy, 12
	lea	bc, iy + 0
	ldir
	ld	de, (ix + 21)
	ld	hl, (ix + 15)
	lea	bc, iy + 0 ; can be changed to ld c, 12
	ldir
	ld	de, (ix + 15)
	ld	hl, (ix - 33)
	lea	bc, iy + 0 ; can be changed to ld c, 12
	ldir

Similar thing here

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    missed optimizationMissed optimizations generate correct (no bugs) but not optimal code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions