Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
35
Добавлен:
17.04.2015
Размер:
1.73 Кб
Скачать
/* Turbo Assembler example. Copyright (c) 1993 By Borland International, Inc.

   COUNTER.CPP

   Usage: bcc counter.cpp countadd.asm

   From the Turbo Assembler User's Guide 
   Ch. 18: Interfacing Turbo Assembler with Borland C++
*/

#include <stdio.h>

class counter {
     // Private member variables:
     int count;         // The ongoing count
   public:
        counter(void){ count=0; }
        int  get_count(void){return count;}

        // Two functions that will actually be written 
        // in assembler: 
        void increment(void);
        void add(int what_to_add=-1); 
         // Note that the default value only
         // affects calls to add, it does not
         // affect the code for add.
};

extern "C" {
  // To create some unique, meaningful names for the 
  // assembler routines, prepend the name of the class 
  // to the assembler routine. Unlike some assemblers, 
  // Turbo Assembler has no problem with long names.
  void counter_increment(int *count);    // We will pass a 
                                         // pointer to the
                                         // count variable. 
                                         // Assembler will
                                         // do the incrementing.
  void counter_add(int *count,int what_to_add);
}

void counter::increment(void)
{
  counter_increment(&count);
}

void counter::add(int what_to_add)
{
  counter_add(&count, what_to_add);
}

int main()
{
   counter Counter;

   printf( "Before count: %d\n", Counter.get_count() );
   Counter.increment();
   Counter.add( 5 );
   printf( "After count:  %d\n", Counter.get_count() );
   return 0;
}



Соседние файлы в папке USRGUIDE
  • #
    17.04.2015668 б34CASMLINK.ASM
  • #
    17.04.20151.07 Кб34COMPROG.ASM
  • #
    17.04.2015616 б34CONCISE.ASM
  • #
    17.04.20152.45 Кб34COUNT.ASM
  • #
    17.04.20151.04 Кб34COUNTADD.ASM
  • #
    17.04.20151.73 Кб35COUNTER.CPP
  • #
    17.04.20152.73 Кб34COUNTLG.ASM
  • #
    17.04.2015520 б34CSPEC.ASM
  • #
    17.04.20156.05 Кб34DOS.INC
  • #
    17.04.20151.35 Кб35DOTOTAL.ASM
  • #
    17.04.20153.38 Кб34ENVSTR.ASM