Microsoft (R) Macro Assembler Version 5.10 9/13/10 01:09:37 MINIMAL DEMO PROGAM CALC2 Page 1-1 1 TITLE MINIMAL DEMO PROGAM CALC2 2 PAGE ,132 3 ;---------------------------------------------------------; 4 ; Author: M.S. Alam ; 5 ; Date: 9/25/1991 ; 6 ; Purpose: To demonstrate the simplest program structure ; 7 ; and write a program to add and subtract two 16-; 8 ; bit numbers. ; 9 ;********************************************************** 10 0000 STACK SEGMENT PARA STACK 'STACK' 11 0000 0040[ DB 64 DUP('STACK') 12 53 54 41 43 4B 13 ] 14 15 0140 STACK ENDS 16 ;********************************************************** 17 0000 DSEG SEGMENT PARA PUBLIC 'DATA' 18 0000 00FF DATA1 DW 0255 19 0002 0FFF DATA2 DW 4095 20 0004 0000 SUM DW ? 21 0006 0000 DIFF DW ? 22 0008 DSEG ENDS 23 SUBTTL Here is the main program 24 ;********************************************************* 25 SUBTTL The main program starts here 26 ;--------------------------------------------------------- 27 0000 CSEG SEGMENT PARA PUBLIC 'CODE' 28 0000 OUR_PROG PROC FAR 29 ASSUME CS:CSEG, DS:DSEG, SS:STACK 30 ; Set up the stack to contain the proper values 31 ; so this program can return to debug. 32 ; 33 0000 1E PUSH DS ; Put return seg. addr on stack 34 0001 B8 0000 MOV AX,0 ; Clear a register AX 35 0004 50 PUSH AX ; Put zero return address on stack 36 37 ; Initialize the data segment address 38 0005 B8 ---- R MOV AX,DSEG ;Initialize DS 39 0008 8E D8 MOV DS,AX 40 ; ------------------------------------------------------------- 41 ; Perform the addition 42 ; 43 000A A1 0000 R MOV AX,DATA1 ; Load first word to reg AX 44 000D 8B 0E 0002 R MOV CX,DATA2 ; Load second word to reg BX 45 0011 03 C1 ADD AX,CX ; Add data at mem loc DATA1 AND DATA2 46 ; Store the sum in memory 47 ; 48 0013 A3 0004 R MOV SUM,AX ; Store the result at mem loc SUM 49 ; ------------------------------------------------------------- 50 ; Perform the subtraction 51 0016 A1 0000 R MOV AX,DATA1 ; Reload first word to reg AX 52 0019 91 XCHG AX,CX ; Move large number to AX 53 001A 2B C1 SUB AX,CX ; Data at DATA2 - Data at DATA1 Microsoft (R) Macro Assembler Version 5.10 9/13/10 01:09:37 MINIMAL DEMO PROGAM CALC2 Page 1-2 The main program starts here 54 ; Store the difference in memory 55 ; 56 001C A3 0006 R MOV DIFF,AX ; Store the result at mem loc DIFF 57 ; ------------------------------------------------------------- 58 001F CB RET ; Retrurn to DEBUG 59 0020 OUR_PROG ENDP 60 0020 CSEG ENDS 61 END OUR_PROG Microsoft (R) Macro Assembler Version 5.10 9/13/10 01:09:37 MINIMAL DEMO PROGAM CALC2 Symbols-1 Segments and Groups: N a m e Length Align Combine Class CSEG . . . . . . . . . . . . . . 0020 PARA PUBLIC 'CODE' DSEG . . . . . . . . . . . . . . 0008 PARA PUBLIC 'DATA' STACK . . . . . . . . . . . . . 0140 PARA STACK 'STACK' Symbols: N a m e Type Value Attr DATA1 . . . . . . . . . . . . . L WORD 0000 DSEG DATA2 . . . . . . . . . . . . . L WORD 0002 DSEG DIFF . . . . . . . . . . . . . . L WORD 0006 DSEG OUR_PROG . . . . . . . . . . . . F PROC 0000 CSEG Length = 0020 SUM . . . . . . . . . . . . . . L WORD 0004 DSEG @CPU . . . . . . . . . . . . . . TEXT 0101h @FILENAME . . . . . . . . . . . TEXT calc2 @VERSION . . . . . . . . . . . . TEXT 510 58 Source Lines 58 Total Lines 15 Symbols 46100 + 407881 Bytes symbol space free 0 Warning Errors 0 Severe Errors