News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

MASM: Why must you be so difficult?

Started by 2-Bit Chip, September 03, 2009, 12:48:55 AM

Previous topic - Next topic

Ghandi

Quote
i tried that, Ghandi
the alloc macro is similar to the str$() (and a few others)
it only works if it is used in a context where it could be replaced with "eax"

Ah, my bad. Sorry Dedndave.

HR,
Ghandi

dedndave

lol - no prob Ghandi
i tried it, too   :bg

a much better approach might be to:
1) keep an index into the allocated block for adding new points: NextNewPoint dd ?
2) allocate enough memory for all the points to be stored
3) store the base address (or "handle") for that allocation in: hNewPoints dd ?
also, initialize NextNewPoints with the same address as hNewPoints

then, use a macro (or a proc) like this:

NewPoint MACRO X:Req,Y:Req
        push    edx
        mov     edx,NextNewPoint
        mov     [edx],X
        mov     [edx+4],Y
        add     edx,8
        mov     NextNewPoint,edx
        pop     edx
        ENDM

2-Bit Chip

Dave,

The only method for saving that I have seen would be:

MakePoint proc X:DWORD, Y:DWORD
     LOCAL p: POINT


Or I would see:

    db 0,0,0,0,0

Assigning values without a name.

dedndave

well, we know nothing about how these points are created to begin with, nor how they are used - lol
perhaps you could give us some insight as to the application
if you can reasonably predict how many points you will be creating
or, at least, a starting point, you can allocate the block of memory all at once, and enlarge it later if needed
the points do not appear to require names
but, you can find a specific point, according to the order they are created, by starting at the base of the allocated block
if they are arbitrary points of, say, a circle as it is generated, you may not need to specifically address them one-by-one
the method you are currently using must generate a lot of allocated "handles" - what are you doing with all of those ?