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

Write a complete procedure (suitable to be called form a main program) which wil

ID: 664883 • Letter: W

Question

Write a complete procedure (suitable to be called form a main program) which will add two integer (32 bit) arraya, X and Y, producing their sum in a third array, Z. That is,

Zi = Xi + Yi ,    for i = 0, N-1

Assuem that the addresses of hte arrays X, Y, and Z are passed in the registers EBX, ESI, and EDI, respetively, and that the number of ellements is passed in the register EXC.
Use AddVec as teh name of the procedure. Note that your prceure should NOT that your procedure shourld NOT reference the arrays directly - only thorugh the parameters.

Explanation / Answer

model small .data op1 dd 12345678h op2 dd 11111111h ans dd ? .code mov ax, @data mov ds, ax mov ax, word ptr op1 ; lsb of number1 in ax mov bx, word ptr op1+2 ; msb of number1 in bx mov cx, word ptr op2 ; lsb of number2 in cx mov dx, word ptr op2+2 ; msb of number1 in dx add ax, cx ; add msb + msb + carry mov word ptr ans, ax ; lsb answer mov word ptr ans+2, bx ; msb answer mov bx, word ptr ans+2 ; Result in reg bx mov dh, 2 l1: mov ch, 04h ; Count of digits to be displayed mov cl, 04h ; Count to roll by 4 bits l2: rol bx, cl ; roll bl so that msb comes to lsb mov dl, bl ; load dl with data to be displayed and dl, 0fH ; get only lsb cmp dl, 09 ; check if digit is 0-9 or letter A-F jbe l4 add dl, 07 ; if letter add 37H else only add 30H l4: add dl, 30H mov ah, 02 ; INT 21H (Display character) int 21H dec ch ; Decrement Count jnz l2 dec dh cmp dh, 0 mov bx, word ptr ans ; display lsb of answer jnz l1 mov ah, 4ch ; Terminate Program int 21h end

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