-
-
Notifications
You must be signed in to change notification settings - Fork 66
Opt libload 2 #690
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
base: master
Are you sure you want to change the base?
Opt libload 2 #690
Conversation
699623e to
e84c64a
Compare
|
The flags are changed, are they not? That's what the push af is for. Just need some more proof |
| pop af | ||
| pop hl | ||
| jr nz, .loop | ||
|
|
||
| .not_loaded: | ||
| ld hl, (lib_name_ptr) | ||
| move_string_to_end | ||
| push hl ; save the location in the program we are on | ||
| findlib: | ||
| call ti.ChkFindSym |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here push af \ pop af was removed. call ti.CpHLDE was only used to check if HL == DE, so we only need to preserve the Z flag for the jr nz, .loop branch:
- When
jr nz, .loopis taken: All flags are destroyed bycp a, (hl). - When
jr nz, .loopis not taken:move_string_to_end(which usescpir) destroys Z, P, and V. The Carry flag is unused and destroyed bycall ti.ChkFindSym
Therefore, it is safe to remove push af \ pop af as we only need the Z flag for jr nz, .loop
Proof for the
push af \ add hl, 15 \ pop afstuff:#648 (comment)