The following code calculates A = (4 * B) + C in which A, B, and C are signed bytes. If C has the decimal value of +28, then what is the largest decimal value for B that allows the code to correctly calculate A = (4 * B) + C as a signed byte?
mov al, [B] ; B
add al, [B] ; 2 * B
add al, al ; 4 * B
add al, [C] ; (4 * B) + C
move [A], al ; A = (4 * B) + C
A) +15 B) +19 C) +24 D) +28 E) +31
Could someone please explain this problem to me as they provide the solution? Thank you.
A = (4 * B) + C
First signed byte range from -128 to 127.
so whatever the value of A it should be be in that range.
so let's put all the values B and find the result.
A) A = (4 * 15) + 28 = 88
B) A = (4 * 19) + 28 = 104
C) A = (4 * 24) + 28 = 124
D) A = (4 * 28) + 28 = 140
E) A = (4 * 31) + 28 = 152
D,E are above the range of signed byte
B,A are below the range and the C
C is the largest possible value for a signed byte. so answer is C
(B = 24).
The value for C is 28.
Use the following data declarations. Assume that the offset of byteVal is 00000000: data byteValsbyte 1,2,3,ffh dwordVal dword 34567890h, 90785634h, 12346745h Show the value of the final destination operand after each of the following code fragments has executed:(If any instruction/s is invalid, indicate "INV" as the answer and briefly explain why) a.mov edi, 2 answer al mov al, (byte Val + edi) b.mov ebx, dwordVal+4 answer ebx - [esi).- (show your answer in liteedim mov esi, offset dwordVal+8 xchg ebx,...
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...
I
need help creating this code.
Write an assembly program (MASM and Irvine's libraries) that calculates and prints out the first five Fibonacci numbers FO=0; F1=1; F2=1; F3=F1+F2; F4=F3+F2; F5=F4+F3 If we use 0, 1 and initial conditions the sequence would be: 0, 1, 1, 2, 3 Use the ebx, eax, and ecx registers. Note WriteHex, Writelnt, WriteDec, all use eax So use ebx for first and eax for second and ecx for temporary The calculation could go something like...
1. Assume that you are given values in eax, ebx, ecx. Write an assembly code that does the following: eax = (ecx + edx ) - (eax + ebx) 2. Write a piece of code that copies the number inside al to ch. Example: Assume that Initially eax = 0x15DBCB19. At the end of your code ecx = 0x00001900. Your code must be as efficient as possible. 3. You are given eax = 0x5. Write one line of code in...
X86 Assembly Language Help to implement the CipherChar Procedure at the end of the given code INCLUDE Irvine32.inc .data KeyPrompt BYTE "Enter the passphrase: ",0 TextPrompt BYTE "Enter the plaintest: ",0 str1 BYTE "The passphrase has length:",0 str2 BYTE "The plaintest has length:",0 KeyIs BYTE "The passphrase: ",0 PlainTextIs BYTE "The plaintext: ",0 CipherTextIs BYTE "The ciphertext: ",0 KMAX = 64 ; passphrase buffer maximum size BMAX = 128 ; test...
Convert the following assembly language program into a C
program:
*Update: The variables are initialized, in lines 4 & 6 of
the red assembly language code.
Convert the following assembly language program into a C program: *Update: The variables are initialized, in lines 4 & 6 of the red assembly language code. include "p24Hxxxx.inc" global__reset bss: Uninitialized data section: Variables start at location 0x0800 x: .space 2: Allocating space (two bytes) to variable. y: .space 2;Allocating space (two bytes) to...
Using Microsoft Visual Studio. 1) Complete the following C++ program by adding more line of code for 8-bit signed array, 16-bit unsigned array, 16-bit signed array, 32-bit signed array and 32-bit signed array. 2) Fill in all the blanks in Table 1 using your completed code, following the hints provided within the table. 3) Fill in all the blanks in Table 2 using your completed code, following the hints provided within the table. C++ Program #include <stdio.h> #include <iostream> int...
Examine the following code and answer the following: 10. Register contents after execution of each instruction Machine code using hand assembly EDSIM51 Simulation a. b. c. istart (origin) at 0 ;load 25H into R5 iload 34H into R7 ;load 0 into A ;add contents of R5 to A now A-A+R5 ; add contents of R7 to A inow A A+R7 ;add to A value 12H ORG OH MOV R5,#25H MOV R7 , #34H MOV A, #0 ADD A, R5 ADD...
b) 4 bits c) 12 bits ) 16 bits 12) mov al, 0101b; mov bl, 1100b; and al, bl; What will AL be equal to after this code runs? b) 0xF3 c) 0x3F d) 0xF5 13) mov al, 0110b; mov bl, 1011b; or al, bl, xchg al, bl; neg al, What will AL and BL be equal to after this code runs? c) AL = 0xF3, BL = 0x1B 14) mov edx, 5 cmp edx, 10 ige L1, je L2...
9. The following C-like code calculates the greatest common divisor (GCD) of the two 8-bit positive integers a and b (Aside: This is Euclid's algorithm from 300 BC). Complete the HLSM for the code (Answers are case sensitive) Inputs: byte a, byte b, bit go Outputs: byte gcd, bit done GCD while (1) ( while (!go); done 0 while (a!-b){ if(a>b){ a-a b else gcd-a done 1 Inputs: go (bit), a, b (8 bits) Outputs: done (bit), ged (8 bits)...