xor %eax, %eax
: set eax to 0 - more discussion later
mov $4, %eax
mov
: copy data to destination - calling it move
is "traditional"
add $38, %eax
mov
statement,
click Debug and then start
neg %ebx
, step through
and
, or
, xor
, not
with 01101100 (0x6C) and 01110101 (0x75)
~
unsigned int result = 0x6c & 0x75;
xor
, and what do we get with xor %eax, %eax
?
xor
takes 2 bytes, mov $0, %eax
needs 4
bytes for the 0 (for a total of 5 bytes)
imul
, but there's a twist..
mov $6, %eax
, then mov $9, %ebx
,
and mul %ebx
mov $5, %ebx mov $6, %ecx imul %ecx, %ebxIn this case there is no implicit side-effect modifying %eax or %edx
push
, pop
.data
: data segment (currently empty)
.text
: code segment (name text likely comes from it
being the text of the program in the same way that the lyrics are the
words (text) of a song
.global
: signals that it can be called from other "modules"
main
: a label indicating the start of a
routine (here, the main function of the program)
ret
: return instruction - return to caller
__asm__
keyword
simp_asm_fun_call.cpp
mov $5, %eax
will set a 32-bit register, so can
assume to be moving a "long"
movX
variant where X
is b
, w
, l
, q
movq
: 64 bits (quadword)
add
add
, neg
and
, or
, xor
, not
;
logical operations