Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
; assembly code when comparison using 64-bit registers
section .data
samemsg db "They are the same: ", 10
samelen equ $- samemsg
answer dq 'h' ; correct answer this line changed to have 64 bits
notsamemsg db "They are not the same: ", 10
notsamelen equ $- notsamemsg
segment .bss
guess resb 1
section .text
global _start ;must be declared for using gcc
_start: ;tell linker entry point
mov eax, 3 ; read from keyboard
mov ebx, 2;
mov ecx, guess ; move guess into ecx
mov edx, 1 ; As single letter using 1 byte
int 80h ; call interrupt
mov rax, [guess] ; move guess by user into rax
cmp rax, [answer] ; compare correct answer with what in rax
je same ; if they are the same jump to same
call notSame ; else jump to notSame
same:
mov ecx,samemsg ; same message
mov edx, samelen ; length of same message
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax, 1
int 80h
notSame:
mov ecx,notsamemsg ; not same message
mov edx, notsamelen ; not same message length
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax, 1
int 80h