I am using inline assembly in c++. However, my code does not work properly, It always returns 0. I want to find some of negative values and show. Could you please help me out?
PS: I have used debugging but could not find the problem
void func(const int* arr, size_t arr_rows, size_t arr_cols, int* result)
{
int sum = 0;
_asm
{
mov ebx, [arr] ///address
mov edx, 0; //sum
mov ecx, [arr_rows] // number of rows
row_loop:
push ecx // save number of rows
xor esi, esi // reset column offset for the current row
mov ecx, [arr_cols] // number of column
col_loop :
add ebx, esi;
cmp ebx, 0
jge bigger_case
jl less_case
jmp n_case
less_case :
add esi, 4
add edx, dword ptr[ebx + esi];
loop col_loop
bigger_case:
add esi, 4
loop col_loop
n_case:
add esi, 4
add ebx, esi // move to the next row offset
pop ecx // restore row loop counter
loop row_loop;
ending:
mov sum, edx;
}
cout << sum<<" is answer"<<endl;
}