NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: georgelappies on April 28, 2012, 08:43:16 PM
-
Is db not a byte only? (define byte)? How is it then possible that a statement such as
message: db 'Hello World', 0ah, 0dh, '$'
is valid in NASM. Or is the label message treated like a pointer?
-
Is db not a byte only? (define byte)?
Yeah... maybe "define byte or bytes" would be more accurate. Anything enclosed in quotes is taken as a list of bytes. You could also do:
my_byte_array db 0, 1, 3, 5, 42
another "list of bytes". Using a single number that exceeds byte size...
foo db 345
is probably an error, but Nasm will assemble it (just the low byte) with just a warning.
In Nasm syntax, the unadorned variable name - "message" - is the address (an "immediate" value). Masm (AoA) would call it "offset message". In Masm syntax, just "message" refers to the contents of memory at that address - 'H', or possibly more bytes - Nasm uses "[message]" to refer to "[contents]"...
mov dx, message ; address - Masm would need "offset"
mov al, [message] ; 'H'
mov eax, [message] ; "Hell" :)
(only one of the instances of "Hell" you'll encounter) :)
Best,
Frank