-
Notifications
You must be signed in to change notification settings - Fork 15
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
Unnecessary code in Power-function #8
Comments
You are right, that's a leftover from the very first version of 4klang where a generic power function was called with the base provided by the caller. It should be safe to modify it, as you already said. Thanks for the hint! P.S: ; //----------------------------------------------------------------------------------------
; // Power function
; //----------------------------------------------------------------------------------------
; // Input : st0 : base
; // st1 : exponent
; // Output: st0 : result
; //----------------------------------------------------------------------------------------
go4kPower: ; // base exp
fyl2x ; // log2_base -
fld st0 ; // log2_base log2_base
frndint ; // (int)log2_base log2_base
fxch ; // log2_base (int)log2_base
fsub st0, st1 ; // (frac)log2_base (int)log2_base
f2xm1 ; // 2 ^ '' - 1 (int)log2_base
fld1 ; // 1 2 ^ '' - 1 (int)log2_base
faddp st1, st0 ; // 2 ^ '' (int)log2_base
fscale
fstp st1
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In 4klang.asm, the lines 251-253 are:
I believe they do absolutely nothing to the stack and can be removed. To see this, I added some comments:
I think they are a left-over from a time when the power function could compute any power, not just 2^x. Also, I'm just learning x86 assembly so there could be something I'm missing here; however, I just ran some regression tests after deleting these three lines and all my regression tests seem to pass.
Also, the comments seem to be completely off, I think better comments could be:
The text was updated successfully, but these errors were encountered: