Пожалуйста, поясните фрагмент кода - Assembler

Узнай цену своей работы

Формулировка задачи:

.586p
.MODEL FLAT, C
 
public __Last
;------------------------------------------------------
.data
 
    string dd ?      ;end of string
      strl dd ?        ;beginning of the string
       val dd ?        ;lenght of string
 last_word db 20,?,20 dup (?)
       len dd ?        ;lenght of the last word
         k dd ?          ;lenght of the current word
       kol dd 0        ;number of words <- than the last
     konec dd ?        ;lenght of string without the last word
;---------------------------------------------------------
.code
 
__Last proc 
 
        push ebp
        mov ebp,esp
        push ebx
    push ecx
        push esi
        push edx
        mov edi,[ebp+8]
        mov strl,edi             ;beginning of the string
        mov eax,[ebp+12]
        mov val,eax             ;lenght of string
 
;--------------------------------------------
mov eax,ds
mov es,eax
mov eax,strl                     ;beginning of string to eax
add eax,val                      ;beginning + lenght = end of string
mov string, eax                  ;end of string to eax
 
std
mov al,' '
mov ecx,val                      ;lenght of string to ecx
mov edi,string                   ;the end of string to edi
mov edx,edi                      ;the end of string to edi
repne scasb                      ;look for gaps
je f                             ;if gap -> jmp to f
f:
inc edi                          ;the adress of beginning of last_word
mov eax,edi
sub edx,eax                      ;address of end - address of beginning = lenght of last_word
mov len,edx                      ;dx-lenght of the last word
sub len,1                        ; - null byte
cld                              
mov esi,string
sub esi,len
lea edi,last_word
mov ecx,len
rep movsb                     ;the last word
 
mov edx,string   
sub edx,len
sub edx,2
mov konec,edx                  ;lenght of string without the last word
 
mov ebx,strl
cycl11:
        mov al,' '
        mov ecx,konec          ;lenght of string without the last word to ecx
        mov edi,ebx            ;ebx - beginning  of string
        mov edx,edi            ;edx - beginning  of string
        repne scasb            ;look for gaps
        je found_it
        found_it: dec edi     ;end of current word
        sub edi,edx           ;lenght of the current word = edi-edx
        mov k,edi             ;lenght of current word to k
 
cmp edi,len
jg go_len
mov ecx,edi
jmp next_
go_len: mov ecx,len
jmp next_
next_:
cld
 
mov edi,ebx
lea esi,last_word
repne cmpsb
jb no_min
inc kol
no_min:
         add k,ebx
         mov ebx,k
plus_:  inc ebx
         mov eax,ebx
         cmp al,' '
         je plus_
         cmp ebx,konec
         jl cycl11
 
mov eax,kol         
;------------------------------------
        pop edx
        pop esi
    pop ecx
        pop ebx
    pop ebp
 
 ret
 
__Last endp
;-----------------------------
 
end
Непонятна именно вот эта часть
cmp edi,len
jg go_len
mov ecx,edi
jmp next_
go_len: mov ecx,len
jmp next_
next_:
cld
 
mov edi,ebx
lea esi,last_word
repne cmpsb
jb no_min
inc kol
no_min:
         add k,ebx
         mov ebx,k
plus_:  inc ebx
         mov eax,ebx
         cmp al,' '
         je plus_
         cmp ebx,konec
         jl cycl11
Поясните,пожалуйста,если можете что делает этот фрагмент кода.

Решение задачи: «Пожалуйста, поясните фрагмент кода»

textual
Листинг программы
mov eax,[ebx]

Оцени полезность:

7   голосов , оценка 3.429 из 5