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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education