.model small .data num1 db ? num2 db ? sum db ? String db 13,10,13,10,"Please Enter a Number: $" .stack 100h .code main: call Initsegs call PrintEnter call ReadNum1 call PrintEnter Call ReadNum2 call AddNums Call PrintSum call exit Proc InitSegs ; Setup String Pointers in DS and ES push ax ; SAVE AX to Stack mov ax, @data ; Get address of .DATA segment mov ds,ax ; PUt it in DS mov es,ax ; Put it in ES pop ax ; RESTORE AX from Stack RET EndP InitSegs PROC DELAY push ax bx mov bx, 02000H reload_ax: mov ax, 0FFFFh dec_ax: dec ax jnz dec_ax dec bx jnz reload_ax pop bx ax RET ENDP DELAY PROC PrintEnter ; Print a String in Color at ROW,COLUMN on Screen push ax dx ; SAVE bp ax bx cx dx mov ah,9h ; setup for function 13H of INT 10h API mov dx, Offset String ; Color Attr in BL INT 21h ; Execute INT 10H API pop dx ax RET ENDP PrintEnter ; ==== WAIT4KEY ==== PROC Wait4Key ; Wait for a key to be pressed push ax ; SAVE AX mov ah,0h ; Setup for function 0 of INT 16h API int 16h ; Execute INT 16H API pop ax ; RESTORE AX from Stack RET ENDP Wait4key Proc ReadNum1 push ax mov ah,1 INT 21h mov Num1,al pop ax RET ENDP ReadNum1 Proc ReadNum2 push ax mov ah,1 INT 21h mov Num2,al pop ax RET ENDP ReadNum2 Proc AddNums push ax bx mov al, NUM1 mov bl, Num2 add al,bl mov SUM, al ; add al,bl ; sub al,'0' ; Convert Char to INT (0-9 Only) ; mov SUM,al ; pop bx ax RET ENDP Addnums PROC PrintSum push dx ax mov dl,SUM mov ah,2 INT 21h pop ax dx RET ENDP PrintSum ; ==== EXIT ==== PROC exit ; EXIT to DOS push ax ; SAVE AX to Stack mov ah, 4ch ; Setup Function 4ch of INT 21H int 21h ; EXECUTE INT 21H API CALL pop ax ; RESTORE AX RET ENDP exit end main