NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: jimcpl on June 05, 2009, 02:24:00 AM
-
Hi,
I am trying to push a constant "string" (4 bytes), onto the stack, but I need to "terminate" the string with bytes containing 0x00.
The string is something like "e!", and the assembled code should look like:
6865210000
I've tried:
PUSH 'e!\0\0'
but that doesn't seem to work (I get a warning from NASM, and it appears to be interpreting the "\0" literally, i.e., as two bytes).
Does anyone know how I can do this in NASM?
Thanks,
Jim
-
Just:
push 'e!'
Should do what you want. Nasm will do stuff like:
push 'e!'<<16 | 0
but that'll "pre-terminate" your string, since it goes into memory little-endian.
Nasm only accepts C-style `/n`, `/t`, `/0`, etc. between "back apostrophes"... and it doesn't seem to work in this case... I guess just with "db"...?
Since you seem to be trying to match "other assemblers", note that Nasm treats "mov eax, 'abcd'" as other assemblers would treat "mov eax, 'dcba'". I'm not sure which assemblers do it which way. Some controversy which is "right"...
Best,
Frank
-
> Nasm only accepts C-style `/n`, `/t`, `/0`, etc. between "back apostrophes"...
> and it doesn't seem to work in this case... I guess just with "db"...?
Brain-cramp/typo there... with BACKslashes and BACKapostrophes, it *does* work as you had it:
push `e!\0\0`
Tseb,
Frank
-
Frank,
Thanks! That (reverse apostrophe) worked perfectly!
Jim