Question
x86_64 Assembly program output is 54321 want it to be 12345 IMPRTANT Please please please double check your answer with https://www.mycompiler.io before submitting, I am
x86_64 Assembly program
output is 54321 want it to be 12345
IMPRTANT
Please please please double check your answer with https://www.mycompiler.io before submitting, I am asking this question third time now and I still waiting to get my correct answer
______________________________________________________________________________________________________________________________________________
The program converts the value stored in rax into a string that is the decimal of the value. Does the program generate a correct answer? If not, correct the program and submit the source code.
________________________________________________________________________________________________________________________________________________ section .data msg db "0011223344556677..,,..,,..,,..,,0011223344556677..,,..,,..,,..,," atoi_buf db "0011223344556677..,,..,,..,,..,,0011223344556677..,,..,,..,,..,," newline db 0ah num dq 0
section .text global _start
put_newline: push rax push rdx push rsi push rdi
mov rax,1 mov rdi,1 mov rsi,newline mov rdx,1 syscall
pop rdi pop rsi pop rdx pop rax ret
atoi_aux: xor edx,edx div ebx push rax mov rax, rdx add al, '0' mov [rdi], al pop rax inc rdi ret
_start: mov rdi,atoi_buf mov rax,12345 mov ebx,10
loop: call atoi_aux cmp rax,0 jne loop
mov rdx,rdi sub rdx,atoi_buf mov rax,1 mov rdi,1 mov rsi,atoi_buf syscall
exit_normal: mov rax, 60 mov rdi, 0 syscall
put_qword_safe: push rax push rbx push rcx push rdx push rsi push rdi mov rdi,msg mov rcx,8 hex_qword: mov rbx,num add rbx,rcx dec rbx mov ah,[rbx] call hex_byte loop hex_qword sub rdi,msg mov rcx, rdi mov rax, 1 mov rdi, 1 mov rsi, msg mov rdx, rcx syscall pop rdi pop rsi pop rdx pop rcx pop rbx pop rax ret
hex_byte: mov al,ah shr al,10 call hex_digit inc rdi mov al,ah and al,0fh call hex_digit inc rdi ret hex_digit: cmp al,10 jnc alpha add al,'0' jmp w alpha: sub al,10 add al,'A' w: mov [rdi],al ret
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started