Hello,

How can I access the input data?

The output looks like this:

What is your name? John
How old are you? 12

....after collecting data from 3 people...how can I access the AGE so that I can sort them?

Thanks
-Flip
Posted on 2010-07-30 18:32:05 by l flipboi l
You don't know how to access the data or how to collect the data?
Posted on 2010-07-31 09:55:58 by ti_mo_n
Actually I figured it now, what I need help now is how to get the data loaded onto the FPU Stack so I can sort it.

I used call DumpMem to access the inputted data.

This is part of my code:

call DumpMem

mov var1, esi    ;var1 is declared as DWORD
FILD var1
call showFPUstack

my FPU stack ST(0) displays the offset and not the value.  How can I load the value?

Thanks
-Flip
Posted on 2010-08-01 18:54:37 by l flipboi l
try mov var1,

data from behind pointer, not pointer itself!
Posted on 2010-08-02 01:28:48 by Homer
or why not just fild real4 ptr
Posted on 2010-08-02 01:29:47 by Homer
Thanks, Homer!

I seem to be running into a problem still....it still doesn't show the value in the FPU stack...

Here's my full code:


INCLUDE Irvine32.inc

AskInfo PROTO,
messageSize:DWORD,
messagePtr:PTR DWORD,
bufferSize:DWORD,
bufferPtr:PTR DWORD

.data
idStr BYTE "Please enter your id number: "
lastNameStr BYTE "Please enter your last name: "
firstNameStr BYTE "Please enter your first name: "
ageStr BYTE "Please enter your date of birth: "
testScore BYTE "Please enter your midterm score: "

messagePtrs DWORD OFFSET idStr, SIZEOF idStr
DWORD OFFSET lastNameStr, SIZEOF lastNameStr
DWORD OFFSET firstNameStr, SIZEOF firstNameStr
DWORD OFFSET ageStr, SIZEOF ageStr
DWORD OFFSET testScore, SIZEOF testScore
Items = ($ - messagePtrs ) / ( TYPE messagePtrs * 2 )

EntrySize = 30 ; bytes per item (including end of line)
userInfo BYTE Items * EntrySize DUP(0)

var1 DWORD ?


score1 REAL8 2 DUP(0.0)

filename BYTE "output.txt",0
fileHandle DWORD ? ; handle to output file
stdOutHandle DWORD 0
bytesWritten DWORD 0
stdInHandle DWORD 0
bytesRead DWORD 0

.code
main PROC
finit
; Get handle to standard output
INVOKE GetStdHandle, STD_OUTPUT_HANDLE
mov stdOutHandle, eax ; save console handle

; Get handle to standard input
INVOKE GetStdHandle, STD_INPUT_HANDLE
mov stdInHandle, eax ; save standard input handle

; Create file and get file handle
INVOKE CreateFile,
ADDR filename, GENERIC_WRITE, DO_NOT_SHARE, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0
mov fileHandle,eax ; save file handle

mov ecx, 2 ; number of records to read


L1: push ecx ; save counter

; Get info from user
mov esi, OFFSET messagePtrs
mov edi, OFFSET userInfo
mov ecx, ITEMS ; counter

GET_INFO_LOOP:
INVOKE AskInfo, , ; message size
, ; pointer to message
EntrySize, ; size of entry
edi ; pointer to item in userInfo Array


add esi, 8 ; two doublewords per item
add edi, EntrySize ; next entry
loop GET_INFO_LOOP

call NewLine ; write a blank line


pop ecx
call DumpMem

add esi, 120
FILD REAL8 PTR
call showFPUstack

loop L1

mov ecx, 2
mov esi, 0

L2:                                      ;load array for sorting
FSTP
add esi, TYPE score1
call WriteFloat
loop L2

call showFPUstack
Posted on 2010-08-02 12:47:40 by l flipboi l
Actually Homer, it worked!

Thanks man.
Posted on 2010-08-02 14:11:22 by l flipboi l
:)
Posted on 2010-08-03 01:32:51 by Homer