Thomas
Thomas

Reputation: 23

How to fix 'syntax error: ,' and 'undefined symbol'

I'm doing an assignment where I need to declare symbolic constants in MASM along with some other functions in the program. I wrote the whole program and think I did it all properly, but I keep having a syntax error for the symbolic constant declarations. I'm supposed to declare the symbolic constants A = 5120, B=260, C= 170 and D=2200. Under the code directive, with the use of mov instruction, move values of A, B, C and D to EAX, EBX, ECX and EDX respectively. However it keeps saying there's a syntax error for the comma before 'C', that 'C' is a syntax error, and all my other symbolic constants are undefined.

I changed 'C' to 'E' and it worked but I feel like changing the letters isn't the issue here.

 .data
 mystring BYTE 20 DUP('a')
 val1 SDWORD 2147483647
 sum DWORD 0
 firstName BYTE "Akash", "Akash", "Akash", "Akash", "Akash"
 firstNameSize = ($ - firstName)
 A = 5120
 B = 260
 C = 170
 D = 2200

 .code
 main proc
 mov eax, A             
 mov ebx, B
 mov ecx, C
 mov edx, D             
 sub ebx, ecx
 add eax, ebx
 sub eax, edx
 mov sum, eax
 invoke ExitProcess,0

I expected the output to be that there would be no build errors, the registers would contain the correct values and would do the math on the numbers.

Upvotes: 0

Views: 2732

Answers (1)

Luis Sosa
Luis Sosa

Reputation: 140

C is the name of an operation in MASM, so you can't use it as a variable name. Here's a list of all reserved terms I could find.

Upvotes: 3

Related Questions