What is the difference between defining a string in bytes (db) and defining strings as words / double words (dw / dd) in x86

I am trying to investigate the difference between label definitions in an assembly, here is an example

ALabel: db 'Testing'
AAnotherLabel: dw 'Testing'

Now, let me load them into a 32-bit register:

mov eax, [ALabel]
mov ebx, [AAnotherLabel]

when researching with gdb I found that all child registers eax and ebx contain the same values, look here:

info register eax
0x64636261 //dcba

info register ebx
0x64636261 //dcba

They are the same!

In a book by Jeff Duntemann (phased programming of a programming language on Linux) he shows an example of words and double words in registers, but for some reason loads an offset (i.e. an address of such a value)

DoubleString: dd 'Stop'
mov edx, DoubleString

Examining the contents of edx shows that it contains the address, presumably the address of the first four letters in the string, as well as the address of only the first, although I reflect here.

, , :

Fin: db 'Final'
mov ecx, Fin
+4
2

.

db, dw, dd
. NASM, .

dw, 1 (2 ). , 2, 4, 6, 8... . 3 'abc'. 3 , 'dw', 4 . 4. 0.

fin: dw 'abc'               ; 0x61 0x62 0x63 0x00 (string)

db dw, 1 . 3 :

fin: db 'abc'               ; 0x61 0x62 0x63 (string)

-, ( NASM), , . , . :
3.2.1: http://www.nasm.us/doc/nasmdoc3.html


, , [] . - , NASM. , NASM . eax:

mov eax, fin

4 eax:

mov eax, [fin]

:

DoubleString: dd 'Stop'
mov edx, DoubleString

DoubleString, , 'Stop', edx. . , DoubleString 'S'. Doublestring+1 , 't' ..

:
2.2.2: http://www.nasm.us/doc/nasmdoc2.html#section-2.2.2

+4

- . dw 2, dd 4.

, .

+2

All Articles