I am a beginner (first year in UNI). I use VisualStudio and the x86 configuration. This is my function:
int hex(int x) {
__asm {
MOV EAX, x
CMP EAX, 9
JG jumpto
ADD EAX, 48
MOV x, EAX
jumpto:
ADD EAX, 55
MOV x, EAX
}
return x;
}
There is an issue with the JG condition or I dont understand it right. My understanding of the CMP and JG lines is:
- EAX is compared to 9 (x to 9).
- IF it is greater than 9 it'll jump to "jumpto" (wow that sounds stupid).
- IF it is NOT greater, it just reads the line between JG and jumpto. So I basically think it works like if/else
My problem is that, if it is not greater the program still reads the line that are in the "jumpto" segment (ADD EAX,55 ; MOV x, EAX) which by my understanding should't do.
Can someone explain to me (like I'm a child or as easy as possible) why it doesn't work. I am hopeles. Thank you.
I tried google and again if I'm not making a mistake it just made me more confident in the if/else thing.