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/getNameandPrint.asm
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
38 lines (37 sloc)
1.45 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
;Code to get person's name and repeat it | |
section .data | |
name db "What is your Name: " ;Ask the person to put in their name | |
nameLen equ $-name ; Ge the persons name | |
section .bss | |
answer resb 8 ; to store the name 8 bytes | |
section .text | |
global _start | |
_start | |
mov rax,4 ;; Move the system call 4 to the register rax | |
; to say name question | |
mov rbx,1 ;; put the value 1 in the register rbx - | |
; standard output to the screen | |
mov rcx, name ; Put the offset of name in rcx register | |
;; so we can access the string 'name' | |
mov rdx, nameLen ;Move length of name in register | |
int 80h ; Call the operating system with an interrupt. | |
mov rax,3 ; system call input | |
mov rbx, 0 ; stand input | |
mov rcx, answer ; store inputted value in answer - note ascii | |
; value and should be a name of up to 6 characters | |
mov rdx, 8 ; size of input value in bytes | |
int 80h | |
; The operating system checks the registers and | |
; performs the operation to write to screen | |
mov rax,4 ; System call output | |
mov rbx, 1 ; stand output | |
mov rcx, answer; The name of person enters | |
mov rdx, 8 ; size of output value in bytes | |
int 80h | |
mov rax,1 ; Put 1 in rax which equates to the system call | |
; for exit (sys_exit) | |
mov rbx,0 ; Put 0 in rbx which is the exit value 0 (no | |
; error) | |
int 80h; Call the operating system with an interrupt. | |
; The operating system checks the registers and | |
; performs the exit operation |