I get an application error when I do it that way...

"memory at blah referenced at blah could not be written"
Posted on 2003-03-31 00:34:47 by locke
I think you're on your own locke, I can't see the problem from my pov, I don't have your library files so I can't test it here except to test the createfile writefile stuff and that works fine. I'm afraid I've given you all the ideas that I have. Maybe sleep on the problem and you'll come up with something in the morning. (or start your homework on Saturday instead :) )
Posted on 2003-03-31 00:37:28 by donkey
hell I'll send u the files... lol :)

I've been working on this the past 2,3 days... I seriously need to find out whats going wrong
Posted on 2003-03-31 00:38:35 by locke
Try jumping past the seive part and just writing the file full of zeroes with bufSize set to 32768, that'll let you see which routine is causing the error. I'm off to bed, g'nite.
Posted on 2003-03-31 00:40:57 by donkey
when vc++ dubugger runs... the problem is w/ this line of code: mov byte ptr ,1

says "The instruction at 0x00401044 referenced memory at "0x004339bb". The memory could not be "written" ".
Posted on 2003-03-31 00:41:39 by locke
when I do a jmp past all the sieve algoritm... the file size changed to like 63 bytes! but its still empty
Posted on 2003-03-31 00:53:23 by locke
Cause position > 0ffffh

buffer db 0ffffh dup (?)
lea esi,buffer
mov ecx,2
mov eax,2
push eax
mul ecx
mov byte ptr [esi+eax],1
pop eax
inc eax
cmp eax, 0ffffh
jb @B
inc ecx
cmp ecx,10
jnz @B
Posted on 2003-03-31 00:56:55 by roticv
Your stack is not balanced :

mov bl, 2
mul bl

.WHILE (ax < lengthof buffer)
[COLOR=red]push eax[/COLOR]
mov ebx,esi
add eax,ebx
mov esi,eax
add [esi], dx
[COLOR=red]pop eax[/COLOR]
[COLOR=red]pop ebx[/COLOR]
inc bl
mul bl

inc al
Posted on 2003-03-31 00:58:32 by donkey

I still get "The instruction at "0x00401044" referenced memory at "0x0041a000". The memory could not be "written" "


when I balance it out (either push ebx also, or get rid of the pop ebx) it gives me an error saying: "The instruction at "0x0040105c" referenced memory at "0x0042d77c". The memory could not be "written". "

I should also add... when I added a "jmp write" to skip all the Sieve algorithm, I does indeed write to the file (its 64kb), though its filled w/ weird squarish looking characters.
Posted on 2003-03-31 01:06:31 by locke
As I said it would write DWORDs and not text, those squares are DWORD 0's.
Posted on 2003-03-31 01:08:02 by donkey
so how do I write text???
Posted on 2003-03-31 01:08:54 by locke
You have to do a conversion to ascii,

fmtstring db "%ld",0
textbuffer db 16 dup (?)

; This line will convert a DWORD value to text and place it in textbuffer
invoke wsprintf,ADDR textbuffer, ADDR fmtstring ,number
Posted on 2003-03-31 01:13:00 by donkey
whats number ???
Posted on 2003-03-31 01:16:46 by locke
my assembler (masm6.15) doesn't know what wsprintf is
Posted on 2003-03-31 01:18:10 by locke
Any DWORD Value, I haven't thought about how to integrate this into your program, just posted the command that you need to use to convert a numeric DWORD value into an ascii string so you can display it or write it to a file in a readable by humans format. The rest you really have to figure out yourself.

wsprintf is a Windows api command, it would be in your windows.inc or library files. If it doesn't recognize it amybe your lib has another function for it
Posted on 2003-03-31 01:20:36 by donkey
well Donkey,

I know I bothered you a lot... thanx for ALL the help :)

I hope I can get this done
Posted on 2003-03-31 01:21:34 by locke
one last question:

whats this: fmtstring db "%ld", 0
Posted on 2003-03-31 01:24:41 by locke
It just tells the wsprintf api call what the input format is for the conversion i.e

%ld = A long signed decimal integer
Posted on 2003-03-31 01:28:27 by donkey
General advise:

I assume you should move "bufSize = ($ - buffer)" to right after the buffer, so you won't accidentally trash anything.

use 32-bit registers and data, 16bit stuff is slow in 32bit mode. Very important, make SURE your stack is 4byte aligned. This also means no pushing/popping of 16bit values. Many win32 functions will fail if stack is not 4byte aligned, especially NT doesn't like this.

(already mentioned), your push/pop are unbalanced.

Read up on 32bit assembly at www.madwizard.org, read up on win32 API.

Run app through debugger and make sure API return values etc are valid.

What's in irvine32.inc? And are you using the standard windows.inc (etc) files that are supplied with hutches masm32 package?
Posted on 2003-03-31 01:37:37 by f0dder
already put the bufSize = ($-buffer) under... that not the prob :)

prob is, i'm a novice at asm... hahah :(

now, the Irvince32.inc is just a small including for that includes some constants so you don't have to type in for example:

.model flat, stdcall

and makes some function calls easier

it includes other include files: smallwin.inc

this is masm6.15 which comes w/ the book: "Assembly using Intel" by Kip Irvine
Posted on 2003-03-31 01:47:01 by locke