home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 183_01 / msc_asm.doc < prev    next >
Text File  |  1985-10-27  |  3KB  |  115 lines

  1.             Using Assembler with Microsoft C  ver 3 and up
  2.  
  3.  
  4.  This program is an attempt to demonstrate the ues of assembly language
  5. routines with MS C.
  6.  
  7.  The latest version of Microsoft C has a function called intdos that
  8. generates a DOS function call. This would be the easy way out namely
  9. CLS and CPOS (position the cursor). But there are times when you need
  10. to do things *** this *** way.
  11.  
  12.  I hope you find this information helpful. I have tried hard to keep it
  13. error free. If I have failed in this, or if you have suggestions,
  14. comments, or criticisms, I'd be pleased to hear them.
  15.  
  16.  My address is as follows:
  17.  
  18.                  John Scarfone
  19.                  P.O. Box 2055
  20.                  Windsor, Ontario
  21.                  Canada
  22.                  N8Y 4R5
  23.  
  24. My current UID is 75236,521.
  25.  
  26.  
  27. #include <stdio.h>
  28.  
  29. main()
  30. {
  31.      cls();          /* call cls */
  32.      cpos(10, 10);   /* position the cursor at row 10 col 10 */
  33.      printf("It works!!!!!!");
  34. }
  35.  
  36.  
  37. title   CLEARS the SCREEN
  38. name    CLS
  39.  
  40. COMMENT @
  41.  
  42.         This is the source code for 'C' function CLS. This function
  43.       does exactly the same thing as CLS in Dos.
  44.  
  45.         You must use the underscore as I did and you must use
  46.       _text for the small model.
  47.  
  48.         @
  49.  
  50.         assume cs:_text
  51. _text   segment public byte 'code'
  52.         public _cls
  53.  
  54. _cls    proc near
  55.  
  56.         push bp
  57.         mov  bp,sp
  58.  
  59.         mov  ax,0600h    ; Scroll the whole screen
  60.         mov  cx,0000     ; From 0,0 to ...
  61.         mov  dx,184fh    ; Row 24, Col 79.
  62.         mov  bh,07       ; Normal attribute
  63.         int  10h
  64.  
  65.         mov  ah,02       ; Set cursor function
  66.         mov  dx,0000     ; Row, Col 0,0
  67.         mov  bh,00       ; Page 0
  68.         int  10h
  69.  
  70.         pop  bp
  71.         ret
  72. _cls    endp
  73. _text   ends
  74.         end
  75.  
  76.  
  77. title   POSTION THE CURSOR
  78. name    CPOS
  79.  
  80. COMMENT @
  81.  
  82.         This is the source code for the 'C' function CPOS (ROL, COL);
  83.       that does exactly what it sounds like it does.
  84.  
  85.         Usage:
  86.  
  87.               INT ROW, COL; /* assign the value 0, 0 to 24, 79 */
  88.  
  89.         @
  90.  
  91.         assume cs:_text
  92. _text   segment public byte 'code'
  93.         public _cpos
  94.  
  95. _cpos    proc near
  96.  
  97.         push bp
  98.         mov  bp,sp
  99.  
  100.         mov  dx,[bp + 4]   ; Skip over return address,
  101.                            ; and save bp, and get left parm (ROW)
  102.         mov  ax,[bp + 6]   ; Get second parm (COL)
  103.         pop  bp
  104.  
  105.         mov  dh,dl         ; Row in dh
  106.         mov  dl,al         ; Col in dl
  107.         mov  ah,02         ; Function set cursor position
  108.         mov  bh,00         ; Page 0
  109.         int  10h
  110.  
  111.         ret
  112. _cpos   endp
  113. _text   ends
  114.         end
  115.