Как правильно использовать cmp? - PullRequest
0 голосов
/ 18 октября 2019

Тогда, если уже полдень, он должен написать доброе утро, если полдень, и добрый день, если днем. Я не могу понять, почему

Так что однажды я попытался заменить morning на hello и morningLen на helloLen, и это сработало, но если я заменил полдень, это не сработало.

Также я попыталсязамените привет на утро, и это напечатано доброе утро! но он не печатает в текущей программе

SECTION .data               ;data section beggining
hello:  DB 'Hello, is it afternoon?: 1 - yes, 2 - no',41 ;
helloLen:   EQU $-hello     ;length of hello

morning:    DB 'Good morning!',13 ;
morningLen: EQU $-morning       ;length of morning

afternoon:  DB 'Good afternoon!',15 ;
afternoonLen:   EQU $-afternoon ;length of afternoon

SECTION .bss        ; not initiated section
buf1:   RESB 80     ; buf 80 bytes

SECTION .text       ; code start section
GLOBAL _start

_start:

mov eax,4       ;system call for write
mov ebx,1       ;
mov ecx,hello   ;hello string address
mov edx,helloLen    ;hello string length
int 80h     ;core call

mov eax, 3      ;system call for read
mov ebx, 0      ;file descriptor
        ;0 - standard read
mov ecx, buf1       ;buff address
mov edx, 80         ;length of read string
int 80h

mov ecx,buf1        ;move buf1 to ecx

cmp ecx,1       ;comparison
je @IfNot       ;if true jump to ifnot

mov eax,4       ;system call for write
mov ebx,1       ;
mov ecx,morning     ;hello string address
mov edx,morningLen  ;hello string length
int 80h         ;

jmp @EndIf      ; jump to endif if not working
@IfNot:

mov eax,4       ;
mov ebx,1       ;
mov ecx,afternoon   ;
mov edx,afternoonLen    ;
int 80h         ;

@EndIf:

mov eax,1       ;(sys_exit)
mov ebx,0       ;0 - no errors
int 80h         ;

он ничего не выводит после команды cmp, и если я заменяю morning на hello, а morningLen на helloLen, он печатает после сравнения.

Нет ошибоксообщения

...