Pages

Jul 20, 2011

Sum

.MODEL SMALL
.STACK 100H
.DATA
  M1 DB "HOW MANY NUMBER(S)?::$"
  M2 DB 0DH, 0AH, "ENTER THE NUMBER(S) ::$"
  M3 DB 0DH, 0AH, "THE SUM IS::$"
  SUM DW 0

.CODE
  MAIN PROC
  MOV AX, @DATA
  MOV DS, AX

LEA DX, M1
MOV AH, 9
INT 21H

CALL INDEC
MOV CX, AX

LEA DX, M2
MOV AH, 9
INT 21H

TOP:
CALL INDEC
ADD SUM, AX
MOV AH, 2
MOV DL, 0DH
INT 21H
MOV DL, 0AH
INT 21H
LOOP TOP

LEA DX, M3
MOV AH, 9
INT 21H

MOV AX, SUM
CALL OUTDEC

MOV AH, 4CH
INT 21H

MAIN ENDP
INCLUDE INDEC.ASM
INCLUDE OUTDEC.ASM
END MAIN

No comments:

Post a Comment