Eddie
Eddie

Reputation: 13

Passing Values into Memory location Access Violation in Assembly

I will start with this block of code:

mov   eax, 5
mov   DWORD PTR [eax], 123

I am trying to move the value 123 into the memory location at address 5, but I get a write access violation. The only thing I can guess is that the memory location is already reserved or in use. But no matter what address I use, it's the same thing. If I were to read out from the same location, say:

mov   eax, 5
mov   ebx, DWORD PTR [eax]

I get no errors. What am I missing?

(If it helps, I am coding in MASM, Win 7, 4 gb ram)

Upvotes: 1

Views: 1227

Answers (1)

Jens Björnhager
Jens Björnhager

Reputation: 5649

You get a protection fault because your process doesn't own that particular piece of address space. In fact, the first megabyte of address space is made off limits by Windows for any process.

Upvotes: 1

Related Questions