Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Convert the following C program to assembly. Test code checks it 1 uint16_t u16-

ID: 3906543 • Letter: C

Question

Convert the following C program to assembly. Test code checks it 1 uint16_t u16-a; 2uint16_t u16_b 3 uint16_t u16_c 4 5 void transvoid) ( 6 lation approach ex 20 7End. Data .bss First define a variable named-u 16-a , then define-u16-b , then define-u16-c , all of which occupy two bytes of memory. Make all variables visible to C 1 The variable below is used by the test code; you may ignore it. us test: .space 1 .global u8 test Code text Write assembly which implements the C given above. 1 Save and run

Explanation / Answer

X86-64 GCC 7.2 code:

translation_approach_ex_2():

push rbp

mov rbp, rsp

mov eax, DWORD PTR [rbp-4]

sub eax, DWORD PTR [rbp-8]

mov DWORD PTR [rbp-12], eax

nop

pop rbp

ret