Assembly 1

1. Fibonacci Numbers

Write a program that uses a loop to calculate the first seven values in the Fibonacci number sequence {1, 1, 2, 3, 5, 8, 13}. Place each value in the EAX register and display it with a call DumpRegs statement inside the loop.

2. Arithmetic Expression

Write a program that implements the following arithmetic expression.

EAX = -val2 + 7 - val3 + val1

Use the following data definition:

val1 SDWORD 8

val2 SDWORD -15

val3 SDWORD 20

In comments next to each instruction, write the hexadecimal value of EAX. Insert a call DumpRegs statement at the end of the program.

3. Direct-Offset Addressing

Insert the following variables in your program:

.data

Uarray WORD 1000h, 2000h, 3000h, 4000h

Sarray SWORD -1, -2, -3, -4

Write instructions that use direct-offset addressing to move the four values in Uarray to the EAX, EBX, ECX, EDX registers. When you follow this with a call DumpRegs statement, the following register values should display:

 EAX=00001000 EBX=00002000 ECX=00003000 EDX=00004000

Next, write instructions that use direct-offset addressing to move the four values in Sarray to the EAX, EBX, ECX, EDX registers. When you follow this with a call DumpRegs statement, the following register values should display:

EAX=FFFFFFFF EBX=FFFFFFFE ECX=FFFFFFFD EDX=FFFFFFFC

Assembly 2

1. Consider the following questions on the 29th slide of chapter 6:

Write code that jumps to label L1 if either bit 4, 5, or 6 is set in the BL register.
Write code that jumps to label L1 if bits 4, 5, and 6 are all set in the BL register.
Write code that jumps to label L2 if AL has even parity.
Write code that jumps to label L3 if EAX is negative.
Write code that jumps to label L4 if the expression (EBX – ECX) is greater than zero.

2. Could you figure out which status flags each of the jumps based on unsigned/signed comparisons correspond to?