我正在组装练习计算器。它正常工作,除了显示答案时,新行字符(0x0A)将不会显示。相反,有一个包含数字0014的框(可能是Unicode)。我做错了吗?
bits 64 ; 64-bit (amd64) code
section .data
stdin: equ 0
stdout: equ 1
sys_read: equ 0
sys_write: equ 1
sys_exit: equ 60
l_out1: db "Simple Assembly Addition",0Ah,": "
l_len1: equ 27
l_out2: db ": "
l_len2: equ 2
l_out3: db "Answer is: "
l_len3: equ 11
section .bss
l_in1: resb 3 ; reserve 3 bytes (digits)
l_in2: resb 3 ; reserve 3 bytes (digits)
l_ans: resb 4 ; answer
section .text
global _start
_start:
mov rax,sys_write ; system call id
mov rdi,stdout ; descriptor
mov rsi,l_out1
mov rdx,l_len1
syscall
mov rax,sys_read ; system call id
mov rdi,stdin ; descriptor
mov rsi,l_in1
mov rdx,3 ; see .bss
syscall
mov rax,sys_write ; system call id
mov rdi,stdout ; descriptor
mov rsi,l_out2
mov rdx,l_len2
syscall
mov rax,sys_read ; system call id
mov rdi,stdin ; descriptor
mov rsi,l_in2
mov rdx,3
syscall
mov r8,[l_in1] ; copy l_in1 to rax
sub r8,"0"
mov r9,[l_in2] ; copy l_in2 to rax
sub r9,"0"
add r8,r9
add r8,"0" ; add 0 for ascii conversion
mov [l_ans],r8 ; store answer to address of l_ans
mov rax,sys_write ; system call id
mov rdi,stdout ; descriptor
mov rsi,l_out3
mov rdx,l_len3
syscall
mov rax,sys_write ; system call id
mov rdi,stdout ; descriptor
mov rsi,l_ans
mov rdx,4
syscall
mov rax,sys_write
mov rdi,stdout
mov rsi,0Ah
mov rdx,1
syscall
mov rax,sys_exit ; system call id
mov rdi,0 ; return 0
syscall