Ok, let's just get it right out and say that I'm a newbie. Boom, there we go!

Ok, I'm writing a Logging Procedure for logging errors, but it seems that I'm going to have some trouble with it.

Since assembly can't directly support strings (it needs the variables), am I going to have to make about 1000 different string variables with different error messages?

.data

szD3DInitError db "Error Initializing Direct3D",0
szD3DVertexError db "Error Initializing Direct3D Vertex Buffer", 0
.data?
szLoggingString db ?


and then keep having to do

invoke lstrcpy,addr szLoggingString, szD3DInitError

invoke loggingproc, addr szLoggingString

invoke lstrcpy, addr szLoggingString, szD3DVertexError
invoke loggingproc, addr szLoggingString


This seems to be extremely inefficient...seeing as under .data i'd have about 400 strings.

There has to be some way to pass a string. Doesn't there? Or am I way too corrupted by using C++ for a while?

Also, what data type would be in loggingproc? I'm just guessing that it'd be
loggingproc proc text:DWORD

but I'm probably wrong. Thanks for any help that you can give me.
Posted on 2002-09-29 10:01:39 by SuperRoy
Macros could move the strings into the code (HERE).

It seems you need to create a PROC to receive a variable number of strings and write them to a logfile buffer. The szMultiCat PROC in masm32lib would only need slight changes to work efficiently.
Posted on 2002-09-29 10:55:39 by bitRAKE
There is no need to copy the string, you can just use the ADDR operator to give the address of the string to your debugging procedure.
.data

szD3DInitError db "Error Initializing Direct3D",0
szD3DVertexError db "Error Initializing Direct3D Vertex Buffer", 0

.code
invoke loggingproc, addr szD3DInitError
invoke loggingproc, addr szD3DVertexError

You can also look into making a macro, which might be able to replace something like
log "Error Initializing Direct3D"

Example:

log MACRO text
LOCAL localtext
.data
localtext BYTE text,0
.code
invoke loggingproc, addr localtext
ENDM

Then you can just use a code like:
log "hello"
inc eax
log "EAX has been increased!"

And it automatically calls your loggingproc.
Posted on 2002-09-29 10:57:45 by _js_
Thanks a lot.
Posted on 2002-09-29 11:38:02 by SuperRoy