"how do you store a 11 byte data into 1 byte memory?"
:laugh:
You don't.
db
allocates bytes, not just a byte - so if you use
msg db 'Hello, world!',0xa
then it will allocate an area for an fourteen character string with the data filled in, not a single byte. The label
msg
will contain the address of the first byte of that string.
So when you execute
mov ecx,msg
The address of the first byte is placed in the register.
"Another thing that I forgot to ask is that if 'db' allocates bytes, what is the purpose of having 'dw', 'dd', etc.?"
They assign different sizes:
db allocates in units of one byte, and aligns to a single byte address.
dw allocates in units of two bytes, and aligns to the next two byte address.
dd allocates in units of four bytes, and aligns to the next four byte address.
The alignment is important: when you access a byte, you can use any address. When you access a word, the least significant bit of the address is ignored, because words are always supposed to be on a word boundary. If you provide an odd-numbered address to a word fetch or store instruction, it will read or write at the wrong location.
Suppose the address starts at hex 100:
x db 1
y dw 1001
If the alignment didn't happen, then x would be "0x100" and y would be "0x101" (We'll ignore segments, and 32 / 64 bit addressing here).
So when you write to y the hardware in the processor executes a word based instruction and "rounds" the address to write to down by ignoring the least significant bit. As a result the write to y overwrites x as well!
dw forces the alignment to be correct for word operations by making x hold "0x100" and y "0x102" - dd does the same for 4 byte addresses and so forth.
Make sense?