0
我想學習如何在程序集中使用linux 64位系統調用。從x64 linux系統調用(組件)讀取鍵盤輸入
我正在寫一些閱讀鍵盤的代碼,只需在屏幕上按下按鍵:我使用sys_read。
代碼:
section .text
global _start
_start:
;write startmsg
mov rax, 1
mov rdi, 1
mov rsi, startmsg
mov rdx, sizestart
syscall
;using sys_read
mov ax, 0
mov rdi, 0
mov rsi, key
mov rdx, 2
syscall
;trying to see if esc is pressed then exit
mov rbx, 0x1b
cmp rbx, key
je _exit
_exit:
mov rax, 60
mov rdi, 0
syscall
section .bss
key resw 1
section .data
startmsg db 'Press a key', 10
sizestart equ $-startmsg
現在兩件事情: 1)它在屏幕上自動打印鍵(d :) 2)當我按下ESC