You are on page 1of 1

EatMsg: db Eat at Joe s! ....

mov ecx,EatMsg
If you ve had any exposure to high-level languages like Pascal, your ?rst instinct
might be to assume that whatever
data is stored in EatMsg will be copied into ECX. Assembly doesn t work that way.
That MOV instruction
actually copies the address of EatMsg,notwhat s stored in(actually,at) EatMsg. In
assembly language, variable names
represent addresses, not data! So how do you actually
get at
the data represented b
y a variable like EatMsg?Again,
it s done with square brackets:
mov edx,[EatMsg]
Where the size issue gets tricky is when you write data in a register out to mem
ory. NASM does not
remember
the size of variables, as higher-level languagesdo.Itknowswhere EatMsgstartsinme
mory,andthat sit.Youhave to tell
NASM how many bytes of data to move. This is done by a size speci?er. For exampl
e:
mov [EatMsg],byte 'G
The simplest example of a conditional jump instruction, and the one you re likely
to use the most, is JNZ, Jump If Not
Zero. TheJNZ instruction tests the value of the Zero ?ag. If ZF is set (that is,
equal to 1),
then nothing happens and the CPU executes the next instruction in sequence. Howe
ver, if ZF is not set (that is, equal t
o 0), then execution travels to a new destination in your program.
Not all multiplications generate large enough products to require twor egisters.
Most of the time you ll ?nd that 32
bits is more than enough. So how can you tell whether or not there are signi?ca
nt ?gures in the high-order register?
MUL very helpfully sets theCarry flag(CF)whenthevalueoftheproductover?ows the l
ow-order register. If, after a MUL,
you ?nd CF set to 0, you can ignore the high-order register, secure in the know
ledge that the entire product is in
the lower order of the two registers.
EatLen: equ $-EatMsg
.Labels,remember,are not data, but locations and, in the case of assembly language
, addresses. When NASM reaches
the label EatLen, the value of $ is the location immediately after the last cha
racter in EatMsg.
Note well that nothing in the CPU or in Linux remembers the size of the data ite
ms that you place on the stack.
It s up to you to know the size of the last item pushed onto the stack. If the la
st item you pushed was a 16-bit
register,
popping the stack into a 32-bit register will take two more bytes off the stack
than you pushed.
Global- ono sto mozes koristiti u drugom modulu
Extern- koristis ono sto je globalno u drugom modulu

You might also like