My compiler is gcc and assembler is nasm. I made my makefile. I need to learn taking arguments from function to assembly code. For example, these functions take 3 arguments and how i will use them in assembly? I wrote something that is:
PHP Code:
.MODEL SMALL
.CODE
global _add_num
_add_num PROC
push ebp ;Pushing arguments from function
mov ebp,esp
pushad
mov eax,0
mov edx,0
mov esi,[ebp+8]
mov esp,[ebp+4]
mov edi,esi
sub ecx,ecx
not ecx
sub al,al
cld
repne scasb
neg ecx
sub ecx,3
mov ebx,ecx ;ebx has lenght of first argument
mov edi,esp
sub ecx,ecx
not ecx
sub al,al
cld
repne scasb
neg ecx
sub ecx,3
mov edi,[ebp+4]
mov ebp,ecx ;ebp has lenght of first argument
sub eax,eax
sub edx,edx
mov ecx,2
L1:
mov al,[esi+ebp]
mov dl,[esp+ebx]
sub dl,48 ;sub ascii code
add al,dl
mov [edi+ebx],al ;result is in eax
dec ebp
dec ebx
loop L1
pop ebp
ret
_add_num ENDP
END
This code is correct for add function:
add(char* number1,char* number2,char* result)
And I'm getting memory for result before calling function.
There is any wrong about this code?