home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 6.ddi / TASMEXMP.ZIP / EXEPROG.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-06-10  |  1.5 KB  |  58 lines

  1. ; Turbo Assembler    Copyright (c) 1988, 1991 By Borland International, Inc.
  2.  
  3. ; EXEPROG.ASM - Template for writing .EXE files.
  4.  
  5. ; From the Turbo Assembler Users Guide
  6.  
  7. P8086         ;select the processor
  8. DOSSEG        ;indicate DOS segment conventions
  9. MODEL SMALL   ;select the model - can be any model
  10. DOSHEAP = 0   ;specify whether DOS heap is to be used, or
  11.               ; internal heap; 1 indicates DOS heap; 0 internal
  12. STACK 200h    ;reserve stack space as needed for application
  13.  
  14. DATASEG
  15.    ;<<Any initialized data is defined here>>
  16.  
  17. UDATASEG
  18.    ;<<Any uninitialized data is defined here>>
  19.  
  20. CODESEG
  21.    ;This marks the start of executable code
  22.    STARTUPCODE
  23.    ;EXE program has all available memory allocated to it
  24.  
  25. IF DOSHEAP
  26.    ;Release all memory except the amount currently being used
  27.    ;End of stack is end of non-heap portion of program
  28.    MOV BX,SP
  29.    ADD BX,15    ;convert SP into paragraphs
  30.    SHR BX,4
  31.    MOV AX,SS    ;calculate size of program using ES PSP address
  32.    ADD BX,AX
  33.    MOV AX,ES
  34.    SUB BX,AX
  35.    MOV AH,4AH   ;resize memory block with PSP
  36.    INT 21H      ;address in ES
  37. ENDIF
  38.  
  39. ;Now execute user code.
  40. ;The code can be placed here, but it looks better to call it;
  41. ;DoIt returns an exit value in AL, which corresponds to ERRORLEVEL in
  42. ;.BAT files.
  43. CALL DoIt
  44.  
  45.    ;Exit to DOS when complete
  46.    MOV AH,4CH
  47.    INT 21H
  48.    RET
  49.  
  50. ;Arguments to this procedure:
  51. ;ES=PSP address (for command-line arguments)
  52. ;Must return an exit value in AL
  53. DoIt PROC NEAR
  54.    ;<<Your code goes here>>
  55.    RET
  56. DoIt ENDP
  57. END
  58.