TITLE   MINIMAL DEMO PROGAM CALC2                           
        PAGE      ,132
;---------------------------------------------------------;
; Author: M.S. Alam                                       ;
; Date: 9/25/1991                                         ;
; Purpose: To demonstrate the simplest program structure  ;
;          and write a program to add and subtract two 16-;
;          bit numbers.                                   ;
;**********************************************************
STACK   SEGMENT   PARA STACK 'STACK'
        DB 64 DUP('STACK')
STACK   ENDS
;**********************************************************
DSEG    SEGMENT   PARA PUBLIC 'DATA'
DATA1   DW   0255
DATA2   DW   4095
SUM     DW   ?
DIFF    DW   ?
DSEG    ENDS
SUBTTL  Here is the main program
;*********************************************************
SUBTTL  The main program starts here
;---------------------------------------------------------
CSEG     SEGMENT   PARA PUBLIC 'CODE'
OUR_PROG PROC  FAR
         ASSUME CS:CSEG, DS:DSEG, SS:STACK
;  Set up the stack to contain the proper values 
;  so this program can return to debug.
;  
         PUSH DS           ; Put return seg. addr on stack
         MOV AX,0          ; Clear a register AX
         PUSH AX           ; Put zero return address on stack

;  Initialize the data segment address
         MOV AX,DSEG      ;Initialize DS
         MOV DS,AX
;  -------------------------------------------------------------
;  Perform the addition
;
         MOV AX,DATA1     ; Load first word to reg AX
         MOV CX,DATA2     ; Load second word to reg BX
         ADD AX,CX        ; Add data at mem loc DATA1 AND DATA2
;  Store the sum in memory
;
         MOV SUM,AX       ; Store the result at mem loc SUM
;  -------------------------------------------------------------
;  Perform the subtraction
         MOV AX,DATA1     ; Reload first word to reg AX
         XCHG AX,CX       ; Move large number to AX
         SUB AX,CX        ; Data at DATA2 - Data at DATA1
;  Store the difference in memory
;        
         MOV DIFF,AX      ; Store the result at mem loc DIFF
;  -------------------------------------------------------------
         RET              ; Retrurn to DEBUG
OUR_PROG ENDP
CSEG     ENDS
         END OUR_PROG
;**********************************************************

