You are on page 1of 2

; Exercise 3 Develop a program that will perform n times, for each time, 2 integers will be

accepted then sum of them is printed out. Value of n is received from user.

include\masm32\include\masm32rt.inc

.code
start:
call main
exit
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
main proc
LOCAL a : DWORD
LOCAL b : DWORD
LOCAL sum : DWORD
LOCAL n : DWORD
LOCAL i : DWORD

mov n, sval(input("Ban muon bao nhieu vong lap: "))


mov i, 1
mov ebx, n
VONGLAP:
cmp i, ebx
jle CALC
jg EXIT

CALC:
print chr$("Lap lan thu: ")
print str$(i)
print chr$(13, 10)
mov eax, 0
mov a, sval(input("Nhap so thu nhat: "))
mov b, sval(input("Nhap so thu hai: "))
mov eax, a
add eax, b
mov sum, eax
print chr$("Sum of 2 number: ")
print str$(sum)
print chr$(13, 10)
inc i
jmp VONGLAP

EXIT:
ret
main endp
end start

You might also like