Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume array A has 10 word, (two\'s complement binary integers): 1, -2, -3, 4, 5

ID: 3581369 • Letter: A

Question

Assume array A has 10 word, (two's complement binary integers): 1, -2, -3, 4, 5, 6, 7, -8, 9, and -10. Write a code sequence (in normal assembler language) to replace each positive element in array A by 0. Write a subprogram (in normal assembler language) corresponding to this code sequence. a. The subprogram must receive the offset of the array as argument from the calling program via stack. b. The subprogram must replace each positive element in array A by 0. c. Write a sequence of instructions (in normal assembler language) as the calling program to call the subprogram.

Explanation / Answer

Normal assembly language for replacing the 0 in the place of positive values

ARRAY DW 1,-2,-3,4,5,6,7,-8,9,-10

LEA SI, ARRAY ; set SI=offset address of ARRAY

L1:

mov ax,0;

mov ECX, 10;

CMP ax,[SI]

JBE swap;

INC SI; //increamenting SI

dec

LOOP L1;

swap:

mov SI,AX; // fill the positive array value with the 0(ax=0)

By sub program:

ARRAY DW 1,-2,-3,4,5,6,7,-8,9,-10

cal subprogramme; //calling sub programme

subprogramme

LEA SI, ARRAY ; set SI=offset address of ARRAY

L1:

mov ax,0;

mov ECX, 10;

CMP ax,[SI]

JBE cal swap ;

INC SI; //increamenting SI

dec

LOOP L1;

if we want to pass the arguments for the above programme throgh the sub program with the help of $1,$2 etc

thank you

swap:

mov SI,AX; // fill the positive array value with the 0(ax=0)

ret

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote