Z
Z
ZIK12017-11-15 10:08:38
assembler
ZIK1, 2017-11-15 10:08:38

How to perform addition, multiplication and display a comparison of the resulting numbers?

Good day, assembler experts
For the first time I encountered this PL, and most likely the first and last time, so I don’t see the point of fully delving into its study.
You need to run it in visual studio 2017. You
need a simple code .

// int main()
{
  int a;
  int b;
  int x, y, z;
  x = 1;
  y = 2;
  z = 3;

That is, numbers x,y,z are given
Next, you need to perform the following actions:
a=x+y*z
b=(x+y)*(x+z)
After performing the actions, compare the numbers a and b and display the result of the comparison
All, until the moment it is displayed on the screen, you need to write in assembler.
The result of the comparison is also placed in assembler in some new variable, and then using C++ to display this variable on the screen.
Thank you in advance for your help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JaxxDexx, 2017-11-15
@ZIK1

int main()
{
  int a;
  int b;
  int x = 1;
  int y = 2;
  int z = 3;
  __asm {
    mov eax, y
    mul z
    add eax, x
    mov a, eax
    
    mov eax, y
    mov ebx, z
    add eax, x
    add ebx, x
    mul ebx
    mov b, eax

    mov eax, a
    mov ebx, b
    cmp eax, ebx
    je equal
    jb more
    jmp less
  };
  equal:
  printf("a = b");
  return 0;

  less:
  printf("a > b");
  return 0;

  more:
  printf("a < b");
  return 0;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question