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.
;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
Comments
Leave a comment