I will be grateful for any comments (http://smiles.kolobok.us/standart/blush2.gif)
Quote
...
...
...
String2LONG proto :DWORD,:DWORD
.data
mestitle db "String2LONG",0
String db "4294967295",0
form db "%u %u",0
.data?
buffer db 512 dup(?)
BReg LONG64 ?
.code
start:
invoke String2LONG, addr String, addr BReg
invoke wsprintf,ADDR buffer,ADDR form,BReg
invoke MessageBox,0,ADDR buffer,ADDR mestitle,MB_OK + MB_ICONASTERISK
invoke ExitProcess,0
String2LONG proc FSTRING:DWORD,NUMBER:DWORD
LOCAL COMPRESS :REAL10 ----------?????????????????????????
LOCAL FLONG :LONG64
;LOCAL COMPRESS :dt ----------???? how to use dt here (in procedure)? dt is compress decimal?
mov dword ptr[COMPRESS], 0 ----------????? why it is necessary to full zero this real variable after initialization?
mov dword ptr[COMPRESS+4], 0
mov word ptr[COMPRESS+8], 0
;fldz ---------------????? this way is more slowly ?
;fbstp COMPRESS
....
....
....
;finit ----------????????????????????????? why initialization is not necessarily?
fbld COMPRESS
fistp FLONG
.ENDIF
mov esi, NUMBER ----------????????????????????????? are any other way to back 64 bit variable?
push dword ptr [FLONG]
pop dword ptr [esi]
add esi, 4
push dword ptr [FLONG+4]
pop dword ptr [esi]
ret
String2LONG endp
end start
This code is part of working rightly code
look in the masm32\tutorial\fputute folder for Raymond's excellent tutorial - also online on his site
DT is a tenbyte (80 bit) variable
better to use REAL10 rather than DT
mov dword ptr[COMPRESS], 0 ----------????? why it is necessary to full zero this real variable after initialization?
mov dword ptr[COMPRESS+4], 0
mov word ptr[COMPRESS+8], 0
it is a local variable on the stack - LOCAL just reserves space for it
i prefer to create my own locals using PUSH
xor eax,eax
push eax
push eax
push eax
that creates a 12-byte variable filled with 0's - you may use only 10 bytes of it as a real10
you just have to figure out what the address is, relative to EBP :bg
if it is the only local variable, it would be REAL10 PTR [EBP-12]
FINIT is slow, so use it if you have to
it is better, and more difficult, to learn when you need to use it and use it only when you have to
Jochen has played with many combinations of using FINIT, saving registers, etc
mov esi, NUMBER ----------????????????????????????? are any other way to back 64 bit variable?
ESI is a 32 bit register ????????????????????? :bg
thanks, clouds cleared .
NUMBER - offset
ohhh - if it is on the stack, use LEA...
LEA ESI,NUMBER
loads the address of NUMBER into ESI
NUMBER offset from main program. or I don't understand something
inside the proc, it is NUMBER - a function parameter that is on the stack
you must use LEA to get the offset of stack variables
LEA is Load Effective Address - the CPU calculates the offset for you
for example, if the parm's address is [EBP+12], it will calculate EBP+12 and place that value in the register
outside the proc, it is OFFSET BReg (the address of the variable passed to the function)
ADDR BReg is slightly different, as i understand it
it has to do with how parms are pushed onto the stack
ADDR is only necessary for INVOKE parms, and when there are several
if you are outside the PROC and want the address in a register - MOV ESI,OFFSET BReg