linux - sys_write will not output 0x0A -
i making calculator in assembly practice. working fine except when answer displayed, new line character (0x0a) not display. instead there box numbers 0014 inside (unicode probably). doing wrong?
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 rax sub r8,"0" mov r9,[l_in2] ; copy l_in2 rax sub r9,"0" add r8,r9 add r8,"0" ; add 0 ascii conversion mov [l_ans],r8 ; store answer 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
Comments
Post a Comment