SlideShare ist ein Scribd-Unternehmen logo
1 von 2
Given the following C function, implement the equivalent assembly language function, int
returnLength(char *myArray, int *length) { int i; i = 0; while (myarray[i] !=0) { myarray[i] -
myarray[i) & 0x0F; i+ +;} *length = i; return(value);}
Solution
;Assume that all general purpose registers (rax, rbx, rcx and rdx) are saved before calling the
following assembly language procedure. Also, the following procedure assumes that the pointer
(address) to "myArray" is contained inside the register, "rdx" and pointer (address) to the
parameter "length" is contained inside the register, "rcx".
;The return value (length of the string) will be available inside the register, "eax", after the
procedure returns.
; Procedure to return the length of a string
ReturnLength PROC NEAR PUBLIC
mov DWORD PTR[rcx], 0 ; Initialize length with 0
jmp LOOP2
LOOP1:
mov eax, DWORD PTR [rcx]
movsx rbx, eax
add rbx, rdx
movzx eax, BYTE PTR [rbx] ; eax will contain the character at ith location
and eax, 15 ; and the character value with 0x0F
mov BYTE PTR [rbx], al ; store the result back at the same location
add DWORD PTR [ecx], 1 ; increment i (length) by 1
LOOP2: ; Checks the while loop and if is not end of the string,
then jums to LOOP1.
mov eax, DWORD PTR [rcx] ; assign i to eax
movsx rbx, eax
add rbx, rdx
movzx eax, BYTE PTR [rbx] ; Get the character at the ith location
test al, al ; Check whether it is NULL character
jne LOOP1 ; If not end of string jump to LOOP1 to peroform the operations
given in while loop
mov eax, DWORD PTR [rcx] ; store the final length in eax and return
ret
ReturnLength ENDP

Weitere ähnliche Inhalte

Ähnlich wie Given the following C function- implement the equivalent assembly lang.docx

Array and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxArray and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxJumanneChiyanda
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfgiriraj65
 
Lesson 24. Phantom errors
Lesson 24. Phantom errorsLesson 24. Phantom errors
Lesson 24. Phantom errorsPVS-Studio
 
Implement an MPI program to perform matrix-matrix multiplication AB .pdf
Implement an MPI program to perform matrix-matrix multiplication AB .pdfImplement an MPI program to perform matrix-matrix multiplication AB .pdf
Implement an MPI program to perform matrix-matrix multiplication AB .pdfmeerobertsonheyde608
 
Analysing space complexity of various encryption algorithms 2
Analysing space complexity of various encryption algorithms 2Analysing space complexity of various encryption algorithms 2
Analysing space complexity of various encryption algorithms 2IAEME Publication
 
I have question in c++ program I need the answer as soon as possible.docx
I have question in c++ program I need the answer as soon as possible.docxI have question in c++ program I need the answer as soon as possible.docx
I have question in c++ program I need the answer as soon as possible.docxdelciegreeks
 
ImplementingCryptoSecurityARMCortex_Doin
ImplementingCryptoSecurityARMCortex_DoinImplementingCryptoSecurityARMCortex_Doin
ImplementingCryptoSecurityARMCortex_DoinJonny Doin
 
Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"Yulia Tsisyk
 
State of the .Net Performance
State of the .Net PerformanceState of the .Net Performance
State of the .Net PerformanceCUSTIS
 
Lec2&3 data structure
Lec2&3 data structureLec2&3 data structure
Lec2&3 data structureSaad Gabr
 
CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011Deepak Singh
 
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptxsangeeta borde
 

Ähnlich wie Given the following C function- implement the equivalent assembly lang.docx (20)

Array and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxArray and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptx
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdf
 
Lesson 24. Phantom errors
Lesson 24. Phantom errorsLesson 24. Phantom errors
Lesson 24. Phantom errors
 
Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
 
posix.pdf
posix.pdfposix.pdf
posix.pdf
 
C
CC
C
 
Implement an MPI program to perform matrix-matrix multiplication AB .pdf
Implement an MPI program to perform matrix-matrix multiplication AB .pdfImplement an MPI program to perform matrix-matrix multiplication AB .pdf
Implement an MPI program to perform matrix-matrix multiplication AB .pdf
 
Blazing Fast Windows 8 Apps using Visual C++
Blazing Fast Windows 8 Apps using Visual C++Blazing Fast Windows 8 Apps using Visual C++
Blazing Fast Windows 8 Apps using Visual C++
 
Managing console input
Managing console inputManaging console input
Managing console input
 
Analysing space complexity of various encryption algorithms 2
Analysing space complexity of various encryption algorithms 2Analysing space complexity of various encryption algorithms 2
Analysing space complexity of various encryption algorithms 2
 
Unit 3
Unit 3 Unit 3
Unit 3
 
I have question in c++ program I need the answer as soon as possible.docx
I have question in c++ program I need the answer as soon as possible.docxI have question in c++ program I need the answer as soon as possible.docx
I have question in c++ program I need the answer as soon as possible.docx
 
ImplementingCryptoSecurityARMCortex_Doin
ImplementingCryptoSecurityARMCortex_DoinImplementingCryptoSecurityARMCortex_Doin
ImplementingCryptoSecurityARMCortex_Doin
 
Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"
 
State of the .Net Performance
State of the .Net PerformanceState of the .Net Performance
State of the .Net Performance
 
Lec2&3 data structure
Lec2&3 data structureLec2&3 data structure
Lec2&3 data structure
 
Lec2
Lec2Lec2
Lec2
 
Lec2&3_DataStructure
Lec2&3_DataStructureLec2&3_DataStructure
Lec2&3_DataStructure
 
CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011
 
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
 

Mehr von delicecogupdyke

You have been learning about Urie Bronfenbrenner this week- Let's mak.docx
You have been learning about Urie Bronfenbrenner this week-  Let's mak.docxYou have been learning about Urie Bronfenbrenner this week-  Let's mak.docx
You have been learning about Urie Bronfenbrenner this week- Let's mak.docxdelicecogupdyke
 
You encounter a flat green organism growing on a rock with no obvious.docx
You encounter a flat green organism growing on a rock with no obvious.docxYou encounter a flat green organism growing on a rock with no obvious.docx
You encounter a flat green organism growing on a rock with no obvious.docxdelicecogupdyke
 
You are the PR specialist for St- John's Ambulance- The organization w.docx
You are the PR specialist for St- John's Ambulance- The organization w.docxYou are the PR specialist for St- John's Ambulance- The organization w.docx
You are the PR specialist for St- John's Ambulance- The organization w.docxdelicecogupdyke
 
You are the CFO of a large academic medical center and your organizati (1).docx
You are the CFO of a large academic medical center and your organizati (1).docxYou are the CFO of a large academic medical center and your organizati (1).docx
You are the CFO of a large academic medical center and your organizati (1).docxdelicecogupdyke
 
You are on a field trip with your bio class- Your water sample from a.docx
You are on a field trip with your bio class- Your water sample from a.docxYou are on a field trip with your bio class- Your water sample from a.docx
You are on a field trip with your bio class- Your water sample from a.docxdelicecogupdyke
 
You are fortunate to travel to a tropical forest- You find an insect o.docx
You are fortunate to travel to a tropical forest- You find an insect o.docxYou are fortunate to travel to a tropical forest- You find an insect o.docx
You are fortunate to travel to a tropical forest- You find an insect o.docxdelicecogupdyke
 
You are a Government employee working in the Human Resources departmen.docx
You are a Government employee working in the Human Resources departmen.docxYou are a Government employee working in the Human Resources departmen.docx
You are a Government employee working in the Human Resources departmen.docxdelicecogupdyke
 
You are a genetic cownselar- A single mother cnmes to vou- where both.docx
You are a genetic cownselar- A single mother cnmes to vou- where both.docxYou are a genetic cownselar- A single mother cnmes to vou- where both.docx
You are a genetic cownselar- A single mother cnmes to vou- where both.docxdelicecogupdyke
 
Write the following report that can be a powerpoint presentation-The g.docx
Write the following report that can be a powerpoint presentation-The g.docxWrite the following report that can be a powerpoint presentation-The g.docx
Write the following report that can be a powerpoint presentation-The g.docxdelicecogupdyke
 
Write two functions using the Front and Back Linear Search algorithms-.docx
Write two functions using the Front and Back Linear Search algorithms-.docxWrite two functions using the Front and Back Linear Search algorithms-.docx
Write two functions using the Front and Back Linear Search algorithms-.docxdelicecogupdyke
 
xpected to grow geometrically- (Assume that interactions ith other spe.docx
xpected to grow geometrically- (Assume that interactions ith other spe.docxxpected to grow geometrically- (Assume that interactions ith other spe.docx
xpected to grow geometrically- (Assume that interactions ith other spe.docxdelicecogupdyke
 
Write the pseudocode for Python for the following- from Celsius to Fah.docx
Write the pseudocode for Python for the following- from Celsius to Fah.docxWrite the pseudocode for Python for the following- from Celsius to Fah.docx
Write the pseudocode for Python for the following- from Celsius to Fah.docxdelicecogupdyke
 
Write the definition of the linkedListKeepLast function- (Please write.docx
Write the definition of the linkedListKeepLast function- (Please write.docxWrite the definition of the linkedListKeepLast function- (Please write.docx
Write the definition of the linkedListKeepLast function- (Please write.docxdelicecogupdyke
 
Write SQL commands that convert the Database schema to Tables with the.docx
Write SQL commands that convert the Database schema to Tables with the.docxWrite SQL commands that convert the Database schema to Tables with the.docx
Write SQL commands that convert the Database schema to Tables with the.docxdelicecogupdyke
 
write the adjusting entries for following Given Data-.docx
write the adjusting entries for following    Given Data-.docxwrite the adjusting entries for following    Given Data-.docx
write the adjusting entries for following Given Data-.docxdelicecogupdyke
 
Write python code to collect 1000 posts from Twitter- or Facebook- or.docx
Write python code to collect 1000 posts from Twitter- or Facebook- or.docxWrite python code to collect 1000 posts from Twitter- or Facebook- or.docx
Write python code to collect 1000 posts from Twitter- or Facebook- or.docxdelicecogupdyke
 
write one to two paragraphs on the significance about Jati Explain how.docx
write one to two paragraphs on the significance about Jati Explain how.docxwrite one to two paragraphs on the significance about Jati Explain how.docx
write one to two paragraphs on the significance about Jati Explain how.docxdelicecogupdyke
 
Write in C++ Calculate the mean of a vector of floating point numbers.docx
Write in C++ Calculate the mean of a vector of floating point numbers.docxWrite in C++ Calculate the mean of a vector of floating point numbers.docx
Write in C++ Calculate the mean of a vector of floating point numbers.docxdelicecogupdyke
 
Write down the code that will count the number of clicks for a LIKE bu.docx
Write down the code that will count the number of clicks for a LIKE bu.docxWrite down the code that will count the number of clicks for a LIKE bu.docx
Write down the code that will count the number of clicks for a LIKE bu.docxdelicecogupdyke
 
Write declarations for variables p1 and p2 whose values will be addres.docx
Write declarations for variables p1 and p2 whose values will be addres.docxWrite declarations for variables p1 and p2 whose values will be addres.docx
Write declarations for variables p1 and p2 whose values will be addres.docxdelicecogupdyke
 

Mehr von delicecogupdyke (20)

You have been learning about Urie Bronfenbrenner this week- Let's mak.docx
You have been learning about Urie Bronfenbrenner this week-  Let's mak.docxYou have been learning about Urie Bronfenbrenner this week-  Let's mak.docx
You have been learning about Urie Bronfenbrenner this week- Let's mak.docx
 
You encounter a flat green organism growing on a rock with no obvious.docx
You encounter a flat green organism growing on a rock with no obvious.docxYou encounter a flat green organism growing on a rock with no obvious.docx
You encounter a flat green organism growing on a rock with no obvious.docx
 
You are the PR specialist for St- John's Ambulance- The organization w.docx
You are the PR specialist for St- John's Ambulance- The organization w.docxYou are the PR specialist for St- John's Ambulance- The organization w.docx
You are the PR specialist for St- John's Ambulance- The organization w.docx
 
You are the CFO of a large academic medical center and your organizati (1).docx
You are the CFO of a large academic medical center and your organizati (1).docxYou are the CFO of a large academic medical center and your organizati (1).docx
You are the CFO of a large academic medical center and your organizati (1).docx
 
You are on a field trip with your bio class- Your water sample from a.docx
You are on a field trip with your bio class- Your water sample from a.docxYou are on a field trip with your bio class- Your water sample from a.docx
You are on a field trip with your bio class- Your water sample from a.docx
 
You are fortunate to travel to a tropical forest- You find an insect o.docx
You are fortunate to travel to a tropical forest- You find an insect o.docxYou are fortunate to travel to a tropical forest- You find an insect o.docx
You are fortunate to travel to a tropical forest- You find an insect o.docx
 
You are a Government employee working in the Human Resources departmen.docx
You are a Government employee working in the Human Resources departmen.docxYou are a Government employee working in the Human Resources departmen.docx
You are a Government employee working in the Human Resources departmen.docx
 
You are a genetic cownselar- A single mother cnmes to vou- where both.docx
You are a genetic cownselar- A single mother cnmes to vou- where both.docxYou are a genetic cownselar- A single mother cnmes to vou- where both.docx
You are a genetic cownselar- A single mother cnmes to vou- where both.docx
 
Write the following report that can be a powerpoint presentation-The g.docx
Write the following report that can be a powerpoint presentation-The g.docxWrite the following report that can be a powerpoint presentation-The g.docx
Write the following report that can be a powerpoint presentation-The g.docx
 
Write two functions using the Front and Back Linear Search algorithms-.docx
Write two functions using the Front and Back Linear Search algorithms-.docxWrite two functions using the Front and Back Linear Search algorithms-.docx
Write two functions using the Front and Back Linear Search algorithms-.docx
 
xpected to grow geometrically- (Assume that interactions ith other spe.docx
xpected to grow geometrically- (Assume that interactions ith other spe.docxxpected to grow geometrically- (Assume that interactions ith other spe.docx
xpected to grow geometrically- (Assume that interactions ith other spe.docx
 
Write the pseudocode for Python for the following- from Celsius to Fah.docx
Write the pseudocode for Python for the following- from Celsius to Fah.docxWrite the pseudocode for Python for the following- from Celsius to Fah.docx
Write the pseudocode for Python for the following- from Celsius to Fah.docx
 
Write the definition of the linkedListKeepLast function- (Please write.docx
Write the definition of the linkedListKeepLast function- (Please write.docxWrite the definition of the linkedListKeepLast function- (Please write.docx
Write the definition of the linkedListKeepLast function- (Please write.docx
 
Write SQL commands that convert the Database schema to Tables with the.docx
Write SQL commands that convert the Database schema to Tables with the.docxWrite SQL commands that convert the Database schema to Tables with the.docx
Write SQL commands that convert the Database schema to Tables with the.docx
 
write the adjusting entries for following Given Data-.docx
write the adjusting entries for following    Given Data-.docxwrite the adjusting entries for following    Given Data-.docx
write the adjusting entries for following Given Data-.docx
 
Write python code to collect 1000 posts from Twitter- or Facebook- or.docx
Write python code to collect 1000 posts from Twitter- or Facebook- or.docxWrite python code to collect 1000 posts from Twitter- or Facebook- or.docx
Write python code to collect 1000 posts from Twitter- or Facebook- or.docx
 
write one to two paragraphs on the significance about Jati Explain how.docx
write one to two paragraphs on the significance about Jati Explain how.docxwrite one to two paragraphs on the significance about Jati Explain how.docx
write one to two paragraphs on the significance about Jati Explain how.docx
 
Write in C++ Calculate the mean of a vector of floating point numbers.docx
Write in C++ Calculate the mean of a vector of floating point numbers.docxWrite in C++ Calculate the mean of a vector of floating point numbers.docx
Write in C++ Calculate the mean of a vector of floating point numbers.docx
 
Write down the code that will count the number of clicks for a LIKE bu.docx
Write down the code that will count the number of clicks for a LIKE bu.docxWrite down the code that will count the number of clicks for a LIKE bu.docx
Write down the code that will count the number of clicks for a LIKE bu.docx
 
Write declarations for variables p1 and p2 whose values will be addres.docx
Write declarations for variables p1 and p2 whose values will be addres.docxWrite declarations for variables p1 and p2 whose values will be addres.docx
Write declarations for variables p1 and p2 whose values will be addres.docx
 

Kürzlich hochgeladen

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Kürzlich hochgeladen (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 

Given the following C function- implement the equivalent assembly lang.docx

  • 1. Given the following C function, implement the equivalent assembly language function, int returnLength(char *myArray, int *length) { int i; i = 0; while (myarray[i] !=0) { myarray[i] - myarray[i) & 0x0F; i+ +;} *length = i; return(value);} Solution ;Assume that all general purpose registers (rax, rbx, rcx and rdx) are saved before calling the following assembly language procedure. Also, the following procedure assumes that the pointer (address) to "myArray" is contained inside the register, "rdx" and pointer (address) to the parameter "length" is contained inside the register, "rcx". ;The return value (length of the string) will be available inside the register, "eax", after the procedure returns. ; Procedure to return the length of a string ReturnLength PROC NEAR PUBLIC mov DWORD PTR[rcx], 0 ; Initialize length with 0 jmp LOOP2 LOOP1: mov eax, DWORD PTR [rcx] movsx rbx, eax add rbx, rdx movzx eax, BYTE PTR [rbx] ; eax will contain the character at ith location and eax, 15 ; and the character value with 0x0F mov BYTE PTR [rbx], al ; store the result back at the same location
  • 2. add DWORD PTR [ecx], 1 ; increment i (length) by 1 LOOP2: ; Checks the while loop and if is not end of the string, then jums to LOOP1. mov eax, DWORD PTR [rcx] ; assign i to eax movsx rbx, eax add rbx, rdx movzx eax, BYTE PTR [rbx] ; Get the character at the ith location test al, al ; Check whether it is NULL character jne LOOP1 ; If not end of string jump to LOOP1 to peroform the operations given in while loop mov eax, DWORD PTR [rcx] ; store the final length in eax and return ret ReturnLength ENDP