In: Computer Science
where a=2, b=3 and c=5.
if (bx<= ax) && ( cx > dx )
{
ax = 5;
dx = 6;
}
NOTE: Only use 16 bit or 8 bit registers like ax,bx,cx,dx or al,bl,cl,dl. You can either do this using loop statement or conditional or unconditional jmps in assembly language. Keep the code as simple as possible. For question you need to use cmp in assembly language to compare the values. You need to ask from the user the values of ax,bx,cx and dx as input.
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], 2
mov DWORD PTR [rbp-8], 3
mov DWORD PTR [rbp-12], 5
mov edx, DWORD PTR [rbp-8]
mov eax, edx
add eax, eax
add eax, edx
mov edx, eax
shr edx, 31
add eax, edx
sar eax
mov edx, eax
mov eax, DWORD PTR [rbp-12]
lea ecx, [rdx+rax]
mov edx, DWORD PTR [rbp-8]
mov eax, edx
add eax, eax
add eax, edx
add eax, eax
sub eax, DWORD PTR [rbp-4]
imul eax, ecx
mov DWORD PTR [rbp-16], eax
mov eax, DWORD PTR [rbp-16]
mov esi, eax
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
mov eax, 0
leave
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 .L5
cmp DWORD PTR [rbp-8], 65535
jne .L5
mov edi, OFFSET FLAT:_ZStL8__ioinit
call std::ios_base::Init::Init() [complete object constructor]
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:_ZStL8__ioinit
mov edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev
call __cxa_atexit
.L5:
nop
leave
ret
_GLOBAL__sub_I_main:
push rbp
mov rbp, rsp
mov esi, 65535
mov edi, 1
call __static_initialization_and_destruction_0(int, int)
pop rbp
ret