M
M
murmur32019-03-21 18:15:23
assembler
murmur3, 2019-03-21 18:15:23

How to write a simple C++ program as close to assembler as possible?

It is necessary to write a program in C ++ that is as similar as possible to assembler code. How to make nested if-else look like it?
*sorry if the question is incorrect
Condition: if the three numbers are in ascending order, print 1, otherwise - 0.

int main() {
  int res; //результат
  int a = 5;
  int b = 4;
  int c = 9;

  if (b < c) {
    if (a < c) {
      if (a < b) {
        res = 1; 
      }
      else {
        res = 0;
      }
    }
    else {
      res = 0;
    }
  }
  else {
    res = 0;
  }
  cout << res << endl;
  system("pause");
  return 0;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2019-03-21
@dollar

int a = 5;
int b = 4;
int c = 9;

if (a >= b) goto bad;
if (b >= c) goto bad;
good:
res = 1;
goto done;
bad:
res = 0;
done:

cout << res << endl;

As close as possible to assembler

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question