Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int sumMatrix(int *, int, int) {
- _asm {
- mov eax, 0
- mov ebx, 0 //rand
- mov ecx, 0 //coloana
- mov edx, [ebp + 8]
- mov esi, [ebp + 16] //nr. coloane
- _while:
- cmp ebx, [ebp + 12]
- je _endwhile
- mov ecx, 0
- _while2:
- cmp ecx, esi
- je _endwhile2
- //mov edi, [edx + ebx*esi + ecx*4]
- mov edi, ebx
- imul edi, esi
- add edi, ecx
- shl edi, 2
- mov edi, [edx + edi]
- cmp edi, ebx
- je _addit
- cmp edi, ecx
- je _addit
- jmp _skip
- _addit:
- add eax, edi
- _skip:
- inc ecx
- jmp _while2
- _endwhile2:
- inc ebx
- jmp _while
- _endwhile:
- }
- }
- int sumMatrix2(int *, int, int) {
- _asm {
- mov eax, 0
- mov ebx, 0 //rand
- mov ecx, 0 //coloana
- mov edx, [ebp + 8] //adresa completa
- mov esi, 0 //addr
- mov edi, [ebp + 12]
- imul edi, [ebp + 16]
- shl edi, 2
- _while:
- cmp esi, edi
- je _endwhile
- cmp esi, edi
- jne _skip
- mov ecx, 0
- inc ebx
- _skip:
- cmp ebx, [edx + esi]
- je _addit
- cmp ecx, [edx + esi]
- je _addit
- jmp _skip2
- _addit :
- add eax, [edx + esi]
- _skip2 :
- inc ecx
- add esi, 4
- jmp _while
- _endwhile :
- }
- }
- int main(){
- int M[][4] = {
- {5, 1, 7, 9},
- {10, 8, 2, 1},
- {2, 3, 11, 3}
- };
- cout << sumMatrix2(&M[0][0], 3, 4);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement