SlideShare a Scribd company logo
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
Consider the following C code snippet C codevoid setArray(int.pdf
PDF
Lenguaje ensamblador EMU8086
PDF
Laboratory Report Sample
PDF
8051 assembly programming
PDF
Taller practico emu8086_galarraga
PDF
Marco acosta emu
Please convert the following C code to assembly Y86int i,j; ......pdf
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdf
Consider the following C code snippet C codevoid setArray(int.pdf
Lenguaje ensamblador EMU8086
Laboratory Report Sample
8051 assembly programming
Taller practico emu8086_galarraga
Marco acosta emu

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

PPTX
HDL17_MIPS CPU Design using Verilog.pptx
PDF
instruction set of 8086
PPT
12 mt06ped008
PPT
ARM Fundamentals
PPT
COMPUTER ARCHITECTURE MIPS INTRODUCTION ISA
PDF
Emuladores
PPT
Al2ed chapter13
PPTX
Instruction Set Architecture: MIPS
PDF
Instalación de emu8086 y compilados
PPT
Lec18 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- In...
PPTX
PPTX
PDF
Masm tutorial
PDF
Section 1 8051 microcontroller instruction set
PPT
1347 Assembly Language Programming Of 8051
PPT
8051 Instruction Set
PDF
mca is a microcontroller and accmulator is a third year couse
PPT
14941634.ppt
PPT
Microcontroller 8051- soft.ppt
HDL17_MIPS CPU Design using Verilog.pptx
instruction set of 8086
12 mt06ped008
ARM Fundamentals
COMPUTER ARCHITECTURE MIPS INTRODUCTION ISA
Emuladores
Al2ed chapter13
Instruction Set Architecture: MIPS
Instalación de emu8086 y compilados
Lec18 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- In...
Masm tutorial
Section 1 8051 microcontroller instruction set
1347 Assembly Language Programming Of 8051
8051 Instruction Set
mca is a microcontroller and accmulator is a third year couse
14941634.ppt
Microcontroller 8051- soft.ppt
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
Yogi Goddess Pres Conference Studio Updates
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PDF
Trump Administration's workforce development strategy
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Classroom Observation Tools for Teachers
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Lesson notes of climatology university.
PDF
RMMM.pdf make it easy to upload and study
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
Complications of Minimal Access Surgery at WLH
Yogi Goddess Pres Conference Studio Updates
Weekly quiz Compilation Jan -July 25.pdf
Cell Structure & Organelles in detailed.
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Supply Chain Operations Speaking Notes -ICLT Program
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
Trump Administration's workforce development strategy
UNIT III MENTAL HEALTH NURSING ASSESSMENT
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Classroom Observation Tools for Teachers
2.FourierTransform-ShortQuestionswithAnswers.pdf
Final Presentation General Medicine 03-08-2024.pptx
Lesson notes of climatology university.
RMMM.pdf make it easy to upload and study
A systematic review of self-coping strategies used by university students to ...
Paper A Mock Exam 9_ Attempt review.pdf.
Complications of Minimal Access Surgery at WLH

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