2. [Addressing Modes] Copy the following code into your assembly development
environment and single-step through it. For each single step execution, submit the
screenshot. Forthoseinstructionsreferencingmemory,dothelinearaddresscomputation
by hand and typewrite it.
TITLE Addressing Modes (main.asm)
INCLUDE Irvine32.inc
.data
alpha DWORD 0A1B1C1D1h, 87654321h
beta DWORD 67EED9FCh, 21A220C2h
gamma DWORD 0BCB1D44Fh
.code
main PROC
mov eax, 1C2Fh; Immediate
mov ecx, eax; Register to Register
mov edi, OFFSET beta; Immediate
mov [gamma], eax; Direct
mov esi, gamma; Direct
mov esi, 4; Immediate
mov eax, beta[esi]; Indirect-offset
mov ebx, OFFSET alpha; Immediate
mov eax, 4[ebx]; Indirect-displacement
mov eax, [ebx]; Indirect
mov eax,4[ebx][esi]; Base-Indirect-displacement
exit
main ENDP
END main
3. [Indirect addressing] Write a program that first displays all the elements of Array1,
Array2 and Array3. Then, the program should subtract all the odd indexed elements of
Array2 from the odd indexed elements of Array1 and store the result in Array3; e.g. Array3
[7] = Array1 [7] – Array2 [7]. Next, it must add the even indexed elements of Array1 and
Array 2 and store them in the corresponding even indexed elements of Array3, e.g. Array3
[4] = Array1 [4] + Array2 [4]. Next, display the elements of all the arrays after these
operations. Submit screenshots of the displays of the elements of all the arrays. You can
use WriteInt or WriteHex to display the elements of the arrays. Fill in Array1 and Array2
each by your own ten numbers each using both positive and negative integers.
.data
Array1 SWORD 7, …
Array2 SWORD -4, …
Array3 SWORD 10 DUP (?)
4. [Loops] Declare a signed word array. Write a program to print on screen the
first n positive elements of the array, using the Loop instruction. One sample
array is given below. You should test with other sample created arrays and
with multiple sized arrays. Make sure you have a good mix of positive and
negative integers.
.data
MySigned Array SWORD -1, 78, 0AC, 4567, -7, -273, 92
1. Prompt user for integer n,
2. Read the value of n from user input
Please use the ¡°WriteInt¡± procedure, not ¡°DumpRegs¡±. Other relevant
procedures: ¡°ReadInt¡± and ¡°WriteString.¡± In your homework submission,
please embed both the code and one screen shot for n = 6.