I'm still beginer, so this may be trivial error. I wont to work with floating point matrix. So I created simple application (basic skeleton I take from help in FPULIB & raymond's determinants, but damaged by me) to read number into matrix & then to display elements by one. But it changes rows with columns. I check EDI register, but both functions have same values:
143318, 143322, 14332C, 143336, 143340, 14334A, 143354, 14335E, 143368
I don't understand to this. I known, in my code is error, but can't find it.
This is my code (it isn't optimal, it is poor, but I'm beginner forever):
.386
.model flat,stdcall
option casemap:none
include E:\masm32\include\windows.inc
include E:\masm32\include\user32.inc
include E:\masm32\include\kernel32.inc
include E:\masm32\include\masm32.inc
include E:\masm32\include\fpu.inc
includelib E:\masm32\lib\user32.lib
includelib E:\masm32\lib\kernel32.lib
;includelib E:\masm32\lib\masm32.lib
includelib E:\masm32\lib\Fpu.lib
.data
MsgPopis db "Matrix test",0
numtxt db 19 dup(0)
lpsrc dd "1.1",0,"1.2",0,"1.3",0,"2.1",0,"2.2",0,"2.3",0,"3.1",0,"3.2",0,"3.3",0
hMem dd 100 dup(0)
.code
start:
mov eax,3 ;size of matrix
mul eax ;size of matrix
push eax
push eax
imul eax,10
invoke LocalAlloc,LPTR,eax
mov hMem,eax ;adress allocated memory
mov edi,eax
mov esi,offset lpsrc
pop ecx ;number of elements
loop1:
push ecx
invoke FpuAtoFL,esi,edi,DEST_MEM ;test edi!!!
@@:
inc esi
cmp byte ptr[esi],0
jnz @B
inc esi
add esi,4
add edi,10
pop ecx
dec ecx
jnz short loop1
pop ecx ;number of elements
mov edi,hMem ;adress allocated memory
@@:
push ecx
invoke FpuFLtoA,edi,8,addr numtxt,SRC1_REAL ;test edi!!!
invoke MessageBox,0,addr numtxt, addr MsgPopis,MB_OK
add edi,10
pop ecx
dec ecx
jnz @B
invoke ExitProcess,NULL
end start
joe,
start:
mov eax,3 ;size of matrix
mul eax ;size of matrix
That is a register multiply so shouldn't EDX be initialized to some value?
Paul
not for the multiplication. division yes, but multiply no. :)
Oops, my mistake, the result goes into EDX:EAX. Must be senile decay...
Paul
Quote @@:
inc esi
cmp byte ptr[esi],0
jnz @B
inc esi
add esi,4
The short loop finds the end of the string which has been processed, which is fine if they may be of variable length.
The "inc esi" then brings the pointer to the start of the next string. OK
But the
add esi,4 then advances the pointer another 4 bytes which, with the data used, skips every other string. Otherwise, your code should work OK.
N.B. Don't forget to free your allocated memory before the ExitProcess.
Raymond
Thank's! Now I see it. First I used add esi,4, then I become aware that it can be used only for constant length, but forget delete add esi,4. There was second mistake: I used in lpsrc dd, but there must have been db.