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 9122479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:06:50+00:00 2026-06-17T06:06:50+00:00

How should I write such an if statement in assembly? if ((a == b

  • 0

How should I write such an if statement in assembly?

if ((a == b AND a > c) OR c == b) { ...

Platform: Intel 32-bit machine, NASM syntax.

Update

For variable types and value, use whatever is more easy to understand. Integers would works fine for me, I guess.

  • 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-17T06:06:51+00:00Added an answer on June 17, 2026 at 6:06 am

    For a simple expression with no side effects (such as the one given), the order of evaluation does not matter(1). That means you can check the "quick" cases first (those that decide with least code executed, c == b in this case).

    In generic assembly, it will be basically something like this (assume a in ax, b in bx, c in cx):

        cmp  bx, cx     ; check b == c?
        jeq  is_true    ; final result is true.
    
        cmp  ax, cx     ; otherwise b != c, so check a <= c?
        jle  is_false   ; if so, final result is false.
    
        cmp  ax, bx     ; otherwise a > c, so check a == b?
        jeq  is_true    ; if so, final result is true.
    
    is_false:
        ; do false bit  ; otherwise final result is false.
        jmp  next
    
    is_true:
        ; do true bit
    
    next:
        ; carry on
    

    If there’s no false bit, it can be simplified to something like:

        cmp  bx, cx
        jeq  is_true
    
        cmp  ax, bx
        jne  next      ; no false bit, next statement.
    
        cmp  ax, cx
        jle  next      ; no false bit, next statement.
    
    is_true:
        ; do true bit
    
    next:
        ; carry on
    

    (1) If the expression contained side-effects then order of evaluation may become important due to the possibility of short-circuiting evaluations. By that, I mean consider an expression such as (pseudo-code):

    if a == b and c == d:
        do_something()
    

    In that case, once you establish that a and b are equal, there is no need to compare c and d.

    I haven’t covered that (other than in this footnote) since:

    1. no source language was specified in the question (making it unclear whether it even has short-circuiting operations); and

    2. the expression appears to have no side effects anyway.

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

Sidebar

Related Questions

How should I write a statement in Java to produce JavaScript in a page
I should write function that takes list, element and return positions in with such
I have a problem regarding the lifetime of a variable. My Android-App should write
For pure educational purposes, what should I write instead of * such that I
I know I should write this in Vb.net but for my own reasons I'm
Should there be any specific order in which I should write the following for
I have some child processes which should write some logs into a common file.
I'm trying to create async api with Goliath framework. Service should write to mysql,
i want to upload the sound file (.ogg) in server. But it should write
What should I write into the .bat file for it to find all files

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.