Question

Follow the instructions below to create a full running Assembly program: Create a ​WORD ​sized array...

  1. Follow the instructions below to create a full running Assembly program:

    Create a ​WORD ​sized array with ​5​ elements of ​A2D5h ​using the ​DUP​ operator. Move the ​OFFSET ​of this array into register ​ESI​. Move the number of elements in the array initialized using the ​LENGTHOF​ instruction and move it into ECX as your loop counter.

    Create a ​LOOP​ that adds the value 1F33h to each element. Traverse through the array by adding the size of each element to the ​ESI​ using the instruction ​TYPE​.

    Using instructions, ​MOVZX​ and M​ OVSX​, move an element in the array into an appropriate sized register. After perform an swap of these two registers using the instruction ​XCHG. ​Lastly, utilize the instruction ​PTR​ to move an element from the array to a DWORD sized register.

Homework Answers

Answer #1

SECTION . DATA

ARR DWORD 5 DUP(A2D5h)

ARR_SIZE EQU $ -ARR ; gives number of elements in which array.

SECTION .TEXT

global MAIN; must be declared for linker ( ld)

MAIN:

MOV ESI, ARRAY1 ; moves the offset of the array into ESI

MOV ECX, ARR_SIZE ; mov array size into ecx to act as the loop counter.

MOV EBX, 1F33h. Storing the data to be added in EBX.

SUM_UP:

ADD [ESI],EBX ;adding each element of the array with 1F33h.

ADD ESI,1 ; increment array address to pont the next element in the array.

DEC ECX ; Decrement loop counter.

JNZ SUM_UP ;jump to sum_up if counter not equal to zero.

MOVZX EAX, [ESI] ; moving array element into 32 bit register.

MOV EBX,[ESI-4] ; moves the previous array element to EBX.

XCHG EAX,EBX ;swap value in EAX with EBX

MOV EAX,DWORD PTR[ARR] ; An element of the array is moved EAX using PTR operator.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT