3rd
Окт

Cравнить две строки. asm

Posted by Chas under Пост-обзор

Нужно сделать по аналогии с strcmp (на Си). Если первая строка меньше второй вывести -1, если равны 0, иначе 1.

.686P
.model flat
.data
string1 db ‘мама мыла раму’,0
string2 db ‘мама не мыла раму’,0
.code
start:     mov esi,offset string1
         mov ecx,offset string2
         call strcmp
         mov esi,offset string2
         mov ecx,offset string1
         call strcmp
         mov esi,offset string1
         mov ecx,offset string1
strcmp proc
@@:     lodsd
         cmp al,[ecx]
         jnz short a3
         or al,al
         jz short @f
         cmp ah,[ecx+1]
         jnz short a3
         or ah, ah
         jz short @f
         shr eax,10h
         cmp al,[ecx+2]
         jnz short a3
         or al,al
         jz short @f
         cmp ah,[ecx+3]
         jnz short a3
         add ecx,4
         or ah,ah
         jnz short @b
@@:     xor eax,eax
         retn
a3:     sbb eax,eax
         or eax,1
         retn
strcmp endp
end start

Тема на форуме

Похожие статьи