Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8780321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:00:54+00:00 2026-06-13T20:00:54+00:00

I have some calculation in asm in loop, it must be before Sum will

  • 0

I have some calculation in asm in loop, it must be before Sum will be 3, but loop work all time and never ending. Here is mu code:

int main() {

    float Sum=0;
    int i=0;
    int A=5;
    int B=180;
    int C=3;

_asm{
   finit
m1:inc i
   fldpi
   fimul A  
   fimul i
   fidiv B
   fsin
   fadd Sum 
   fstp Sum
   fild Sum
   ficom C      
   fstsw AX     
   sahf         
   jg   m1
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:00:56+00:00Added an answer on June 13, 2026 at 8:00 pm

    The FPU’s condition flags have completely different meanings than the condition flags in the EFLAGS register.

    If Sum is greater than C, then the ficom will set the FPU condition flags to “C3=0, C2=0, C1=0”. When loaded into the CPU’s EFLAGS register (via. fstsw and sahf) this becomes “ZF=0, PF=0, CF=0”. The jg instruction will branch if “ZF=0” and “SF=0” – it won’t test the PF flag or the CF flag at all, but will test the irrelevant SF flag.

    Given that you’re comparing integers anyway; you should probably just do:

    mov eax,[Sum]
    cmp [C],eax
    jg m1
    

    The alternative is to test the flags in AX directly. For example:

    ficom C
    fstsw AX
    test AX,0x4500    ;Are C3, C2 and C0 clear?
    je m1             ; yes, Sum must be greater than C
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some idea that it is due to some complex calculation, but i
I have following JavaScript function to make some calculation with textboxes but when I
I have votes in my system, but I want to sort by some calculation
I have a controller that runs some calculation on data, and then I need
i have to build some financial data report, and for making the calculation, there
I have a javascript function which needs to do a numerical calculation. Some of
I have a loop like this: for i=1:no %some calculations fid = fopen('c:\\out.txt','wt'); %write
I do not think this is a duplicate. I have done some reading but
I have a little program that needs to do some calculation on a data
we have some calculation in our project like convertion from non-Exponential(1234567890.1234567890 numbers to Exponential(1.234567890E+10)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.