Question

In: Computer Science

Assembly Language Programming: a)If eax = 0FFFFFFFFH, and edx = 0FFFFFFFFH, then the instruction                            

Assembly Language Programming:

a)If eax = 0FFFFFFFFH, and edx = 0FFFFFFFFH, then the instruction

                             imul edx

will leave the value ______________________________ in the edx register.

b)If eax = 0D000000DH, and edx = 50000005H, then the instruction

                             idiv dl

will leave the value ______________________________ in the eax register.

c)If ax = 3BC4H, then the following instructions

                             cmp ah, al

jg   Label

will / will not cause a jump to Label.

d)If ax = 3BC4H, then the following instructions

                             cmp ah, al

ja   Label

will / will not cause a jump to Label.

f) The following instructions

                             mov eax, 0

mov ecx, 1100B

L1: inc eax

loop L1

will leave the value ______________________________ in the eax register.

Solutions

Expert Solution

a) When the one-operand form of imul is passed a 32 bit argument (as in this case with edx) it effectively means eax * edx where both eax and eax are 32 bit registers. The product of two 32 bit values may not necessarily fit in 32 bits as the full multiply result can take up to 64 bits. The high 32 bits of the answer will be written to the edx register and the low 32 bits to the eax register; this is represented with the edx:eax notation

Net answer after eax*edx = FFFF FFFE 0000 0000 Hex

So edx = FFFF FFFE H

b) The IDIV (signed divide) instruction performs signed integer division, using the same operands as the DIV instruction.

eax = eax / dl = 2999 999C H

c) jg jumps if Sign Flag  = Overflow Flag and Zero Flag = 0 (signed Greater, excluding equal)

cmp ah, ah
jg Label ; will go "Label" if ah >s al
             ; where >s is "signed greater than"

Since 3BH - SIGNED C4H = 77H

So it will jump to Label as the result is positive, so ah > al.

d) ja jumps if Carry Flag = 0 and Zero Flag = 0 (unsigned above: no carry and not equal)

cmp ah, al
ja Label ; will go "Label" if ah >u al
             ; where >u is "unsigned greater than"

Since 3BH – C4H = (5910- 19610 ) = -ve answer

So It will not jump as subtraction as result is positive, as ah < al.

f) The LOOP instruction assumes that the ECX register contains the loop count. When the loop instruction is executed, the ECX register is decremented and the control jumps to the target label, until the ECX register value, i.e., the counter reaches the value zero.

While the ecx decreases, the eax increases to 1100 B.

So eax = 1100 B.


Related Solutions

Provide the instruction type, assembly language instruction, and binary representation of the instruction described by the...
Provide the instruction type, assembly language instruction, and binary representation of the instruction described by the following LEGv8 fields: op = 0x458, Rm = 14, Rn = 16, Rd = 18, shamt = 0
Assembly Language Programming Construct an assembly language program fragment equivalent to the following C/C++ statement: if...
Assembly Language Programming Construct an assembly language program fragment equivalent to the following C/C++ statement: if (M <= N + 3 && (C == ‘N’ || C == ‘n’)) C = ‘0’; else C = ‘1’; Assume that M and N are 32-bit signed integer variables, and C is an 8-bit ASCII character variable. All variables are stored in memory, and all general-purpose registers are available for use.
Write a possible assembly language instruction or set of instructions to accomplish the following: a) Compare...
Write a possible assembly language instruction or set of instructions to accomplish the following: a) Compare the byte stored at the memory location pointed to by register R4 to the upper (higher) byte stored in register R5 b) Branch to instruction at label ‘ZERO’ if the lower byte of register R6 is zero c) Jump to the instruction at label ‘EVEN’ if the value in register R7 is an even number
Assume that the instruction pointer, EIP, initially contains 2010 and the assembly language representation of the...
Assume that the instruction pointer, EIP, initially contains 2010 and the assembly language representation of the instructions in memory starting at address 2010 is Instruction Address Instruction 20 CMP DL, 0xD2 21 JE 72 Before the instruction sequence is executed, the flags are CF=0, ZF=0 and SF=0 and the Registers have the values AL=0x0D, BL=0xA9 CL=0x5E andDL=0xCF. What is the value of the instruction pointer after the sequence executes?
Assisted Instruction: Has to be in PERL SCRIPTING LANGUAGE with NO SUBROUTINES Programming Exercise: Write a...
Assisted Instruction: Has to be in PERL SCRIPTING LANGUAGE with NO SUBROUTINES Programming Exercise: Write a program in PERL with NO SUBROUTINES to allow the user to pick a type of arithmetic problem to study. An option of 1 means addition problems only, 2 means subtraction problems only, 3 means multiplication problems only, 4 means division problems only and 5 means random mixture of all these types. (Computer- Assisted Instruction) The use of computers in education is referred to as...
Write in ARM assembly language the following operations without using multiplication instruction: a) A * 17...
Write in ARM assembly language the following operations without using multiplication instruction: a) A * 17 b). A * 23
ASSEMBLY LANGUAGE PROGRAMMING Q:Write a complete assembly program that inputs a small signed integer n, whose...
ASSEMBLY LANGUAGE PROGRAMMING Q:Write a complete assembly program that inputs a small signed integer n, whose value can fit within 8 bits, and outputs the value of the expression n2 – n + 6.
1) Provide the type and assembly language instruction for the following binary value: 0000 0010 0001...
1) Provide the type and assembly language instruction for the following binary value: 0000 0010 0001 0000 1000 0000 0010 0000 (two) 2) Provide the type, assembly language instruction, and binary representation of instruction described by the following MIPS fields: op=0, rs=3, rt=2, rd=3, shamt=0, funct=34 3)For the following C statement, write a minimal sequence of MIPS assembly instructions that does the identical operation. Assume $t1 = A, $t2 = B, and $s1 is the base address of C. A...
One of the very practical uses of assembly language programming is its ability to optimize the...
One of the very practical uses of assembly language programming is its ability to optimize the speed and size of computer programs. While programmers do not typically write large-scale applications in assembly language, it is not uncommon to solve a performance bottle neck by replacing code written in a high level language with an assembly language procedure. In this programming project you will be given a C++ program that generates an array of pseudorandom integers and sorts the array using...
Translate the following pseudocode to MIPS assembly programming language cout << “\n Please input a number...
Translate the following pseudocode to MIPS assembly programming language cout << “\n Please input a number for $s0”; cin >> $s0; cout << “\n Please input a number for $s1”; cin >> $s1; cout << “\n Please input a number for $s2”; cin >> $s2; $t0 = $s0 / 8 - 2 * $s1 + $s2; cout << “\n the Value of the expression “$s0 / 8 - 2 * $s1 + $s2” is ”; cout >> $t0; return;
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT