Re: Displaying string




leon800219@xxxxxxxxx wrote:
Hi all:

Hey

I've encounter a code snippet that is for string display, but there's
some points I don't understand, hope you help me thanks.

DispStr:
push ebp
mov ebp, esp
push ebx
push esi
push edi

; First of all what's ebp, I've searched but got no explicit
explanation
; what's the purpose of the above statements about manipulating ebp,
and esp

EBP (extended base pointer) points to the current stack frame.

The first two lines are an entry sequence:
http://en.wikipedia.org/wiki/Cdecl#Standard_Exit_and_Entry_Sequences

mov esi, [ebp + 8] ; why pop 8 bytes?

You're not popping, nor does this involve 8 bytes. You're moving the
(dword) at the address 8 bytes higher than EBP to ESI (this is the
first argument passed to the function).

mov edi, [dwDispPos]
mov ah, 0Fh
.1:
lodsb
test al, al
jz .2
cmp al, 0Ah ; 0Ah stands for enter?

Line feed.

[...snip...]

Before you go any further, you might want to learn some basic
assembly--i.e. what the registers are, the different address modes,
what "mov" means...

.