NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: nobody on December 07, 2008, 06:20:42 PM
-
Simple code:
x dw 10
y dw 10
[come code here]
x dw 20 ; i wish to manually redefine x value
compilation will fail:
filename.asm:65: error: symbol `x' redefined
Is there any simple way to manually redefine symbols in NASM ?
-
x dw 10
y dw 10
[come code here]
x dw 20 ; i wish to manually redefine x value
RE:
mov dword
-
Cool! You've redefined x and y at the same time! :)
"dw", though it looks like "dword", is actually "data word" and takes only 16 bits. Moving a dword into it will overwrite the next 16 bits. Either make the variables "dd", or only move a word into 'em.
Original poster: if you could have 2 "x" variables in your program, which one would you use? How would you know?
I suspect "mov word - , 20" is what you want, but you *could* do:
%define X 10
%define Y 10
; some code
%undefine X
%define X 20
Better, perhaps, would be:
%assign x 10
; some code
%assign x 20
or
%assign x x + 1
or whatever...
But these are "assemble-time" variables. For a "run-time" variable, you really only want *one* with a given name! Think about it...
Best,
Frank