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

  • SEARCH
  • Home
  • 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 8753979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:31:56+00:00 2026-06-13T13:31:56+00:00

Possible Duplicate: x86 Assembly – ‘testl’ eax against eax? I’m very very new to

  • 0

Possible Duplicate:
x86 Assembly – ‘testl’ eax against eax?

I’m very very new to assembly language programming, and I’m currently trying to read the assembly language generated from a binary. I’ve run across

 test   %eax,%eax

or test %rdi, %rdi, etc. etc. I’m very confused as to what this does. Isn’t the values in %eax, %eax the same? What is it testing? I read somewhere that it is doing the AND operation…..but since they are the same value, wouldn’t it just return %eax?

The following is just one instance where I found this usage:

   400e6e:       85 c0                   test   %eax,%eax
   400e70:       74 05                   je     400e77 <phase_1+0x23>

I thought je jumps if the two values being compared are equal……well, because %eax is well, itself, in what situation would we NOT jump?

I’m a beginner to programming in general, so I’d appreciate it very much if someone could explain this to me. Thanks!

  • 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-13T13:31:57+00:00Added an answer on June 13, 2026 at 1:31 pm

    CMP subtracts the operands and sets the flags. Namely, it sets the zero flag if the difference is zero (operands are equal).

    TEST sets the zero flag, ZF, when the result of the AND operation is zero. If two operands are equal, their bitwise AND is zero when both are zero. TEST also sets the sign flag, SF, when the most significant bit is set in the result, and the parity flag, PF, when the number of set bits is even.

    JE [Jump if Equals] tests the zero flag and jumps if the flag is set. JE is an alias of JZ [Jump if Zero] so the disassembler cannot select one based on the opcode. JE is named such because the zero flag is set if the arguments to CMP are equal.

    So,

    TEST %eax, %eax
    JE   400e77 <phase_1+0x23>
    

    jumps if the %eax is zero.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: harmonic series with x86-64 assembly trying to do a version of a
Possible Duplicate: Loading x86 or x64 assembly I'm trying to compile Any CPU .NET
Possible Duplicate: x86 assembly registers — Why do they work the way they do?
Possible Duplicate: Confusing add command in x86 assembly I would like to understand these
Possible Duplicate: C# - How to get Program Files (x86) on Windows Vista 64
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Haskell vs. procedural programming in the real world Few times I heard
Possible Duplicate: How to cross compile from Mac OS X to Linux x86? I
Possible Duplicate: C# - How to get Program Files (x86) on Vista x64 What
Possible Duplicate: Opening url in new tab while i am doing window.open(), my page

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.