Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Assembly (http://www.programmingforums.org/forum20.html)
-   -   Fread (http://www.programmingforums.org/showthread.php?t=1565)

saxman Dec 16th, 2004 12:50 PM

I'm calling the FREAD function in assembly, but I have an issue. This is what I'm trying to accomplish:

:

unsigned short int * *value1;
unsigned short int * *value2;
unsigned short int * *value3;
unsigned short int * *value4;
FILE * **GSShandle

// ~~ cut out some code to show you what I'm looking at ~~ //

fread(&value1, sizeof(short int), 1, GSShandle);
fread(&value2, sizeof(short int), 1, GSShandle);
fread(&value3, sizeof(short int), 1, GSShandle);
fread(&value4, sizeof(short int), 1, GSShandle);


As you can see, the valueX variables are defined one after another. In theory, I would believe that I could use a single FREAD and write to all 4. This is what I put into ASM:

:

push * *ebx * * * * * *;I had put GSShandle here prior to this code
push * *4 * * * * * * *;4 values
push * *2 * * * * * * *;Define each value as 'WORD' size
push * *offset value1 *;Set the offset to 'VALUE1'
call * *fseek * * * * *;Do it's thing
add * * esp, 10h * * *;Fix our stack


When I try it, the results are not what I thought they would be. I am having a pretty difficult time debugging this and seeing what it's 'actually' doing. I was wondering if anyone had any clue as to why my ASM code doesn't work. I realize I could do each of the 4 FREAD's, but I thought it'd be neat to do all 4 in 1 shot.



EDIT: Perhaps this belongs in the C forum instead of this one. I guess I put it here since I was experimenting with the function in assembly... would it be too much trouble if this was moved to C? I think my chances of getting a reply would increase!

SubhadeepGhosh Jan 4th, 2005 3:44 AM

Hey,
The first thing I would like to point out is....instead of using offset use lea...offset is a compile time directive....while lea is a runtime directive...try that and let me know....


All times are GMT -5. The time now is 4:32 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC