Author Topic: Reading numbers from text file  (Read 8823 times)

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: Reading numbers from text file
« Reply #15 on: January 05, 2013, 08:32:23 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

  • Guest
Re: Reading numbers from text file
« Reply #16 on: January 05, 2013, 08:45:20 AM »
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:
Code: [Select]
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

  • Member
  • *****
  • Posts: 1056
Re: Reading numbers from text file
« Reply #17 on: January 05, 2013, 09:36:05 AM »
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

  • Member
  • *****
  • Posts: 1473
  • The base type of a type is the type itself
    • SmplMath macros
Re: Reading numbers from text file
« Reply #18 on: January 05, 2013, 10:14:42 AM »
Use structures for the linked list (more readable). e.g.:
Code: [Select]
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

  • Guest
Re: Reading numbers from text file
« Reply #19 on: January 07, 2013, 08:10:00 AM »
Use structures for the linked list (more readable). e.g.:
It worked quite well, thanks.

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Reading numbers from text file
« Reply #20 on: January 07, 2013, 08:17:12 AM »
Hi lukasz128,

Use structures for the linked list (more readable). e.g.:
It worked quite well, thanks.

that's was friends are for.

Gunther
Get your facts first, and then you can distort them.