Write a X86 assembly function that is passed in two ints a a
Write a X86 assembly function that is passed in two ints a and b from a \"C\" program.
If a < b, it then computes the sum: a+(a+1)+(a+2)+...+b
If a = b, it should compute a.
If a > b, it should compute 0.
After the function is finished calculating, it should return the result
Solution
:_MyFunction1
push ebp
mov ebp, esp
mov eax, [ebp + 8]
mov edx, [ebp + 12]
cmp eax,edx
jne end1
add eax, 0
pop ebp
ret 8
end1:
cmp eax,edx
JG end2
add eax, edx
pop ebp
ret
end2:
add 0, 0
pop ebp
ret
