Answer the question
In order to leave comments, you need to log in
Why are all labels executed?
Hello, why do all the labels work for me and the ans variable contains the result of all actions and not just a specific one, thanks in advance!
int v, ans, aR1,aR2,aR3;
_asm
{
mov eax, 1
mov ebx, 10
cmp eax, 1
jz m1
cmp eax, 2
jz m2
cmp eax, 3
jz m3
cmp eax, 4
jz m4
jmp m5
m1:
imul ebx, 1000
mov ans, ebx
m2:
mov ans, ebx
m3:
imul ebx, 10
mov ans, ebx
m4:
imul ebx, 100
mov ans, ebx
m5:
xor eax, eax
}
cout << "SWITCH";
cout << ans;
Answer the question
In order to leave comments, you need to log in
It's not a high-level language with case, it's asm.
Here labels are just labels, they just tell the assembler the address of the next line to put it in the binary code of the jmp command, without adding any exit logic to the next label.
You need to add m6: at the end and jmp m6 after each option except the last one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question