0

Can help? I totally cannot do assembly code. It's part of my lab tutorial.

I wanted to convert this C++ code into assembly:

```
for (a = x; a <= y; a++) {
prime = 1;
for (b = 2; b <= a / 2; b++) {
if (a % b == 0) {
prime = 0;
break;
}
}
if (prime == 1)
count++;
}
```

x is the first number, y is the second number. This will find the value of prime numbers between the 2 given numbers. (eg. if x = 4, y = 25, the value of prime numbers between the 2 given numbers is 7)

And what I end up having this:

```
mov eax, x // a = x
cmp ebx, y // a <= y
jg end // stop if x > y
mov edx, 1 // prime = 1
push edx
mov ecx, 2 // b = 2
div eax // a / 2
cmp ecx, eax // b <= a / 2
inc ecx // b++
div eax, ecx
mov edh, eah
cmp edh, 0
mov edx, 0
```

*Edited 2 Years Ago by SpottyBlue*