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

hbios - system ticks #54

Merged
merged 5 commits into from Nov 10, 2019
Merged

hbios - system ticks #54

merged 5 commits into from Nov 10, 2019

Conversation

feilipu
Copy link
Contributor

@feilipu feilipu commented Nov 9, 2019

Relating to #53, an enhancement to get an intrinsic time stamp in seconds.ticks with 50Hz resolution.

Through #53 changes, the INC32HL function is now called twice now in the interrupt, including once per 20ms.

So suggest to change function definition so that HL is not preserved. Checked throughout the repository, and every other call to INC32HL does not require the HL to be preserved, and in fact they all immediately overwrite HL.

OLD

INC32HL: ; minimum impact 88 ticks, total 14 bytes
	PUSH	HL  ; 11 - 1
	PUSH	BC ; 11 - 1
	LD	B,4 ; 7 - 2
INC32HL1:
	INC	(HL) ; 11 - 1
	INC	HL ; 6 - 1
	JR	NZ,INC32HL2 ; 12/7 - 2
	DJNZ	INC32HL1 ; 13/8 - 2
INC32HL2:
	POP	BC ; 10 - 1
	POP	HL ; 10 - 1
	RET ; 10 - 1

NEW

INC32HL: ; minimum impact 22 ticks, total 11 bytes
	INC	(HL) ; 11 - 1
	RET	NZ ; 11/5 - 1
	INC	HL ; 6 - 1
	INC	(HL) ; 11 - 1
	RET	NZ ; 11/5 - 1
	INC	HL ; 6 - 1
	INC	(HL) ; 11 - 1
	RET	NZ ; 11/5 - 1
	INC	HL ; 6 - 1
	INC	(HL) ; 11 - 1
	RET ; 10 - 1

Added a TICKSPERSEC configuration item, to avoid magic numbers appearing in the code.

@wwarthen
Copy link
Owner

Thank you Phillip.

wwarthen pushed a commit that referenced this pull request Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants