Ask Question
30 April, 02:45

Consider the following high-level recursive procedure: long long int flong long int n, long long int k long long int b b k+2; if (n=-O) b = 8; else b = b + 4 * n + f (n-1, k+1); return b + k; Translate the high-level procedure f into ARMv8 assembly language. · Pay particular attention to properly saving and restoring registers across procedure calls; Use the ARMv8 preserved register convention Clearly comment your code;. Assume that the procedure starts at address 0x00400100;. Keep local variable b in X19; Assume n and k are passed in XO and X1 respectively and that the result is returned in X2

+4
Answers (1)
  1. 30 April, 06:09
    0
    f (long long, long long):

    push rbp

    mov rbp, rsp

    push rbx

    sub rsp, 40

    mov QWORD PTR [rbp-40], rdi

    mov QWORD PTR [rbp-48], rsi

    mov rax, QWORD PTR [rbp-48]

    add rax, 2

    mov QWORD PTR [rbp-24], rax

    cmp QWORD PTR [rbp-40], 0

    jne. L2

    mov QWORD PTR [rbp-24], 8

    jmp. L3

    . L2:

    mov rax, QWORD PTR [rbp-40]

    lea rdx, [0+rax*4]

    mov rax, QWORD PTR [rbp-24]

    lea rbx, [rdx+rax]

    mov rax, QWORD PTR [rbp-48]

    lea rdx, [rax+1]

    mov rax, QWORD PTR [rbp-40]

    sub rax, 1

    mov rsi, rdx

    mov rdi, rax

    call f (long long, long long)

    add rax, rbx

    mov QWORD PTR [rbp-24], rax

    . L3:

    mov rdx, QWORD PTR [rbp-24]

    mov rax, QWORD PTR [rbp-48]

    add rax, rdx

    add rsp, 40

    pop rbx

    pop rbp

    ret
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Consider the following high-level recursive procedure: long long int flong long int n, long long int k long long int b b k+2; if (n=-O) b = ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers