home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 9.ddi / CHAPXMPL.ZIP / DOTOTAL2.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-02-13  |  1.2 KB  |  36 lines

  1. ; Turbo Assembler    Copyright (c) 1988, 1991 By Borland International, Inc.
  2.  
  3. ; DOTOTAL2.ASM - Using old-style segment directives to interface to C++
  4.  
  5. ; From the Turbo Assembler User's Guide - Interfacing Turbo Assembler
  6. ;                                          with Borland C++
  7.  
  8. DGROUP  group    _DATA,_BSS
  9. _DATA   segment  word public 'DATA'
  10.         EXTRN    _Repetitions:WORD        ;externally defined
  11.         PUBLIC   _StartingValue           ;available to other
  12.                                           ;modules
  13. _StartingValue    DW 0
  14. _DATA   ends
  15. _BSS    segment   word public 'BSS'
  16. RunningTotal      DW  ?
  17. _BSS    ends
  18. _TEXT   segment   byte public 'CODE'
  19.         assume    cs:_TEXT,ds:DGROUP,ss:DGROUP
  20.         PUBLIC    _DoTotal
  21. _DoTotal          PROC                    ;function (near-callable
  22.                                           ; in small model)
  23.         mov       cx,[_Repetitions]       ;# of counts to do
  24.         mov       ax,[_StartingValue]
  25.         mov       [RunningTotal],ax       ;set initial value
  26. TotalLoop:
  27.         inc       [RunningTotal]          ;RunningTotal++
  28.         loop      TotalLoop
  29.         mov       ax,[RunningTotal]       ;return final total
  30.         ret
  31. _DoTotal ENDP
  32. _TEXT   ENDS
  33.         END
  34.  
  35.  
  36.