Open
Conversation
ZERICO2005
commented
Oct 8, 2025
4cf7c54 to
0853c6b
Compare
0853c6b to
ef700af
Compare
ef700af to
6167e0a
Compare
Contributor
Author
|
I just converted this branch/PR from FASMG to GAS. So it would be helpful to know if I did it right |
e175d6f to
3c037c7
Compare
3c037c7 to
cfc924c
Compare
calc84maniac
reviewed
Apr 1, 2026
Comment on lines
+16
to
+24
| push hl | ||
| lea hl, iy + 0 | ||
| add hl, hl | ||
| sbc a, a | ||
|
|
||
| ld hl, $800000 | ||
| add hl, de | ||
| pop hl | ||
| rla |
Contributor
There was a problem hiding this comment.
You can save 2F using this, which reverses the bits rotated into A but that can be solved by using or a, a \ call m for the first subtract instead of rrca \ call c
Suggested change
| push hl | |
| lea hl, iy + 0 | |
| add hl, hl | |
| sbc a, a | |
| ld hl, $800000 | |
| add hl, de | |
| pop hl | |
| rla | |
| push de | |
| ex de, hl | |
| add hl, hl | |
| sbc a, a | |
| lea hl, iy + 0 | |
| add hl, hl | |
| rla | |
| ex de, hl | |
| pop de |
calc84maniac
reviewed
Apr 1, 2026
Comment on lines
+9
to
+28
| __smulhs: | ||
| push bc | ||
| push hl | ||
| call __smulhu | ||
|
|
||
| ; if (BC < 0) { result -= HL; } | ||
| bit 7, b | ||
| pop bc | ||
| jr z, .L.positive_hl | ||
| or a, a | ||
| sbc hl, bc | ||
| .L.positive_hl: | ||
|
|
||
| ; if (HL < 0) { result -= BC; } | ||
| bit 7, b | ||
| pop bc | ||
| ret z | ||
| or a, a | ||
| sbc hl, bc | ||
| ret |
Contributor
There was a problem hiding this comment.
This saves 3R+3W on the stack:
Suggested change
| __smulhs: | |
| push bc | |
| push hl | |
| call __smulhu | |
| ; if (BC < 0) { result -= HL; } | |
| bit 7, b | |
| pop bc | |
| jr z, .L.positive_hl | |
| or a, a | |
| sbc hl, bc | |
| .L.positive_hl: | |
| ; if (HL < 0) { result -= BC; } | |
| bit 7, b | |
| pop bc | |
| ret z | |
| or a, a | |
| sbc hl, bc | |
| ret | |
| __smulhs: | |
| push de | |
| ld d, h | |
| ld e, l | |
| call __smulhu | |
| ; if (BC < 0) { result -= HL; } | |
| bit 7, b | |
| jr z, .L.positive_hl | |
| or a, a | |
| sbc hl, de | |
| .L.positive_hl: | |
| ; if (HL < 0) { result -= BC; } | |
| bit 7, d | |
| pop de | |
| ret z | |
| or a, a | |
| sbc hl, bc | |
| ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added multiply high signed/unsigned routines. These can be used to optimize division by a constant.
__smulhuis optimized, but the rest are not well optimized. They use the exact same calling convention as the regular multiplication routines. We can optimize these routines in later PR's.__bmulhuwas not added since it is justmlt bc \ ld a, b(and the 8-bit calling convention is not well defined).