在64位NASM编程中没有从用户那里获得数字

时间:2018-03-30 11:42:00

标签: assembly nasm x86-64

我正在进行汇编编程,并尝试在变量num1中接受来自用户的号码,但是终端上会打印一些垃圾。输出的图像在描述中给出。解释为什么?

%macro print 2
    mov rax,1
    mov rdi,1
    mov rsi,%1
    mov rdx,%2
    syscall     
%endmacro
%macro accept 2
    mov rax,0
    mov rdi,0
    mov rsi,%1
    mov rdx,%2
    syscall
%endmacro
%macro exit 0
    mov rax,60
    mov rdi,0
    syscall
%endmacro

section .bss
    num1 resb 5         ;1 extra for enter key  
    choice resb 2
    tempbuff resb 8
section .data

    enter1 dq 10,"num1 : ",
    len1 equ $-enter1


    newline db 0AH

section .code
global _start
_start:
    print enter1,len1
    accept num1,5
    exit

enter image description here

0 个答案:

没有答案