Hi there, I'm having a problem with a local buffer. In one of the new tutorials of Iczelions (RichEdit set) he uses a buffer declared like this: LOCAL buffer[1024*10]:BYTE This compiled fine but produces an page fault exception when run. I moved this declaration to the global variables area, and it compiled fine and then ran fine. Do I need a newer version of ml.exe? I have 6.14.8444 or what about link.exe I have 5.12.8078 on that one. Thanks, Ben
Your problem is you can only use 'local' variables in procedures. The local statement allocates data for you on the stack. To do what you want in the .data segment, you need to do something like this: Buffer DB 10240 DUP (0)
What kind of page fault do you obtain? If it is 80000001h - this is infamous "guard page" violation. It may take place, when you try to commit more then 1 page (4096b) of memory on heap or stack at once. Try to get the same local memory in few steps with chunks less then 1 page. DVA
Your problem is related to the way you specify (or don't specify) the reserved/commit stack size for your exe. By default, MASM reserves 1 MB of address space for the stack and commit only some of them with physical memory. Now, local variables are actually stack memory and using a large amount of stack memory can cause page fault. You should look at the makefile that accompanies the richedit control tutorial: syntax hilighting. I use linker switches like the following: Link /STACK:2000000,2000000 /SUBSYSTEM:WINDOWS That line tells the linker to reserve 2 MB of address space for the stack and COMMIT physical memory to back that address range.
Thanks, Izcelion. Sorry martin you didn't quite understand the problem, I understood that part already. (Thanks DVA too, but that wasn't what I got) - Ben