Reputation: 387
I enter assembler function with two C char arrays like that:
EncryptAsm(arr1,arr2)
where both are of type char*
, one containing text and the second one is full of '#' signs and it acts like two dimensional array, both are the same length.
I'm trying to pass some values from first array to second one in asm procedure:
mov ecx,row ;calculating index of arr2 index=[row*inputLength+column]
imul ecx,ebx
add ecx,column
mov eax,1 ;calculating index of arr1
imul eax,iterator
mov esi,arr1[eax]
mov edi,arr2[ecx]
movsb
When the indexes of both arrays equal 0 (eax
and ecx
are 0) everything is fine, but if it's bigger it doesn't work and throws an error (eg. eax
==1).
In asm code, the arrays are of type:
arr1:ptr byte, arr2:ptr byte
What am I doing wrong?
Upvotes: 0
Views: 110
Reputation: 70
can you check the assembly guide of the movsb? If a normal Intel movsb, it shall code like this:
CLD
MOV ECX ,100
LEA ESI,FIRST
LEA EDI,SECOND
REP MOVSB
And also, something needed to be checked:
1, the segment of SI/DI, if write access and segment length are right
2, interrupt protection during the REP MOVSB
Upvotes: 1