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 section .data msg db 0011223344556677..,,..,,..,,..,,0011223344556677..,,..,,..,,..,, atoi_buf db 0011223344556677..,,..,,..,,..,,0011223344556677..,,..,,..,,..,, newline db 0ah num dq 0

x86_64 Assembly program

output is 54321 want it to be 12345

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

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.

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

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

=+How will this affect the recruiting process?

Answered: 1 week ago