C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD

# Finding GCD of an array of n numbers in assembly without external variables

By : JustNoob
Date : October 16 2020, 06:10 PM
Hope this helps Step 1, cleanup and corrections
Removing redundant instructions, re-arrangeing the code for less jumping, removing the potential infinite loop if 2 identical numbers are used and zeroing EDX before each division:
code :
``````    mov  eax, intArray[0]
mov  ebx, intArray[1]

major:
cmp  eax, ebx
jg   nextstep
xchg eax, ebx
nextstep:
cmp  ebx, 0
je   zerob
modulus:
xor  edx, edx
div  ebx
mov  eax, ebx
mov  ebx, edx
jmp  nextstep

zerob:
mov  MCD, eax
fine:
``````
``````    mov  ecx, num       ;Number of elements
lea  esi, intArray[0]
lodsd               ;First number in array
dec  ecx
jz   DONE

AGAIN:
mov  ebx, [esi]     ;Next number in array

major:
cmp  eax, ebx
jg   nextstep
xchg eax, ebx
jmp  nextstep
modulus:                ;Inner loop
xor  edx, edx
div  ebx
mov  eax, ebx
mov  ebx, edx
nextstep:
test ebx, ebx
jnz  modulus

dec  ecx
jnz  AGAIN

DONE:
mov  MCD, eax
fine:
``````

Share :

## Finding Consecutive numbers From a Arithmetic series in an Array of random numbers

By : user34943
Date : March 29 2020, 07:55 AM
Does that help An O(i) solution using additional storage space would be to use a bit vector of size i initialised to 0. Iterate through the array and set the entry j to one if you encounter n*j. After that, find the number of ones at the beginning of the bit vector.

## Loading external web.config variables when invoking a method in an external assembly

By : user2967438
Date : March 29 2020, 07:55 AM
I wish this helpful for you You may need to register with the AppDomain.CurrentDomain.TypeResolve event. This link has an example of how to use it. http://msdn.microsoft.com/en-us/library/system.appdomain.typeresolve.aspx

## Finding the distance between the two closest numbers in an array of n numbers. (Presorted Arrays)

By : Ryan McGraw
Date : March 29 2020, 07:55 AM
this will help Loops are not identical. In the for loop i is increased in each iteration, while in the while loop i is increased only in some cases. An identical while loop would be:
code :
``````while(i<n)
{
if(a[i]==current)
i++;
else
{
currentmin=a[i]-a[i-1];
if(currentmin<arraymin)
{
arraymin=currentmin;
current=a[i];
}
i++;
}
}
``````

## Finding odd numbers in assembly

By : Stefan Kern
Date : March 29 2020, 07:55 AM
it fixes the issue I'm not sure if you just forgot the extra subs, or if you thought ARM had branch delay slots, but you're only decrementing a2 in the "even" case.
Note that beq odd is unnecessary since you could use conditional execution instead, which will be more efficient:
code :
``````    tst a4, #1
addne a3, a3, #1      @ if (a4 & 1) a3++
subs a2, a2, #1
bne elop
mov a1, a3
ldmfd sp!,{v1-v6,pc}
``````

## How to pass variables to a external assembly function

By : user3304941
Date : March 29 2020, 07:55 AM
hop of those help? If you compile your C into 32-bit code with the default GCC options (not -mregparm=3 like the Linux kernel uses), then on function entry the first argument is on the stack just above the return address (at [esp+4]), but that offset changes after you push anything or move ESP around.
You can use [ebp+8] after setting up a traditional stack pointer (which doesn't change during the function even when ESP does).
code :
``````;bits 32              ; unneeded, nasm -felf32 implies this.
global asm_function   ; include asm_function in ELF .o symbol table for linking
section .text
asm_function:
push ebp
mov ebp, esp
mov eax, [ebp+8]  ; return the first argument
mov esp, ebp
pop ebp
ret
``````
``````global _asm_function
global asm_function  ; make both names of the function global
section .text
_asm_function:
asm_function:        ; make both symbols point to the same place
push ebp
mov ebp, esp
mov eax, [ebp+8]
mov esp, ebp
pop ebp
ret
``````