In our system's programming classes, we're being taught assembly language. In most of the sample programs our prof. has shown in classes; he's using:
XOR CX, CX
instead of
MOV CX, 0
or
OR AX, AX
JNE SOME_LABEL
instead of
CMP AX, 0
JNE SOME_LABEL
or
AND AL, 0FH ; To convert input ASCII value to numeral
; The value in AL has already been checked to lie b/w '0' and '9'
instead of
SUB AL, '0'
My question is the following, is there some kind of better performance when using the AND
/OR
or XOR
instead of the alternate (easy to understand/read) method?
Since these programs are generally shown to us during theory lecture hours, most of the class is unable to actually evaluate them verbally. Why spend 40 minutes of lecture explaining these trivial statements?
xor eax,eax
– Satori