Hi, I am taking an Intro to Computer Science course. I have to translate a code to assembly. I was wondering if someone could help me out with the first line of the code. I am not sure what to do since it it ==.

if (x==y) {

thanks!

How do you compare if two registers are equal in assembly?

cmp(x,y);//compare x and y
je jmpWhereverYouWant;//je means jump if equal meaning if x and y are equal,if not equal then
//itll skip the second line and go on to the third line(whatever it is usually the else part.

Use gcc -s file.c command file.s will have it in assembly

ithelp
Cheating never helps anyone learn anything. That, and the code output by the GCC won't be as obvious to read as just doing it right to begin with.

eyehategod
You've got the right idea. Just be careful which jump condition you use. All you need to do now is get x and y into registers.

;somehow set ax = x
;somehow set bx = y
cmp ax, bx
jne somewhere_else
  ;do stuff here if ax==bx
somewhere_else:  ;all done

(Yeah! I got assembly highlighting!)