简体   繁体   中英

Passing values from one array to another in assembler

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM