Objective: Learn memory organization/layout, data transfer concepts and instructions, direct memory access, memory allocation.
Requirements:
1. (5 points) Write an assembly program to compute the following expressions
– –
– – – –
–
–
–
Create a DWORD array named ‘z’ of size 3 using DUP operator. Leave the array ‘z’ uninitialized. You can denote the items in the array as [𝑧!, 𝑧”, 𝑧#], where 𝑧! is the first item, 𝑧” is the second item, 𝑧# is the third item
Update each array item using the following expressions.
𝑧! =𝑥+130
𝑧” =𝑦+𝑥− 𝑧! 𝑧# =𝑟+𝑥−13
Wherex,y,rare16-bitintegermemoryvariables.
x=10,y=15,r=4
Usemov,movzx,movsx,add,subinstructionsonly.
(hint: Do not alter the value of x, y and r during the computation. Transfer them to appropriate registers to do computation)
Attheend,openmemorywindowtoseethevariablezstoredinmemory(littleendianformat). If you code correctly, 𝑧! = 140 in decimal, 𝑧” = −115 in decimal, 𝑧# = 1 in decimal
Usethedebuggertoverifyyouranswer.
o Submit the following:
§ Rename the asm file using your last name as Lastname1.asm
§ Screenshot of the code and memory window showing the content of the variable z (little endian
format).
2. (5 points) Use a loop instruction with indirect addressing to solve the problem.
- – Donotcopytheelementstoanyotherarray.
- – UsetheLOOPandXCHGinstruction.
- – Theinputarray,inputStrcontainselements:“A”,“B”,“C”,“D”,“E”,“F”,“G”,“H”.
- – Thearray’selementsafterrunningtheprogramshouldlooklike:“H”,“G”,“F”,“E”,“D”,“C”,“B”,“A”.
o Submit the following:
- § Rename the asm file using your last name as Lastname2.asm
- § Screenshot of the code and memory window showing the content of the variable inputStr.
3. (5 points) Write an assembly program that does the following:
- – Definethefollowingvalue0506030704080102hinthe.datasegmentusingthe64-bitunsignedidentifiernamed qVal.
- – You can subdivide the qVal value into 4 words – 0506, 0307, 4080, 0102
- – Extract these words from qVal using PTR operator.
- – Find the sum of the words. The sum should be D17h.
- – Store the result in any 16-bit register.
- – The direction of adding two words goes from left to right.




