Program in y86
Please, I would ask you do not mark this as "needs more
information" as this is all of the information. You program it
in y86. Basically just write out the strlen, strcmp, strrev,
and is_palindrome in y86.
Each procedure will be worth 25pts, for a total of 100pts. Complete the assembly language program with the following procedures: 1. strlen(string length): calculate the length of a zero-terminated string. Input: String address in %rdi Output: Length in %rax 2. strcmp (string compare): compare two strings, returning 0 if they are identical Inputs: String addresses in %rdi, %rsi • Output: 0 in %rax if strings are identical; otherwise %rax contains one more than the index of the character mismatch 3. strrev (string reverse): reverses (in place) the characters in a string 4. is-palindrome (test for palindrome): compute if a valid palindrome or not • Input: String address in %rdi • Output: 0 in %rax if the string is a palindrome; 1 if not Hints: You may find it useful to use the strlen procedure you wrote as part of other procedures. What area in memory do we use when we have run out of input registers? How can this be used in these procedures? You have been provided some solutions to the test values as part of the boilerplate code. • Make use of your knowledge of function calls, for every push make sure to pop, handle input and return registers, etc.
-pos o main: irmovq 0x29, %r11 irmovq Oxo, %r12 irmovq Ox14, %13 irmovq Oxo, %r14 irmovq Oxo, %r8 irmovq Ox1, %r9 irmovq stack, %rsp # Set the stack pointer # Start Testing Procedures # String Length Test irmoq str_1, %rdi call strlen rrmovq krax, %:11 # String Comp Test irmoq str_1, %rsi call strcmp rrmova Krax, %r12 # String Comp Test irmovq str 2, %rsi call strcmp rrmovq krax, %r13 # String Rev Test irmovq str_3, %rdi call strrev irmovq ans_3, %rsi call strcmp rrmova Krax, %r14 # Palindrome Test irmovq str_5, %rdi call is_palindrome rrmovq rax, %r8 irmovq str_3, %rdi call is-palindrome rrmovq krax, %r9 halt .align 8 str_1: .quad Ox7420746e61772049 .quad 0x7420646e6966206 .quad 0x74676e656c206568 .quad 0x6968742066682068 .quad 0x676e697274732073 .quad 0x2e6e69727473002e str 2: 2
.quad 0x7420746e61772049 .quad 0x7420646e6966206 .quad Ox20657a6973206568 .quad 0x207369687420666f .quad Ox002e676e69727473 str_3: .quad 0x7420746e61772049 .quad Ox737265766572206f .quad Ox7320736968742065 quad 0x74002e676e697274 ans 3: .quad Ox20737472696e672e .quad 0x7273652074686973 .quad 0x20746f2072657665 .quad 0x7200492077616e74 str_5: .quad 0x72616365636172 strlen: # Your strlen code here strcmp: # Your strcmp code here strrev: # Your strrev code here is-palindrome: # Your is-palindrome code here .pos Ox500 stack:
Program in y86 Please, I would ask you do not mark this as "needs more information" as this is all of the information. Y
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Program in y86 Please, I would ask you do not mark this as "needs more information" as this is all of the information. Y
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!