When adding real numbers expressed in scientific notation (base 10), we must first transform them such that they have the same exponent. For example, 3.1416 + 1.0 x 103 must be transformed to 3.1416 + 1000.0. Once the numbers are expressed with the same exponent, we need to align their decimal point, then we can add them (1003.1416 = 1.0031416 x 103).
The same is true when adding IEEE floating point numbers, except that the base we are working with is 2.
Perform the following IEEE floating point number additions following the algorithm described above, i.e., first, transform the IEEE floating point numbers (expressed as hexadecimal numbers) such that they have the same exponents, align their binary points and add them. Express their sum as an IEEE floating point number, then express this IEEE floating point number as a hexadecimal number. Show your work and clearly show the result of rounding, if rounding occurs.
where 0.16666667 approximates 0x3E2AAAAB
and 0.83333333 approximates 0x3F555555
Assume the following values are stored at the indicated memory addresses and registers:
Imagine that the operands in the table below are the Src (source) operands for some unspecified assembly instructions, fill in the following table with the appropriate answers.
Note: We do not need to know what these assembly instructions are in order to fill the table.
Still using the first table listed above displaying the values stored at various memory addresses and registers, fill in the following table with three different Src (source) operands for some unspecified assembly instructions. For each row, this operand must result in the operand Value listed and must satisfy the Operand Form listed.
Requirement 1:
We would like to write assembly code (instruction(s)) that multiplies the value stored in the register %esi by c, where c is a positive integer constant (fits in 32 bits), and stored their product in the register %eax, i.e., %eax <- c * %esi.
In the table below, write the assembly code (instruction(s)) that satisfies Requirement 1 above and the other requirements found in the Other Requirements column:
Consider a function called arith, defined in a file called arith.c and called from the main function found in the file called main.c.
This function arith performs some arithmetic manipulation on its three parameters.
Compiling main.c and arith.c files, we created an executable called ar, then we executed the command:
objdump –d ar > arith.objdump
We display the partial content of arith.objdump below. The file arith.objdump is the disassembled version of the executable file ar.
Your task is to fill in its missing parts, which have been underlined:
0000000000400527 <arith>:
400527: 48 8d 04 37 lea (%rdi,%rsi,1),%rax
___40052b___: 48 01 d0 add %rdx,%rax
40052e: 48 8d 0c 76 lea (%rsi,%rsi,2),%rcx
400532: 48 c1 e1 _4_ shl $0x4,%rcx
400536: 48 8d 54 0f 04 lea 0x4(%rdi,%rcx,1),%rdx
40053b: 48 0f af c2 imul %rdx,%rax
_40053f_____: c3 retq
Do the Homework Problem 3.58 at the end of Chapter 3 and include your program called decode2.c below. Make sure you satisfy the following requirements:
Once you have created you program decode2.c, generate its assembly code version using the optimization level “g” (–Og) and call it decode2.s. Include it below as well without making any modifications to it.
You do not have to electronically submit your program on CourSys. However, your program must be functionally correct (i.e., it must compile, execute properly and solve this problem).
Reviews
There are no reviews yet.