Write a macro for calculating the dot product of two vectors in 80x86 assy language
; computes the dot product of two vectors
dot_product MACRO x1, y1, z1, x2, y2, z2
ENDM
dot_product MACRO x1,y1,z1,x2,y2,z2
push cx # ax and cx is pushed to the stack so that its value in the main program is not altered
push ax
mov al,x1
mov cl,x2
mul cl
add bx,ax #register bx is used to store the sum
mov al,y1
mov cl,y2
mul cl
add bx,ax
mov al,z1
mov cl,z2
mul cl
add bx,ax
dis
pop cx #initial values of ax and cx are brought back
pop ax
ENDM
dis MACRO #This MACRO is to display the result on the screen
mov ax,bx
add ax,3030h #3030h is added so the the ascii value of the number is obtained
mov cx,ax
mov dl,ah
mov ah,2h #interrupt to print a value on the screen
int 21h
mov dl,cl
mov ah,2h
int 21h
ENDM
Get Answers For Free
Most questions answered within 1 hours.