Comp 3350 HW # 5:  Theme: Data Definitions, Addressing Modes, Arrays solution

$25.00

Original Work ?

Download Details:

  • Name: Assignment-5-1.zip
  • Type: zip
  • Size: 356.57 KB

Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (2 votes)

  1. [Memory Map] Fill in the following memory diagram with the data provided below. Please assume that the data segment begins at 0x00404000.

 

.data

Alpha       WORD            33h, 24h

Beta       BYTE            67h

Gamma       DWORD        5677h

Delta       BYTE            33h

 

Address Variable Data
00404000    
00404001    
00404002    
00404003    
00404004    
00404005    
00404006    
00404007    
00404008    
00404009    

 

  1. [Addressing Modes] Copy the following code into your assembly development environment and single-step through it.  For those instructions referencing memory, write the linear address.

 

TITLE Addressing Modes             (main.asm)

INCLUDE Irvine32.inc

 

.data

alpha       DWORD       44h, 23h

beta       DWORD       6788h, 66h

gamma       DWORD       1234h

 

.code

main PROC

mov eax, 12h;              Immediate

mov ecx, eax;              Register to Register

mov edi, OFFSET beta;            Immediate

mov [gamma], eax;       Indirect

mov esi, [gamma];                Direct

mov esi, 4;                    Immediate

mov eax, beta[esi];        Indirect-offset

mov ebx, OFFSET alpha;           Immediate

mov eax, [ebx];                  Indirect

mov eax, 4[ebx];                 Indirect-displacement

mov eax, 4[ebx][esi];            Base-Indirect-displacement

exit

main ENDP

END main

 

 

 

  1. [Indirect addressing] Write a program that adds a constant value to each element of an array and places the value in the ModArray.   Use:

 

.data

Array       WORD 23h, 45h, 45h, 56h, 25h, 44h, 22h, 54h, 12h

ConstVal    WORD 20h

ModArray    WORD 9 DUP (?)

 

 

  1. [Loops] Write a program to compute the sum of first n even integers.  Sum = 2 + 4 + 6 … + n.  Your program must:

 

    1. Prompt user for integer n,
    2. Read the value of n from user input
    3. Calculate Sum, and;
    4. Print Sum on screen.

 

Please use the “WriteInt” procedure, not “DumpRegs”. Other relevant procedures: “ReadInt” and “WriteString.” The calculation can be done in many ways, and all submissions that evidence proper programming practice are acceptable. In your homework submission, please embed both the code and one screen shot for n = 60.  You can assume that the user is considerate and careful and thus only inputs even values for n.