.

:

;

;

EBP

EIP

;

:

SUB ESP,

2 :

  • ADD ESP,
  • MOV ESP, EBP
  • ,

    :

    Proc

    Push EBP

    Mov EBP, ESP

    SUB ESP,

    PUSH

    POP

    MOV ESP, EBP

    POP EBP

    RET []

    . .

    .

    void itoa (unsigned x){

    int numbers[] = {10000, 1000, 100, 10, 1};

    for (int I=0; I<5; I++){

    Y[I]= x/numbers[i] + 0;

    X%= numbers[i];

    }

    }

    ideal

    p586

    model flat

    codeseg

    proc itoa; ebp 0

    public itoa; eip 4

    ;; y 8

    ;; x 12

    push ebp

    mov ebp, esp

    sub esp, 5*4

    push eax ebx ecx edx esi

    mov [numbers], 10000

    mov [numbers+4], 1000

    mov [numbers+8], 100

    mov [numbers+12], 10

    mov [numbers+16], 1

    mov ecx, 5

    mov eax, [ebp+12]

    mov ebx, [ebp+8]

    lea esi, [numbers]

    for1:

    xor edx, edx

    div [dword ptr esi]

    add al, '0'

    mov [ebx], al

    inc ebx

    add esi, 4

    mov eax, edx

    loop for1

    mov [byte ptr ebx], 0

    pop esi edx ecx ebx eax

    mov esp, ebp

    pop ebp

    ret 8

    endp itoa

    end

    !