Answer to Question #177280 in Assembler for Kent

Question #177280

Write an assembly language program that declares three integer variables called number1 initialized to 9, number2 initialized to 15 and number3 initialized to 23. The assembly language code must add the three numbers and move the result into ebx. The program also must find the difference between number2 and number3 (i.e. 15 – 23). The difference must be placed in edx.


1
Expert's answer
2021-03-31T11:45:10-0400

;ASSEMBLER MASM32

.586

.model flat, stdcall

data segment

number1 dd 9

number2 dd 15

number3  dd 23

data ends

 

text segment

start:

           mov    eax, number1      ; eax = 00000009h                               

           mov    ebx, number2      ; ebx = 0000000fh                                   

           add     ebx, eax               ; ebx = eax+ebx       ebx= 00000018h    

           mov eax, number3          ; eax = 00000017h                                  

           add ebx, eax                   ; ebx = ebx+eax        ebx= 0000002fh     

  

           mov    edx, number2             ; edx = 0000000fh                             

           mov    eax, number3             ; eax = 00000017h                           

           sub     edx, eax                      ; edx=eda-eax edx= fffffff8h           

  ret

text ends

end start


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS