카테고리

asm (27) bootloader_x86_grub (1) C (92) compile (11) config (76) CPP (13) CSS (1) debugging (7) gimp (1) Go (1) html (1) Java (1) JavaScript (1) kernel (19) LibreOffice (3) Linux system progamming (21) MFC (1) opencv (4) OpenGL (1) PHP (1) Python (4) qemu (29) shell (3) socket (7) troubleshooting (2) ubuntu18.04 (2) windows (1)

2018/12/09

asm keyboard input

section .data
text1 db "what is you name? "
text2 db "Hello, "

section .bss
name resb 16

section .text
global _start

_start:
call _printText1
call _getName
call _printText2
call _printName

mov rax, 60
mov rdi, 0
syscall

_getName:
mov rax, 0
mov rdi, 0
mov rsi, name
mov rdx, 16
syscall
ret

_printText1:
mov rax, 1
mov rdi, 1
mov rsi, text1
mov rdx, 18
syscall
ret

_printText2:
mov rax, 1
mov rdi, 1
mov rsi, text2
mov rdx, 7
syscall
ret

_printName:
mov rax, 1
mov rdi, 1
mov rsi, name
mov rdx, 16
syscall
ret

; compile : nasm -f elf64 input_hello.asm -o input_hello.o
; ld input_hello.o -o input_hello

댓글 없음:

댓글 쓰기