i need help converting this into assembly language x86 using visual studio plz _
ID: 3863103 • Letter: I
Question
i need help converting this into assembly language x86 using visual studio plz
__declspec(naked)
int isPalindrome(char *input_string, int left_index, int right_index)
{
// C code to be converted to x86 assembly
/*
// Input Validation
if (NULL == input_string || left_index < 0 || right_index < 0){
return -1;
}
// Recursion termination condition
if (left_index >= right_index)
return 1;
if (input_string[left_index] == input_string[right_index]){
return isPalindrome(input_string, left_index + 1, right_index - 1);
}
return -1;
*/
__asm {
mov eax, 0
// BEGIN YOUR CODE HERE
// END YOUR CODE HERE
ret
}
}
Explanation / Answer
Answer:
__asm {
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movq %fs:40, %rax
movq %rax, -8(%rbp)
xorl %eax, %eax
leaq 16(%rbp), %rax
movq %rax, -16(%rbp)
movl $0, %eax
movq -8(%rbp), %rdx
xorq %fs:40, %rdx
je .L3
call __stack_chk_fail@PLT
.L3:
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
ret
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.