SlideShare a Scribd company logo
Finish the 2 "TODO" in the ASM Language! A palindrome is a word that is spelled the same way
forwards and backwards. For example, "radar", "racecar", "civic", "kayak", and "madam" are all
palindromes. The definition can be extended to phrases and sentences when ignore case and
punctuation, but for this exercise we will stick to a single word. The starter code provided uses the
C library functions printf and scanf to prompt for an input a word. The word that is entered from the
keyboard is a null-terminated string placed in the byte array at address buf. There are also two
output strings provided at addresses str_is_palindrome and str_is_not_palindrome. The starter
code provided simply outputs the string at str_is_not_palindrome. The code contains two TODO
comments... At the first TODO comment, the byte array at buf is filled with input from the
keyboard. This input is a null-terminated character string (i.e. the array contains the characters
entered on the keyboard, followed by ASCII 0). Here you need to determine whether or not the
string stored at buf is a palindrome. You can do this by pushing all characters onto the process
stack, then pop all characters off the stack comparing against the characters in buf. At the second
TODO comment, move either str_is_palindrome or str_is_not_palindrome to RDI to set up output
of the appropriate message. (This could potentially be incorporated into the code under the first
TODO comment if you so choose.) The program, when completed, should prompt for and input a
word, then output a message stating whether or not the word that was input is a palindrome.
global main ; exposes program entry point to the linker extern printf ; declare external function
extern scanf ; declare external function section .text ; start of code segment main: push rbp ;
preserve base pointer mov rbp,rsp ; copy stack pointer to base pointer ; Prompt for entry of a word
to test if a palindrome mov rdi,prompt ; prompt format string for printf call printf ; call printf function
from C library ; Input a word to input buffer (buf) mov rdi,fmt_str ; format string for scanf mov
rsi,buf ; address of input buffer for scanf call scanf ; call scanf function from C library ; TODO:
Check null-terminated string at buf to see if a palindrome ; TODO: Move either str_is_palindrome
or str_is_not_palindrome ; to RDI to output appropriate message mov rdi,str_is_not_palindrome ;
Output message, address of output string expected in RDI call printf ; call printf function from C
library pop rbp ; restore base pointer mov rax, 0 ; exit status (0 = success) ret section .data ; start
of initialized data segment prompt db "Enter a word: ",0 ; Prompt for entry buf_confirm db "You
entered %s.",0xa,0 str_is_palindrome db "This word is a palindrome.",0xa,0 str_is_not_palindrome
db "This word is not a palindrome.",0xa,0 fmt_str db "%s",0 ; Input format string for scanf section
.bss ; start of uninitialized data segment buf resb 100 ; input buffer, for entry of a word

More Related Content

Similar to Finish the 2 TODO in the ASM Language A palindrome is a w.pdf

Msp 430 addressing modes module 2
Msp 430 addressing modes module 2Msp 430 addressing modes module 2
Msp 430 addressing modes module 2
SARALA T
 
C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)
indrasir
 
C++ PROGRAMMING BASICS
C++ PROGRAMMING BASICSC++ PROGRAMMING BASICS
C++ PROGRAMMING BASICS
Aami Kakakhel
 

Similar to Finish the 2 TODO in the ASM Language A palindrome is a w.pdf (20)

88 c-programs
88 c-programs88 c-programs
88 c-programs
 
88 c programs 15184
88 c programs 1518488 c programs 15184
88 c programs 15184
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Function
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
 
Msp 430 addressing modes module 2
Msp 430 addressing modes module 2Msp 430 addressing modes module 2
Msp 430 addressing modes module 2
 
Unit 2- Module 2.pptx
Unit 2- Module 2.pptxUnit 2- Module 2.pptx
Unit 2- Module 2.pptx
 
Advanced+pointers
Advanced+pointersAdvanced+pointers
Advanced+pointers
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
 
Chapter3
Chapter3Chapter3
Chapter3
 
Solid C++ by Example
Solid C++ by ExampleSolid C++ by Example
Solid C++ by Example
 
Input And Output
 Input And Output Input And Output
Input And Output
 
Format String Attack
Format String AttackFormat String Attack
Format String Attack
 
C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)
 
C programming(part 3)
C programming(part 3)C programming(part 3)
C programming(part 3)
 
Buffer OverFlow
Buffer OverFlowBuffer OverFlow
Buffer OverFlow
 
miniLesson on the printf() function
miniLesson on the printf() functionminiLesson on the printf() function
miniLesson on the printf() function
 
CHAPTER 4
CHAPTER 4CHAPTER 4
CHAPTER 4
 
qb unit2 solve eem201.pdf
qb unit2 solve eem201.pdfqb unit2 solve eem201.pdf
qb unit2 solve eem201.pdf
 
runtimestack
runtimestackruntimestack
runtimestack
 
C++ PROGRAMMING BASICS
C++ PROGRAMMING BASICSC++ PROGRAMMING BASICS
C++ PROGRAMMING BASICS
 

More from ablazeaepl

how write introduction and conclusion of case study OnBoar.pdf
how write introduction and conclusion of case study  OnBoar.pdfhow write introduction and conclusion of case study  OnBoar.pdf
how write introduction and conclusion of case study OnBoar.pdf
ablazeaepl
 
For each question provide a one to two sentences per questi.pdf
For each question provide a one to two sentences per questi.pdfFor each question provide a one to two sentences per questi.pdf
For each question provide a one to two sentences per questi.pdf
ablazeaepl
 
Enter the letter of the appropriate term from the list below.pdf
Enter the letter of the appropriate term from the list below.pdfEnter the letter of the appropriate term from the list below.pdf
Enter the letter of the appropriate term from the list below.pdf
ablazeaepl
 
Adam Simmons de 25 aos tuvo un accidente de moto de nieve.pdf
Adam Simmons de 25 aos tuvo un accidente de moto de nieve.pdfAdam Simmons de 25 aos tuvo un accidente de moto de nieve.pdf
Adam Simmons de 25 aos tuvo un accidente de moto de nieve.pdf
ablazeaepl
 
217 Global warming A research poll asked 1603 Americans F.pdf
217 Global warming A research poll asked 1603 Americans F.pdf217 Global warming A research poll asked 1603 Americans F.pdf
217 Global warming A research poll asked 1603 Americans F.pdf
ablazeaepl
 
The first part of the final exam itself is an exercise in th.pdf
The first part of the final exam itself is an exercise in th.pdfThe first part of the final exam itself is an exercise in th.pdf
The first part of the final exam itself is an exercise in th.pdf
ablazeaepl
 

More from ablazeaepl (20)

Marin Companys general ledger indicates a cash balance of .pdf
Marin Companys general ledger indicates a cash balance of .pdfMarin Companys general ledger indicates a cash balance of .pdf
Marin Companys general ledger indicates a cash balance of .pdf
 
Homework Section 34 Contingency Tables Score 07 07 an.pdf
Homework Section 34 Contingency Tables Score 07 07 an.pdfHomework Section 34 Contingency Tables Score 07 07 an.pdf
Homework Section 34 Contingency Tables Score 07 07 an.pdf
 
how write introduction and conclusion of case study OnBoar.pdf
how write introduction and conclusion of case study  OnBoar.pdfhow write introduction and conclusion of case study  OnBoar.pdf
how write introduction and conclusion of case study OnBoar.pdf
 
For each question provide a one to two sentences per questi.pdf
For each question provide a one to two sentences per questi.pdfFor each question provide a one to two sentences per questi.pdf
For each question provide a one to two sentences per questi.pdf
 
Enter the letter of the appropriate term from the list below.pdf
Enter the letter of the appropriate term from the list below.pdfEnter the letter of the appropriate term from the list below.pdf
Enter the letter of the appropriate term from the list below.pdf
 
Ghana Technology University College IT213 Systems Administr.pdf
Ghana Technology University College IT213 Systems Administr.pdfGhana Technology University College IT213 Systems Administr.pdf
Ghana Technology University College IT213 Systems Administr.pdf
 
decimal places R2Ra2 b Does the estimated regression e.pdf
decimal places R2Ra2 b Does the estimated regression e.pdfdecimal places R2Ra2 b Does the estimated regression e.pdf
decimal places R2Ra2 b Does the estimated regression e.pdf
 
Describir la funcin de cada generacin en el ciclo de vida .pdf
Describir la funcin de cada generacin en el ciclo de vida .pdfDescribir la funcin de cada generacin en el ciclo de vida .pdf
Describir la funcin de cada generacin en el ciclo de vida .pdf
 
Consider the planned expenditure curve PAE in the figure b.pdf
Consider the planned expenditure curve PAE in the figure b.pdfConsider the planned expenditure curve PAE in the figure b.pdf
Consider the planned expenditure curve PAE in the figure b.pdf
 
Consider the adjacency matrix Apath dM8639c0225.pdf
Consider the adjacency matrix Apath dM8639c0225.pdfConsider the adjacency matrix Apath dM8639c0225.pdf
Consider the adjacency matrix Apath dM8639c0225.pdf
 
Brenda and Miguel share greatgrandparents and are consideri.pdf
Brenda and Miguel share greatgrandparents and are consideri.pdfBrenda and Miguel share greatgrandparents and are consideri.pdf
Brenda and Miguel share greatgrandparents and are consideri.pdf
 
Adam Simmons de 25 aos tuvo un accidente de moto de nieve.pdf
Adam Simmons de 25 aos tuvo un accidente de moto de nieve.pdfAdam Simmons de 25 aos tuvo un accidente de moto de nieve.pdf
Adam Simmons de 25 aos tuvo un accidente de moto de nieve.pdf
 
5 Suppose that X1X2 follows a BVN where 12 and .pdf
5 Suppose that X1X2 follows a BVN where 12 and .pdf5 Suppose that X1X2 follows a BVN where 12 and .pdf
5 Suppose that X1X2 follows a BVN where 12 and .pdf
 
5 Create an Animal class as the base class with member fun.pdf
5 Create an Animal class as the base class with member fun.pdf5 Create an Animal class as the base class with member fun.pdf
5 Create an Animal class as the base class with member fun.pdf
 
27 Which of the following statements about Consumptive Wate.pdf
27 Which of the following statements about Consumptive Wate.pdf27 Which of the following statements about Consumptive Wate.pdf
27 Which of the following statements about Consumptive Wate.pdf
 
217 Global warming A research poll asked 1603 Americans F.pdf
217 Global warming A research poll asked 1603 Americans F.pdf217 Global warming A research poll asked 1603 Americans F.pdf
217 Global warming A research poll asked 1603 Americans F.pdf
 
Sunland Inc Dec 31 Interest Expense Bonds PayableWhen .pdf
Sunland Inc Dec 31 Interest Expense Bonds PayableWhen .pdfSunland Inc Dec 31 Interest Expense Bonds PayableWhen .pdf
Sunland Inc Dec 31 Interest Expense Bonds PayableWhen .pdf
 
The first part of the final exam itself is an exercise in th.pdf
The first part of the final exam itself is an exercise in th.pdfThe first part of the final exam itself is an exercise in th.pdf
The first part of the final exam itself is an exercise in th.pdf
 
Los cientficos sociales utilizan la estadstica inferencial.pdf
Los cientficos sociales utilizan la estadstica inferencial.pdfLos cientficos sociales utilizan la estadstica inferencial.pdf
Los cientficos sociales utilizan la estadstica inferencial.pdf
 
please help with these please A and B Events A and B are ind.pdf
please help with these please A and B Events A and B are ind.pdfplease help with these please A and B Events A and B are ind.pdf
please help with these please A and B Events A and B are ind.pdf
 

Recently uploaded

The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 

Recently uploaded (20)

Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Extraction Of Natural Dye From Beetroot (Beta Vulgaris) And Preparation Of He...
Extraction Of Natural Dye From Beetroot (Beta Vulgaris) And Preparation Of He...Extraction Of Natural Dye From Beetroot (Beta Vulgaris) And Preparation Of He...
Extraction Of Natural Dye From Beetroot (Beta Vulgaris) And Preparation Of He...
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 

Finish the 2 TODO in the ASM Language A palindrome is a w.pdf

  • 1. Finish the 2 "TODO" in the ASM Language! A palindrome is a word that is spelled the same way forwards and backwards. For example, "radar", "racecar", "civic", "kayak", and "madam" are all palindromes. The definition can be extended to phrases and sentences when ignore case and punctuation, but for this exercise we will stick to a single word. The starter code provided uses the C library functions printf and scanf to prompt for an input a word. The word that is entered from the keyboard is a null-terminated string placed in the byte array at address buf. There are also two output strings provided at addresses str_is_palindrome and str_is_not_palindrome. The starter code provided simply outputs the string at str_is_not_palindrome. The code contains two TODO comments... At the first TODO comment, the byte array at buf is filled with input from the keyboard. This input is a null-terminated character string (i.e. the array contains the characters entered on the keyboard, followed by ASCII 0). Here you need to determine whether or not the string stored at buf is a palindrome. You can do this by pushing all characters onto the process stack, then pop all characters off the stack comparing against the characters in buf. At the second TODO comment, move either str_is_palindrome or str_is_not_palindrome to RDI to set up output of the appropriate message. (This could potentially be incorporated into the code under the first TODO comment if you so choose.) The program, when completed, should prompt for and input a word, then output a message stating whether or not the word that was input is a palindrome. global main ; exposes program entry point to the linker extern printf ; declare external function extern scanf ; declare external function section .text ; start of code segment main: push rbp ; preserve base pointer mov rbp,rsp ; copy stack pointer to base pointer ; Prompt for entry of a word to test if a palindrome mov rdi,prompt ; prompt format string for printf call printf ; call printf function from C library ; Input a word to input buffer (buf) mov rdi,fmt_str ; format string for scanf mov rsi,buf ; address of input buffer for scanf call scanf ; call scanf function from C library ; TODO: Check null-terminated string at buf to see if a palindrome ; TODO: Move either str_is_palindrome or str_is_not_palindrome ; to RDI to output appropriate message mov rdi,str_is_not_palindrome ; Output message, address of output string expected in RDI call printf ; call printf function from C library pop rbp ; restore base pointer mov rax, 0 ; exit status (0 = success) ret section .data ; start of initialized data segment prompt db "Enter a word: ",0 ; Prompt for entry buf_confirm db "You entered %s.",0xa,0 str_is_palindrome db "This word is a palindrome.",0xa,0 str_is_not_palindrome db "This word is not a palindrome.",0xa,0 fmt_str db "%s",0 ; Input format string for scanf section .bss ; start of uninitialized data segment buf resb 100 ; input buffer, for entry of a word