Please convert the following C code to assembly Y86
int j,k;
.....
for (int i=0; i <5; i++) {
j = i*2;
k = j+1;
}
Solution
Answer:
MIPS Assembly Langauge Code :
.zero 1
main:
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-4], 0
.L3:
cmp DWORD PTR [rbp-4], 4
jg .L2
mov eax, DWORD PTR [rbp-4]
add eax, eax
mov DWORD PTR [rbp-8], eax
mov eax, DWORD PTR [rbp-8]
add eax, 1
mov DWORD PTR [rbp-12], eax
add DWORD PTR [rbp-4], 1
jmp .L3
.L2:
mov eax, 0
pop rbp
ret
__static_initialization_and_destruction_0(int, int):
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], edi
mov DWORD PTR [rbp-8], esi
cmp DWORD PTR [rbp-4], 1
jne .L7
cmp DWORD PTR [rbp-8], 65535
jne .L7
mov edi, OFFSET FLAT:std::__ioinit
call std::ios_base::Init::Init()
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:std::__ioinit
mov edi, OFFSET FLAT:std::ios_base::Init::~Init()
call __cxa_atexit
.L7:
nop
leave
ret
push rbp
mov rbp, rsp
mov esi, 65535
mov edi, 1
call __static_initialization_and_destruction_0(int, int)
pop rbp
ret

More Related Content

PDF
Please convert the following C code to assembly Y86int i,j; ......pdf
PDF
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdf
PDF
How would you write this in MARIE assembly languageint count = 0;.pdf
PDF
Translate the following CC++ code into MIPS Assembly Codevoid ch.pdf
PDF
Implement an MPI program to perform matrix-matrix multiplication AB .pdf
PDF
Write a program in MIPS that reads in a Roman form number from th.pdf
PDF
WCTF 2018 binja Editorial
PDF
Write an MPI program that implements a shell-sort like parallel algo.pdf
Please convert the following C code to assembly Y86int i,j; ......pdf
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdf
How would you write this in MARIE assembly languageint count = 0;.pdf
Translate the following CC++ code into MIPS Assembly Codevoid ch.pdf
Implement an MPI program to perform matrix-matrix multiplication AB .pdf
Write a program in MIPS that reads in a Roman form number from th.pdf
WCTF 2018 binja Editorial
Write an MPI program that implements a shell-sort like parallel algo.pdf

Similar to Please convert the following C code to assembly Y86int j,k; .....pdf (20)

PPTX
Защищая С++. Павел Филонов ➠ CoreHard Autumn 2019
PPTX
Protecting C++
PDF
OptimizingARM
PPTX
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
DOCX
1. For each instruction, give the 80x86 opcode and total number of b.docx
PPTX
C++ and Assembly: Debugging and Reverse Engineering
PDF
HHVM on AArch64 - BUD17-400K1
PDF
Pragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
PPT
PPT
Chapter Eight(3)
PDF
Vc4c development of opencl compiler for videocore4
PDF
Javascript engine performance
PPTX
Basic ASM by @binaryheadache
PDF
Return Oriented Programming - ROP
PDF
Devirtualizing FinSpy
PDF
Make ARM Shellcode Great Again - HITB2018PEK
PDF
lec15_x86procedure_4up.pdf
PDF
Visual Studio를 이용한 어셈블리어 학습 part 2
PPTX
Chapter_04_ARM_Assembly ARM assembly language is the low-level programming.pptx
PPT
EMBEDDED SYSTEMS 4&5
Защищая С++. Павел Филонов ➠ CoreHard Autumn 2019
Protecting C++
OptimizingARM
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
1. For each instruction, give the 80x86 opcode and total number of b.docx
C++ and Assembly: Debugging and Reverse Engineering
HHVM on AArch64 - BUD17-400K1
Pragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
Chapter Eight(3)
Vc4c development of opencl compiler for videocore4
Javascript engine performance
Basic ASM by @binaryheadache
Return Oriented Programming - ROP
Devirtualizing FinSpy
Make ARM Shellcode Great Again - HITB2018PEK
lec15_x86procedure_4up.pdf
Visual Studio를 이용한 어셈블리어 학습 part 2
Chapter_04_ARM_Assembly ARM assembly language is the low-level programming.pptx
EMBEDDED SYSTEMS 4&5
Ad

More from foottraders (20)

PDF
Meredith Ward is the assistant chief accountant at Frazier Company, .pdf
PDF
In mathematics, a formula is a(n)A.expression of the value of.pdf
PDF
Landless Corporation currently has 120,000 shares outstanding of $1 .pdf
PDF
Following are some transactions and events of Business Solutions. Feb.pdf
PDF
Each of the following termsphrases conceptually falls into one of t.pdf
PDF
Dinosaur fossils are often dated by using an element other than carbo.pdf
PDF
Discuss the term renaissance (what does it mean) and the developmen.pdf
PDF
Consider a binary SNP matrix M with 1 representing the derived allele.pdf
PDF
Can someone explain to me the classification of PRRs in immuniology.pdf
PDF
An empty soda can has been submitted as evidence. Name at least two .pdf
PDF
All Newsweek (March 20. 2011) Theyre the sort of scores that driv.pdf
PDF
a. What is structure a.... b. Are the contents of structure haploid.pdf
PDF
5. Which of the following is NOT a function of foreign exchange mark.pdf
PDF
Which of the following provide evidence of biological evolution a. .pdf
PDF
Which of the following is necessary in order for an explanation to b.pdf
PDF
When does the centrosome duplicateIn parallel to chromosome segre.pdf
PDF
What are some differences between public sector and private sector b.pdf
PDF
Two days later the patient reports to the infrmary with a severe hea.pdf
PDF
The “Impartial Spectator” described by Adam Smith isa -An imparti.pdf
PDF
1. What are some applications of stored procedure2. How triggers .pdf
Meredith Ward is the assistant chief accountant at Frazier Company, .pdf
In mathematics, a formula is a(n)A.expression of the value of.pdf
Landless Corporation currently has 120,000 shares outstanding of $1 .pdf
Following are some transactions and events of Business Solutions. Feb.pdf
Each of the following termsphrases conceptually falls into one of t.pdf
Dinosaur fossils are often dated by using an element other than carbo.pdf
Discuss the term renaissance (what does it mean) and the developmen.pdf
Consider a binary SNP matrix M with 1 representing the derived allele.pdf
Can someone explain to me the classification of PRRs in immuniology.pdf
An empty soda can has been submitted as evidence. Name at least two .pdf
All Newsweek (March 20. 2011) Theyre the sort of scores that driv.pdf
a. What is structure a.... b. Are the contents of structure haploid.pdf
5. Which of the following is NOT a function of foreign exchange mark.pdf
Which of the following provide evidence of biological evolution a. .pdf
Which of the following is necessary in order for an explanation to b.pdf
When does the centrosome duplicateIn parallel to chromosome segre.pdf
What are some differences between public sector and private sector b.pdf
Two days later the patient reports to the infrmary with a severe hea.pdf
The “Impartial Spectator” described by Adam Smith isa -An imparti.pdf
1. What are some applications of stored procedure2. How triggers .pdf
Ad

Recently uploaded (20)

PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
Introduction to pro and eukaryotes and differences.pptx
PPTX
Virtual and Augmented Reality in Current Scenario
PDF
What if we spent less time fighting change, and more time building what’s rig...
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
advance database management system book.pdf
PDF
Trump Administration's workforce development strategy
PPTX
Computer Architecture Input Output Memory.pptx
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
Empowerment Technology for Senior High School Guide
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
Chinmaya Tiranga quiz Grand Finale.pdf
Introduction to pro and eukaryotes and differences.pptx
Virtual and Augmented Reality in Current Scenario
What if we spent less time fighting change, and more time building what’s rig...
B.Sc. DS Unit 2 Software Engineering.pptx
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
History, Philosophy and sociology of education (1).pptx
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
Weekly quiz Compilation Jan -July 25.pdf
advance database management system book.pdf
Trump Administration's workforce development strategy
Computer Architecture Input Output Memory.pptx
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
Empowerment Technology for Senior High School Guide
FORM 1 BIOLOGY MIND MAPS and their schemes
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
Unit 4 Computer Architecture Multicore Processor.pptx

Please convert the following C code to assembly Y86int j,k; .....pdf

  • 1. Please convert the following C code to assembly Y86 int j,k; ..... for (int i=0; i <5; i++) { j = i*2; k = j+1; } Solution Answer: MIPS Assembly Langauge Code : .zero 1 main: push rbp mov rbp, rsp mov DWORD PTR [rbp-4], 0 .L3: cmp DWORD PTR [rbp-4], 4 jg .L2 mov eax, DWORD PTR [rbp-4] add eax, eax mov DWORD PTR [rbp-8], eax mov eax, DWORD PTR [rbp-8] add eax, 1 mov DWORD PTR [rbp-12], eax add DWORD PTR [rbp-4], 1 jmp .L3 .L2: mov eax, 0 pop rbp ret __static_initialization_and_destruction_0(int, int): push rbp mov rbp, rsp
  • 2. sub rsp, 16 mov DWORD PTR [rbp-4], edi mov DWORD PTR [rbp-8], esi cmp DWORD PTR [rbp-4], 1 jne .L7 cmp DWORD PTR [rbp-8], 65535 jne .L7 mov edi, OFFSET FLAT:std::__ioinit call std::ios_base::Init::Init() mov edx, OFFSET FLAT:__dso_handle mov esi, OFFSET FLAT:std::__ioinit mov edi, OFFSET FLAT:std::ios_base::Init::~Init() call __cxa_atexit .L7: nop leave ret push rbp mov rbp, rsp mov esi, 65535 mov edi, 1 call __static_initialization_and_destruction_0(int, int) pop rbp ret