Problem Convert C If to Assembly Code Convert the following
Problem: Convert C (If) to Assembly Code.
Convert the following If Statement in C, to Assembly Language. Use: Subtract/Carrier-flag test and comparisons instructions. Comment each line of Assembly Code, for better understanding. unsigned char i, j; if (j >= 0 times 25) {j = j - i;}Solution
Answer:
Assembly Language Code :
.zero 1
 main:
 push rbp
 mov rbp, rsp
 movzx eax, BYTE PTR [rbp-1]
 cmp eax, 36
 jle .L2
 movzx eax, BYTE PTR [rbp-2]
 sub BYTE PTR [rbp-1], al
 .L2:
 mov eax, 0
 pop rbp
 ret
 __static_initialization_and_destruction_0(int, int):
 push rbp
 mov rbp, rsp
 sub rsp, 16
 mov DWORD PTR [rbp-4], edi
 mov DWORD PTR [rbp-8], esi
 cmp DWORD PTR [rbp-4], 1
 jne .L6
 cmp DWORD PTR [rbp-8], 65535
 jne .L6
 mov edi, OFFSET FLAT:std::__ioinit
 call std::ios_base::Init::Init()
 mov edx, OFFSET FLAT:__dso_handle
 mov esi, OFFSET FLAT:std::__ioinit
 mov edi, OFFSET FLAT:std::ios_base::Init::~Init()
 call __cxa_atexit
 .L6:
 nop
 leave
 ret
 push rbp
 mov rbp, rsp
 mov esi, 65535
 mov edi, 1
 call __static_initialization_and_destruction_0(int, int)
 pop rbp
 ret

