Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

ISBN: 3319712721, 978-3319712727

More Books

Students also viewed these Databases questions

Question

2. Discuss various aspects of the training design process.

Answered: 1 week ago