What is the value of AX after these five lines of code?
mov AX,10
shl AX,1
add AX,10
cmp AX, 10
dec ax
Solution:
Instruction1: mov AX,10
Explanation: Here mov is opcode and AX is called destination register value and 10 is called source register value. mov copies the source register value into destination register value, hence AX = 10
Instruction 2:shl AX,1
Explanation: shl is used to left-shift the binary value of register by some digit which is represented in second part. Here AX,1 represents the binary value of AX will be left-shifted by 1 digit so AX=10 which is 00001010 and after the execution of instruction shl AX,1 the binary value of AX will be left-shifted by 1 digit so finally it will be 00010100 which is 20 so now AX =20
Instruction 3: add AX,10
Explanation: add is opcode used to add contents of two registers and assigning final value to first register.Here AX=20 and other value=10 so AX= 20+10=30, So after 3rd instruction execution AX=30
Instruction 4: cmp AX,10
Explanation : cmp is opcode which is used to compare the two register contents which are source register at the side and destination register at the left side.
If destination register content > source register content => ZF(zero flag) = 0, CF(carry flag) =0
If destination register content < source register content => ZF(zero flag) = 0, CF(carry flag) =1
If destination register content = source register content => ZF(zero flag) = 1, CF(carry flag) =0
here AX>10 hence ZF=0,CF=0
Instruction 5:dec AX
Explanation: dec is opcode and AX is operand, dec is used to decrease the value of operand by 1
Hence AX-1 =30-1 = 29 (Final value of AX)
What is the value of AX after these five lines of code? mov AX,10 shl AX,1...
What will be the value of the parity flag after the following lines execute? Mov al, 3 Add al, 5 What will be the value of the destination operand after each of the following instructions execute? .data var1 SBYTE -1, -2, -3, -4 var2 WORD A000h, B000h, C000h, D000h var3 SWORD -16, -42 var4 DWORD 11, 22, 33, 44 .code mov ax, var2 mov ax, [var2+4] mov ax, var3 mov ax, [var3-2]
1. What will be the value in EDX after each of the lines marked (a) and (b) execute? .data one WORD 8002h two WORD 4321h code mov edx,213480411h movsx edx,one (a) movsx edx,two ; (b) 2. What will be the value in EAX after the following lines execute? mov eax,1002FFFFh inc ax 3. What will be the value in EAX after the following lines execute? mov eax,30020000h dec ax 4. What will be the value in EAX after the following...
6. What will be the final value in EDX after this code executes? mov edx, 1 mov eax,7FFFh cmp eax,0FFFF8000h jl L2 mov edx,0 し2: 7. (True/False): The following code will jump to the label named Target. mov eax,-30 cmp eax,-50 ig Target 8. Implement the following pseudocode in assembly language. Use short-circuit evaluation and assume that vall and X are 32-bit variables. if vall >ecx ) AND (ecx> edx) X=1 else X=2;
Assembly language: Before executing the following code, the value in eax was 1 What will be the value in eax after executing the following code: mov ebx, eax shl eax, 4 shl ebx, 3 add eax, ebx
MOV AX, O MOV CX, 5 MOV BX, 3 MOV DX, 16 INC BX ADD AX, BX LOOP L1 L1: What is the value of AX, how many cycle is the loop?
read carefully Which DOES NOT evaluate. Consider the following arithmetic operations in C: int X-20; int Y-20; int Z-2*(X+Y) which assembly code(0x86) does not evaluate value for Z correctly? mov eax.X b) mov ebx. Y add eax ebx mov el.4 mov ebx.Y a) add eax.ebx mov cl.2 imul cl mov Z eax imul cl shr eax. 1 mov Z.eax d) mov eax.X mov ebx.Y add eax.ebx shl eax, I mov Z,eax mov eax X c) mov ebx,Y shl eax.2 shl...
1. What will be the contents of BX after the following instructions execute? mov bx,5 stc mov ax,60h adc bx,ax 2. Describe the output when the following code executes in 64-bit mode: .data dividend_hi QWORD 00000108h dividend_lo QWORD 33300020h divisor QWORD 00000100h .code mov rdx,dividend_hi mov rax,dividend_lo div divisor 3. The following program is supposed to subtract val2 from val1. Find and correct all logic errors (CLC clears the Carry flag): .data val1 QWORD 20403004362047A1h val2 QWORD 055210304A2630B2h result QWORD...
37. What is the binary value of AL after the following instructions have mov al,01101011b stc rcl al,2 38. What is the binary value of AX after the following instructions have executed? mov ax, 0000000010011101b mov bx, 1010101010000000b shld ax, bx,1 39. What is the binary value of AX after the following instructions have executed? mov ax, 0000000010011101b mov bx, 1010101010001011b shrd ax, bx, 2 will be the hexadecimal values of DX and AX after the following instructions have executed?...
2) Given the code below: What will be the resulting value of the Sign Flag (SF), and the Zero Flag (ZF) and will the Jump occur or will the Jump NOT occur mov ax,06h mov bx,05h cmp ax,bx jns loop1 OSF=1 ZF=1 JUMP WILL OCCUR OSF=1 ZF=0 JUMP WILL OCCUR OSF=O ZF=0 JUMP WILL OCCUR O SF=0 ZF=1 JUMP WILL NOT OCCUR
e) What is the output of following program? MOV AX, 1234 Address Value 1 2000 11 200122 MOV BX, [2000] PUSH BX INC BX PUSH AX INC BH POP CX OR CX, BX POP AX AND AX, BX INT 05 AX= BX = CX (Show your rough work here)