Understanding Unsigned and Signed Number Comparisons

comparing unsigned and signed numbers n.w
1 / 5
Embed
Share

Explore the differences between unsigned and signed numbers, and how programmers need to make decisions based on the context of the data. Learn about special instructions for comparing unsigned and signed numbers using intuitive jump instructions.

  • Programming
  • Numbers
  • Comparison
  • Unsigned
  • Signed

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Comparing unsigned and signed numbers

  2. Consider the following two numbers: 0xFFFFFFFF and 0x00000001 If we assume they are unsigned, then: 0xFFFFFFFF > 0x00000001 But, if we assume they are signed, then: 0xFFFFFFFF < 0x00000001 Programmer will need to decide whether the program uses unsigned numbers or signed numbers. There are special instructions for unsigned comparison and also for signed comparison

  3. CMP unsigned numbers The following instructions are for unsigned comparisons: JB = Jump if Below JBE = Jump if Below or Equal JA = Jump if Above JAE = Jump if Above or Equal

  4. CMP unsigned numbers (3) An intuitive way to understand the Jump Instructions: Assuming: CMP EAX, EBX Jump Instruction Intuitive Meaning JB (Jump Below) Jump if EAX is Below EBX (EAX < EBX) JBE (Jump Below or Equal) Jump if EAX is Below EBX, or, Equal (EAX <= EBX) JA (Jump Above) Jump if EAX is Above EBX (EAX > EBX) JAE (Jump Above or Equal) Jump if EAX is Above EBX, or, Equal (EAX >= EBX) JB is the same as JC (Jump Carry) JAE is the same as JNC (Jump if No Carry)

  5. CMP signed numbers The following instructions are for signed comparisons: JL = Jump if Less JLE = Jump if Less or Equal JG = Jump if Greater JGE = Jump if Greater or Equal

More Related Content