Please convert the following C code to assembly Y86
int i,j; .....
if (i >j) {
i= i+5;
} else {
i=0;
j++;
}
Solution
Answer:
MIPS Assembly Language Code :
.zero 1
main:
push rbp
mov rbp, rsp
mov eax, DWORD PTR [rbp-4]
cmp eax, DWORD PTR [rbp-8]
jle .L2
add DWORD PTR [rbp-4], 5
jmp .L3
.L2:
mov DWORD PTR [rbp-4], 0
add DWORD PTR [rbp-8], 1
.L3:
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 j,k; .....pdf
PDF
How would you write this in MARIE assembly languageint count = 0;.pdf
PDF
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdf
PDF
Write a program in MIPS that reads in a Roman form number from th.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
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 j,k; .....pdf
How would you write this in MARIE assembly languageint count = 0;.pdf
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdf
Write a program in MIPS that reads in a Roman form number from th.pdf
Translate the following CC++ code into MIPS Assembly Codevoid ch.pdf
Implement an MPI program to perform matrix-matrix multiplication AB .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 i,j; ......pdf (20)

PDF
OptimizingARM
PPTX
Защищая С++. Павел Филонов ➠ CoreHard Autumn 2019
PPTX
Protecting C++
PPTX
Chapter_04_ARM_Assembly ARM assembly language is the low-level programming.pptx
PDF
Vc4c development of opencl compiler for videocore4
PPT
Chapter Eight(3)
PPTX
C++ and Assembly: Debugging and Reverse Engineering
PDF
Pragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
PPTX
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
PDF
Write a Pep8 Assembly program that reads in and stores two integers .pdf
PDF
M.A.R.I.E assembly code for 7th value of Fibonacci sequence Fib(1) .pdf
PPT
Microcontroller 8051- soft.ppt
PPT
Arm Cortex material Arm Cortex material3222886.ppt
PDF
lec15_x86procedure_4up.pdf
PPT
PDF
HHVM on AArch64 - BUD17-400K1
PDF
Visual Studio를 이용한 어셈블리어 학습 part 2
PPT
EMBEDDED SYSTEMS 4&5
PDF
Qemu JIT Code Generator and System Emulation
PDF
Course lecture - An introduction to the Return Oriented Programming
OptimizingARM
Защищая С++. Павел Филонов ➠ CoreHard Autumn 2019
Protecting C++
Chapter_04_ARM_Assembly ARM assembly language is the low-level programming.pptx
Vc4c development of opencl compiler for videocore4
Chapter Eight(3)
C++ and Assembly: Debugging and Reverse Engineering
Pragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Write a Pep8 Assembly program that reads in and stores two integers .pdf
M.A.R.I.E assembly code for 7th value of Fibonacci sequence Fib(1) .pdf
Microcontroller 8051- soft.ppt
Arm Cortex material Arm Cortex material3222886.ppt
lec15_x86procedure_4up.pdf
HHVM on AArch64 - BUD17-400K1
Visual Studio를 이용한 어셈블리어 학습 part 2
EMBEDDED SYSTEMS 4&5
Qemu JIT Code Generator and System Emulation
Course lecture - An introduction to the Return Oriented Programming

More from SIGMATAX1 (20)

PDF
Consider a binary search tree T with nodes containing the four fields.pdf
PDF
Based on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdf
PDF
Comparecontrast the following classes of hormones by identifying thr.pdf
PDF
Why does the incidence of acute disease decrease with ageSoluti.pdf
PDF
White eye color in Drosophila was discovered to be sex linked by Tho.pdf
PDF
Which of the following protons would you NOT expect to find embedded .pdf
PDF
Which of these characteristics distinguishes angiosperms from other .pdf
PDF
Which of the following is MOST responsible for maintaining the doubl.pdf
PDF
What are the role of environmental factors on transpiration and h.pdf
PDF
What will be quantization step size in numbers and in voltage for th.pdf
PDF
What is the need for a shadow page table (One or two brief sentences.pdf
PDF
What step of protein synthesis is shown in the figure elongation st.pdf
PDF
Water is forced through a contraction causing low pressure. The wat.pdf
PDF
Using a PIC 18 Write a time overflow interrupt routine that detects .pdf
PDF
The three types of mixtures are and The weak bond forming a bridge .pdf
PDF
Some commercial airplanes recirculate approximately 50 of the cabin .pdf
PDF
Solve for 02 sin 2+sin 5=0. Separate your answers with commas.pdf
PDF
Required 1. Briefly describe different computer controls available .pdf
PDF
a. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdf
PDF
Proponents of decentralized forms of socialism usually supportA co.pdf
Consider a binary search tree T with nodes containing the four fields.pdf
Based on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdf
Comparecontrast the following classes of hormones by identifying thr.pdf
Why does the incidence of acute disease decrease with ageSoluti.pdf
White eye color in Drosophila was discovered to be sex linked by Tho.pdf
Which of the following protons would you NOT expect to find embedded .pdf
Which of these characteristics distinguishes angiosperms from other .pdf
Which of the following is MOST responsible for maintaining the doubl.pdf
What are the role of environmental factors on transpiration and h.pdf
What will be quantization step size in numbers and in voltage for th.pdf
What is the need for a shadow page table (One or two brief sentences.pdf
What step of protein synthesis is shown in the figure elongation st.pdf
Water is forced through a contraction causing low pressure. The wat.pdf
Using a PIC 18 Write a time overflow interrupt routine that detects .pdf
The three types of mixtures are and The weak bond forming a bridge .pdf
Some commercial airplanes recirculate approximately 50 of the cabin .pdf
Solve for 02 sin 2+sin 5=0. Separate your answers with commas.pdf
Required 1. Briefly describe different computer controls available .pdf
a. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdf
Proponents of decentralized forms of socialism usually supportA co.pdf

Recently uploaded (20)

PDF
advance database management system book.pdf
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
What if we spent less time fighting change, and more time building what’s rig...
PPTX
20th Century Theater, Methods, History.pptx
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
Empowerment Technology for Senior High School Guide
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
HVAC Specification 2024 according to central public works department
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PPTX
Introduction to pro and eukaryotes and differences.pptx
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
advance database management system book.pdf
LDMMIA Reiki Yoga Finals Review Spring Summer
What if we spent less time fighting change, and more time building what’s rig...
20th Century Theater, Methods, History.pptx
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
Paper A Mock Exam 9_ Attempt review.pdf.
Chinmaya Tiranga quiz Grand Finale.pdf
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
TNA_Presentation-1-Final(SAVE)) (1).pptx
FORM 1 BIOLOGY MIND MAPS and their schemes
Unit 4 Computer Architecture Multicore Processor.pptx
Empowerment Technology for Senior High School Guide
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
HVAC Specification 2024 according to central public works department
Share_Module_2_Power_conflict_and_negotiation.pptx
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Introduction to pro and eukaryotes and differences.pptx
202450812 BayCHI UCSC-SV 20250812 v17.pptx
A powerpoint presentation on the Revised K-10 Science Shaping Paper

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

  • 1. Please convert the following C code to assembly Y86 int i,j; ..... if (i >j) { i= i+5; } else { i=0; j++; } Solution Answer: MIPS Assembly Language Code : .zero 1 main: push rbp mov rbp, rsp mov eax, DWORD PTR [rbp-4] cmp eax, DWORD PTR [rbp-8] jle .L2 add DWORD PTR [rbp-4], 5 jmp .L3 .L2: mov DWORD PTR [rbp-4], 0 add DWORD PTR [rbp-8], 1 .L3: 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
  • 2. 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