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

Write assembly language programs to perform each of the following calculations.

ID: 3711596 • Letter: W

Question

Write assembly language programs to perform each of the following calculations. In your programs, ignore overflow (i.e., assume that your operand values will not produce an overflow).

a- Add long word: Add two 64-bit unsigned values (e.g., C ? A + B)

b- Negate long word: Negate a 64-bit value by replacing the value by its two’s complement (e.g., C ? -C)

c- Subtract long word: Subtract a 64-bit value from another 64-bit value (e.g., C ? A - B)

d- Multiply long word: Multiply two 32-bit unsigned values to get a 64-bit result (e.g., C ? A * B)

e- Multiply and accumulate: Multiply two 32-bit unsigned values to get a 64-bit result and add this result to a 64-bit destination value (e.g., C ? C + A * B)

f- Dot product of two vectors: Find the dot product of two vectors. Each element of these vectors is a 32-bit unsigned value. The result is a 64-bit value. (e.g. let X=[x0,x1,x2,…xn], Y= [y0, y1, y2, …, yn], find Z=X.Y = x0* y0 + x1* y1 + x2* y2 + … + xn * yn). Assume that elements of a vector are stored in consecutive memory locations.

Explanation / Answer

Adding words

DATA SEGMENT

N1 DB 9H

N2 DB 7H

RES DB?

ENDS

CODE SEGMENT

ASSUME DS:DATA CS:CODE

START

MOV AX,DATA

MOV DS,AX

MOV AL,N1

MOV AL,N2

MOV RES,AL

MOV AH,4CH

INT 21H

ENDS

END START

Negate Word

Data Segment

Number dw 00000010B

Data Ends

Code Segment

Assume cs:code, ds:data

Begin:

mov ax,data

mov ds,ax

mov es,ax

mov ax,Number

NOT ax

add ax,00000001B

Exit:

mov ax,4c00h

int 21h

Code Ends

End Begin

Substract Words

.model small

.data

message db "Substraction Operation"

message2 db "Enter first number $"

message3 db " Enter second number $"

message4 db "+$"

message5 db "=$"

.code

main proc

mov ax,seg message

mov ds,ax

mov dx,offset message ;

mov ah, 9h

int 21h

mov ah, 1h

int 21h

mov bl,al

mov ah,0Eh

mov al,0Dh

int 10h

mov al,0Ah

int 10h

mov ax,seg message2

mov ds,ax

mov dx,offset message2

mov ah,9h

int 21h

mov ah, 1h

int 21h

mov cl,al

mov ah, 0Eh

mov al, 0Dh

int 10h

mov al, 0Ah

int 10h

mov dl,bl

mov ah, 2h

int 21h

mov ax,seg message4

mov ds,ax

mov dx,offset message4

mov ah,9h

int 21h

mov dl,cl

mov ah, 2h

int 21h

mov ax,seg message5

mov ds,ax

mov dx,offset message5

mov ah,9h

int 21h

sub bl,30h

sub cl,30h

sub bl,cl

add bl,30h

mov dl,bl

mov ah,2h

int 21h

endp

end main

  

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