[Solved] Comp 3350: HW # 8. Theme: Integer Arithmetic

$25

File Name: Comp_3350:_HW_#_8._Theme:_Integer_Arithmetic.zip
File Size: 414.48 KB

SKU: [Solved] Comp 3350: HW # 8. Theme: Integer Arithmetic Category: Tag:
5/5 - (1 vote)
  1. In the following code sequence, show the value of AL after each shift or rotate instruction has executed. This question is to be done by hand, not programmatically. mov cl, 3

mov al, 45h

01000101
10001010 CF = 0
00010101 CF = 1
00101010 CF = 0

rol al, cl ; al = 2Ah

mov al, 7Ah

mov cl, 1

01111010
00111101 CF = 0

ror al, Cl ; al = 3Dh

stc

mov al, 64h mov cl, 2

01100100 CF = 1
11001001 CF = 0
10010010 CF = 1

rcl al, cl ; al = 92h

stc

mov al, 3Dh mov cl, 1

00111101 CF = 1
10011110 CF = 0

rcr al, cl ; al =

  1. (a) Write a program that calculates EAX*1710 using binary multiplication.
  • Consider the following value: A24E6C8D. Let this value be stored in register EAX. Write a program that will extract the decimal digits from this value using shifts and logical instructions.

Place the first two decimal numeric digits in DH and the other two into DL. Submit a print out of the run of the program and the list file.

  1. (a) What will be the contents of AX and DX after the following operation? You must work this problem by hand, not by a program run. What may happen if you do not set dx to 0 in the beginning? mov dx, 0 mov ax, 1234h mov cx, 4213h mul cx

DX = 04B2

AX = C1DC

DX may be different value.

  • When does an IDIV instruction cause an overflow? Provide an example.

Mov ax, 4000h

Mov dx, 500h

Mov bx, 10h

Idiv bx

OF = 1

  • What will be the values of DX:AX after the following instructions execute? What might be the use of such a sequence of instructions in a 16-bit computer?

mov ax, 0h mov dx, 0h sub ax, 1h

sbb dx, 0

DX:AX = FFFF:FFFF

To subtract numbers larger than 16 bits.

  1. Implement the following two expressions in assembly language, using 32-bit signed operands. Demonstrate the equivalence of the two using some test values for X and Y. Show the runs of the programs using both positive and negative test values. Which of the two implementations is preferable?

Z = X2 + 2XY + Y2

Z = (X+Y)2

The second one is preferable because of less code.

  1. Write a program that performs C = A B using extended subtraction. See textbook pg. 270-271.

Use the following:

Apple WORD 1214h, 3423h, 6578h, 5699h, 2005h

Berry WORD 4125h, 2345h, 12BCh, 0CDF1h, 1009h

Cherry WORD 5dup(0)

Submit the list file and a display of the contents of all the arrays after the run.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Comp 3350: HW # 8. Theme: Integer Arithmetic
$25