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

Some optimization with "EX DE, HL \ JP next" #21

Open
redirectme opened this issue Aug 17, 2024 · 0 comments
Open

Some optimization with "EX DE, HL \ JP next" #21

redirectme opened this issue Aug 17, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@redirectme
Copy link

redirectme commented Aug 17, 2024

The system has several combinations

	EX DE, HL 
        JP next

If we denote (e.g., ex_de_hl_next: ) one of them, we can put "JP ex_de_hl_next" instead of the others. This saves 1 byte per combination with no loss of speed.
For example,

over:              
	POP DE     
	PUSH DE    
	PUSH HL    
ex_de_hl_next:     
	EX DE, HL  
	JP next    

And then modify:

minus_rot:                
	POP DE            
	POP AF            
	PUSH HL           
	PUSH AF           
	JP ex_de_hl_next  

Modify other locations in the same way.
In addition, we can aslo put another label:

over:              
	POP DE     
	PUSH DE
dup_ex_de_hl_next:         
	PUSH HL    
ex_de_hl_next:     
	EX DE, HL  
	JP next    

Then replace the combination

        PUSH HL
	EX DE, HL 
        JP next

by "JP dup_ex_de_hl_next"

For example,

rot:                    
	POP AF          
	POP DE          
	PUSH AF         
	JP dup_ex_de_hl_next

There are other places for JP dup_ex_de_hl_next. This saves 2 bytes without losing speed.

Added: I guess I'm wrong about same speed. Certainly "JP ex_de_hl_next" is a bit slower than the original code.

@Veltas Veltas added the enhancement New feature or request label Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants