News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Reading numbers from text file

Started by lukasz128, January 02, 2013, 10:26:21 PM

Previous topic - Next topic

MichaelW

Quote from: lukasz128 on January 05, 2013, 07:35:35 AM
What is better to use HeapAlloc or GlobalAlloc?

For what you are doing I think the best choice is the one that is easier to use, and the same for the functions to open and read the file.
Well Microsoft, here's another nice mess you've gotten us into.

lukasz128

So new question. I have a struct of three dword elements, I have a block of memory size of this struct and for example variable first of this struct. What I need is to replace my "first" by new one.The solution I see is:

invoke HeapAlloc, heapHandle, HEAP_ZERO_MEMORY, sizeof Element
mov pointer, eax
lea ebx, first
mov [ebx], [pointer]
mov [ebx + 4], [pointer + 4]
mov [ebx + 8]. [pointer + 8]

Is there a easier way of doing this? I know it won't work but I only wanted to show sketch. And for question why I need it for:  I'm implementing doubly linkedlist and I need it to "insert" method.

FORTRANS

Hi,

   Look at the MOVe String command.  REP MOVSD will simplify
the transfer, but it requires more setup and the index registers.

Regards,

Steve N.

qWord

Use structures for the linked list (more readable). e.g.:
NODE struct
flink PVOID ?
blink PVOID ?
data DWORD 4 dup (?)
NODE ends

mov ebx, first ; first = ptr NODE

invoke HeapAlloc,...
mov edx,[ebx].NODE.flink
mov [ebx].NODE.flink,eax
mov [eax].NODE.blink,ebx
mov [eax].NODE.flink,edx
.if edx
mov [edx].NODE.blink,eax
.endif
mov [eax].NODE.data[0],...
mov [eax].NODE.data[4],...
MREAL macros - when you need floating point arithmetic while assembling!

lukasz128

Quote from: qWord on January 05, 2013, 10:14:42 AM
Use structures for the linked list (more readable). e.g.:
It worked quite well, thanks.

Gunther

Hi lukasz128,

Quote from: lukasz128 on January 07, 2013, 08:10:00 AM
Quote from: qWord on January 05, 2013, 10:14:42 AM
Use structures for the linked list (more readable). e.g.:
It worked quite well, thanks.

that's was friends are for.

Gunther
You have to know the facts before you can distort them.