I am new to assembly, and when I studied on the internet, I found the following code, but I don't know why push eax
is not written before mov eax, [ebp+8]
.
; char* removerng(char* s, char a, char b)
; removes (in place) characters from a to b in string s
section .text
global removerng
removerng:
; prologue
push ebp
mov ebp, esp
push ebx ;<- ebx instead of eax?
push esi
push edi
; body <- we don't need eax?
mov eax, [ebp+8]; load string into return address
mov esi, [ebp+8]; last char checked
mov edi, [ebp+8]; last char placed
loop:
mov bh, [esi]; current char
inc esi
test bh, bh; test for end of string
jz fin
cmp bh, [ebp+12]
jl keep
cmp bh, [ebp+16]
jg keep
jmp loop
keep:
mov [edi], bh
inc edi
jmp loop
fin:
mov [edi], bh
;epilogue
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
Does this mean we can use both push ebx
and push eax
Could any one help me?