I'm lost because val in your examples is not part of a function argument.
;The following line(s) will be correct only with certain calling
;conventions - compilers will allow you to change the calling
;convention to be used
mov eax,[ebp+8] ;first passed parameter resides at ebp+8
ret ;same as return(val1+val2)
That is using val1 and val2 as function arguments and/or parameters.
mov eax, val
should work on any inline assembler provided that val is a valid variable.
mov eax,[immediate value 8/16/32] is perfectly valid in any x86 assembler provided the immediate value is of an integral type.
Post the entire section and perhaps we can help. Sometimes semi-colons in the wrong place or misplaced parentheses can spit out some strange errors. I don't think the error is in your assembly code.