What does it means when a variable or label has brackets around it? How is it different than using the statement without brackets? For example:

mov eax, [data]

It means move the "contents" of this address into the register (instead of the value of the address itself).

It means move the "contents" of this address into the register (instead of the value of the address itself).

Thanks for the reply! So if I understand you correctly, using the braces means to grab the value, whereas without the braces says to get the address? If that's so, why is it that the following code outputs the same thing?

// C++ w/ inline ASM
	int x = 18, y = 0;

	__asm
	{
		; Without braces
		mov eax, x	; Move '18' into EAX
		mov y, eax	; Move EAX (18) into Y
	}

	cout << "Without braces: \n" << y << endl;	// 18
	y = 0;

	__asm
	{
		; With braces
		mov eax, [x]	; Move the ?address? of x into EAX
		mov y, eax		; Move EAX (address of x?) into Y
	}

	cout << "With braces: \n" << y << endl;

Yes, better said: Value vs. Address

[Your embedded ASM]
Well, that's a different story. The C++ compiler is probably assuming since you have BOTH forms in the same program that you only wanted one form

If I put something like that through my ASM compiler with the address and the value, it will give an error.

I simply had to give another name to the same location and it was OK.

mov ah, 09h
   mov dx, strData
   int 21h

   mov dx, byte ptr [strData2]
   ;mov ax, byte ptr [strData] ; gives error

   int 20h

strData:
strData2:
   db 'this$'

As seen in Debug, you'll notice the results are completely different:

-r
AX=0000  BX=0000  CX=0012  DX=0000  SP=FFFE  BP=0000  SI=0000  DI=0000
DS=1456  ES=1456  SS=1456  CS=1456  IP=0100   NV UP EI PL NZ NA PO NC
1456:0100 B409          MOV     AH,09
-p

AX=0900  BX=0000  CX=0012  DX=0000  SP=FFFE  BP=0000  SI=0000  DI=0000
DS=1456  ES=1456  SS=1456  CS=1456  IP=0102   NV UP EI PL NZ NA PO NC
1456:0102 BA0D01        MOV     DX,010D
-p

AX=0900  BX=0000  CX=0012  DX=010D  SP=FFFE  BP=0000  SI=0000  DI=0000
DS=1456  ES=1456  SS=1456  CS=1456  IP=0105   NV UP EI PL NZ NA PO NC
1456:0105 CD21          INT     21
-p
this
AX=0924  BX=0000  CX=0012  DX=010D  SP=FFFE  BP=0000  SI=0000  DI=0000
DS=1456  ES=1456  SS=1456  CS=1456  IP=0107   NV UP EI PL NZ NA PO NC
1456:0107 8B160D01      MOV     DX,[010D]                          DS:010D=6874
-p

AX=0924  BX=0000  CX=0012  DX=6874  SP=FFFE  BP=0000  SI=0000  DI=0000
DS=1456  ES=1456  SS=1456  CS=1456  IP=010B   NV UP EI PL NZ NA PO NC
1456:010B CD20          INT     20
commented: Thank you for your help! +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.