Permalink
Cannot retrieve contributors at this time
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?
Guessuing_Game/comparison64Bit.asm
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
39 lines (37 sloc)
1.25 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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 |