An access violation means that you are trying to write to a memory address that does not belong to your program's address space. That's the what the protected mode of the CPU is supposed to protect: No program running amok can violate another program's memory space.
Memory addressing and paging on a PC is a matter you must understand once you really want to do some more complicated things. For now it will be sufficient to set up the 'variables' the right way.
In assembly you simply have to reserve the right amount of bytes for the value you want to store. The label (you would call it the variable name) represents the memory address of the first reserved byte. Since you get an access violation, this label represents an invalid address which does not belong to your program.
Obviously you did something wrong when you reserved the memory for your value. Please post that part of your code (including any assembly directives) and we should resolve this quickly.
Thanks for posting the code.
Sam Homer wrote:
var Dd 3
Try it like this:
Var Dd ?
Edit: I have gotten a short sample from the assembler's homepage. Look at the _hheap label and how it is declared and used.
; GetMainArgs v1.01
; Copyright © 2003 Theodor-Iulian Ciobanu
format PE GUI 4.0
entry start
include 'win32a.inc'
include 'cmd.inc'
start:
invoke GetProcessHeap
mov [_hheap],eax
invoke HeapAlloc,[_hheap],HEAP_ZERO_MEMORY,1000h
mov [_strbuf],eax
call GetMainArgs
mov esi,[_argv]
cinvoke wsprintf,[_strbuf],_fmt1,[_argc]
mov ebx,[_argc]
@@:
cinvoke wsprintf,[_strbuf],_fmt2,[_strbuf],[esi]
add esi,4
dec ebx
cmp ebx,0
jnz @b
invoke MessageBox,0,[_strbuf],_msgcap,MB_ICONINFORMATION+MB_OK
invoke HeapFree,[_hheap],0,[_argv]
invoke HeapFree,[_hheap],0,[_strbuf]
invoke ExitProcess,0
_strbuf dd ?
_fmt1 db '%u',0
_fmt2 db '%s, "%s"',0
_msgcap db 'Command line parameters',0
_hheap dd ?
data import
library kernel,'KERNEL32.DLL',\
user,'USER32.DLL'
import kernel,\
GetCommandLine,'GetCommandLineA',\
GetProcessHeap,'GetProcessHeap',\
HeapAlloc,'HeapAlloc',\
HeapFree,'HeapFree',\
ExitProcess,'ExitProcess'
import user,\
MessageBox,'MessageBoxA',\
wsprintf,'wsprintfA'
end data