SlideShare una empresa de Scribd logo
1 de 3
Descargar para leer sin conexión
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.

Más contenido relacionado

Similar a x86_64 Assembly program output is 54321 want it to be 12345 section.pdf

Finding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated DisassemblyFinding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated Disassembly
Priyanka Aash
 
Application of Radare2 Illustrated by Shylock and Snakso.A Analysis
Application of Radare2 Illustrated by Shylock and Snakso.A AnalysisApplication of Radare2 Illustrated by Shylock and Snakso.A Analysis
Application of Radare2 Illustrated by Shylock and Snakso.A Analysis
Positive Hack Days
 
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCsw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
CanSecWest
 

Similar a x86_64 Assembly program output is 54321 want it to be 12345 section.pdf (20)

Drizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free MigrationDrizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free Migration
 
Windows Debugging with WinDbg
Windows Debugging with WinDbgWindows Debugging with WinDbg
Windows Debugging with WinDbg
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
 
利用Init connect做mysql clients stat 用户审计
 利用Init connect做mysql clients stat 用户审计 利用Init connect做mysql clients stat 用户审计
利用Init connect做mysql clients stat 用户审计
 
DEP/ASLR bypass without ROP/JIT
DEP/ASLR bypass without ROP/JITDEP/ASLR bypass without ROP/JIT
DEP/ASLR bypass without ROP/JIT
 
Triggers and Stored Procedures
Triggers and Stored ProceduresTriggers and Stored Procedures
Triggers and Stored Procedures
 
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksBeginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
 
Finding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated DisassemblyFinding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated Disassembly
 
WCTF 2018 binja Editorial
WCTF 2018 binja EditorialWCTF 2018 binja Editorial
WCTF 2018 binja Editorial
 
Accelerated Windows Malware Analysis with Memory Dumps
Accelerated Windows Malware Analysis with Memory DumpsAccelerated Windows Malware Analysis with Memory Dumps
Accelerated Windows Malware Analysis with Memory Dumps
 
Tokyo APAC Groundbreakers tour - The Complete Java Developer
Tokyo APAC Groundbreakers tour - The Complete Java DeveloperTokyo APAC Groundbreakers tour - The Complete Java Developer
Tokyo APAC Groundbreakers tour - The Complete Java Developer
 
Error based blind sqli
Error based blind sqliError based blind sqli
Error based blind sqli
 
Swug July 2010 - windows debugging by sainath
Swug July 2010 - windows debugging by sainathSwug July 2010 - windows debugging by sainath
Swug July 2010 - windows debugging by sainath
 
Game.log
Game.logGame.log
Game.log
 
Application of Radare2 Illustrated by Shylock and Snakso.A Analysis
Application of Radare2 Illustrated by Shylock and Snakso.A AnalysisApplication of Radare2 Illustrated by Shylock and Snakso.A Analysis
Application of Radare2 Illustrated by Shylock and Snakso.A Analysis
 
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCsw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
 
Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph
Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph
Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with Modules
 
Joel Falcou, Boost.SIMD
Joel Falcou, Boost.SIMDJoel Falcou, Boost.SIMD
Joel Falcou, Boost.SIMD
 
FreeLix: Semplicità & Controllo
FreeLix: Semplicità & ControlloFreeLix: Semplicità & Controllo
FreeLix: Semplicità & Controllo
 

Más de AARVEEKNITWEAR

XCode Weather Forecast with Arrays Exercise I began revising similar c.pdf
XCode Weather Forecast with Arrays Exercise I began revising similar c.pdfXCode Weather Forecast with Arrays Exercise I began revising similar c.pdf
XCode Weather Forecast with Arrays Exercise I began revising similar c.pdf
AARVEEKNITWEAR
 

Más de AARVEEKNITWEAR (20)

XYZ Corporation is a multinational organization that has several offic.pdf
XYZ Corporation is a multinational organization that has several offic.pdfXYZ Corporation is a multinational organization that has several offic.pdf
XYZ Corporation is a multinational organization that has several offic.pdf
 
XYZ Co- stock sells for $42 and just a paid a dividend of $2- Dividend.pdf
XYZ Co- stock sells for $42 and just a paid a dividend of $2- Dividend.pdfXYZ Co- stock sells for $42 and just a paid a dividend of $2- Dividend.pdf
XYZ Co- stock sells for $42 and just a paid a dividend of $2- Dividend.pdf
 
XCode Weather Forecast with Arrays Exercise I began revising similar c.pdf
XCode Weather Forecast with Arrays Exercise I began revising similar c.pdfXCode Weather Forecast with Arrays Exercise I began revising similar c.pdf
XCode Weather Forecast with Arrays Exercise I began revising similar c.pdf
 
XYZ Company is considering three different plans for financing their o.pdf
XYZ Company is considering three different plans for financing their o.pdfXYZ Company is considering three different plans for financing their o.pdf
XYZ Company is considering three different plans for financing their o.pdf
 
x7x1-1.pdf
x7x1-1.pdfx7x1-1.pdf
x7x1-1.pdf
 
x-xp(x)dx-xe(x)22.pdf
x-xp(x)dx-xe(x)22.pdfx-xp(x)dx-xe(x)22.pdf
x-xp(x)dx-xe(x)22.pdf
 
x---.pdf
x---.pdfx---.pdf
x---.pdf
 
X-1 Corp's total assets at the end of last year were $480-000 and its.pdf
X-1 Corp's total assets at the end of last year were $480-000 and its.pdfX-1 Corp's total assets at the end of last year were $480-000 and its.pdf
X-1 Corp's total assets at the end of last year were $480-000 and its.pdf
 
X Most sensory neurons belong to what structural type of neurons- Sele.pdf
X Most sensory neurons belong to what structural type of neurons- Sele.pdfX Most sensory neurons belong to what structural type of neurons- Sele.pdf
X Most sensory neurons belong to what structural type of neurons- Sele.pdf
 
x This is teice the prosabity ol he reptat vifendes thingetsabilias ar.pdf
x This is teice the prosabity ol he reptat vifendes thingetsabilias ar.pdfx This is teice the prosabity ol he reptat vifendes thingetsabilias ar.pdf
x This is teice the prosabity ol he reptat vifendes thingetsabilias ar.pdf
 
X is a discrete random variable with probability density function f gi.pdf
X is a discrete random variable with probability density function f gi.pdfX is a discrete random variable with probability density function f gi.pdf
X is a discrete random variable with probability density function f gi.pdf
 
X and Y are independently distributed random variables- The marginal d (1).pdf
X and Y are independently distributed random variables- The marginal d (1).pdfX and Y are independently distributed random variables- The marginal d (1).pdf
X and Y are independently distributed random variables- The marginal d (1).pdf
 
X 3- What gets printed- 14.pdf
X 3- What gets printed- 14.pdfX 3- What gets printed- 14.pdf
X 3- What gets printed- 14.pdf
 
x AutoSave Ooff File for Midterm - Excel File Home Insert Draw Page L.pdf
x AutoSave Ooff  File for Midterm - Excel File Home Insert Draw Page L.pdfx AutoSave Ooff  File for Midterm - Excel File Home Insert Draw Page L.pdf
x AutoSave Ooff File for Midterm - Excel File Home Insert Draw Page L.pdf
 
Wynn Farms reported a net operating loss of $195-000 for financial rep.pdf
Wynn Farms reported a net operating loss of $195-000 for financial rep.pdfWynn Farms reported a net operating loss of $195-000 for financial rep.pdf
Wynn Farms reported a net operating loss of $195-000 for financial rep.pdf
 
Writing the Meanings of Word Parts Write the meanings of the following.pdf
Writing the Meanings of Word Parts Write the meanings of the following.pdfWriting the Meanings of Word Parts Write the meanings of the following.pdf
Writing the Meanings of Word Parts Write the meanings of the following.pdf
 
Write your standard C++ codes to do the following (for class both inte.pdf
Write your standard C++ codes to do the following (for class both inte.pdfWrite your standard C++ codes to do the following (for class both inte.pdf
Write your standard C++ codes to do the following (for class both inte.pdf
 
Write the SQL code to generate the total hours worked and the total ch.pdf
Write the SQL code to generate the total hours worked and the total ch.pdfWrite the SQL code to generate the total hours worked and the total ch.pdf
Write the SQL code to generate the total hours worked and the total ch.pdf
 
Write the pseudocode snippet to declare and initialise the following a.pdf
Write the pseudocode snippet to declare and initialise the following a.pdfWrite the pseudocode snippet to declare and initialise the following a.pdf
Write the pseudocode snippet to declare and initialise the following a.pdf
 
Write the java statement that should appear after the comments- (After.pdf
Write the java statement that should appear after the comments- (After.pdfWrite the java statement that should appear after the comments- (After.pdf
Write the java statement that should appear after the comments- (After.pdf
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 

x86_64 Assembly program output is 54321 want it to be 12345 section.pdf

  • 1. 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
  • 2. 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
  • 3. 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.