home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / c / csr20a.arc / CSRSHELL.ASM < prev    next >
Assembly Source File  |  1986-09-10  |  2KB  |  102 lines

  1.  
  2. Comment *
  3.  
  4.     Shell for assembly routine interface to Microsoft C.
  5.  
  6.     Provided as a convenience for C Spot Run C Add-On Library users.
  7.  
  8.     Note on return values:  The C function is given the value of AX
  9.     upon return of a char, short, int, or any of these three unsigned.
  10.     On return of a long or unsigned long, the high order word goes in
  11.     DX, and the low in AX.  A struct, union, float, or double must be
  12.     returned with the address in AX and the value in a static area of
  13.     memory.  A near pointer is returned in AX, and a far with the 
  14.     segment selector in DX and the offset in AX.
  15.  
  16.     For more information on assembly interface, consult Chapter 8
  17.     (Pages 157-172) of the Microsoft 3.0 User's Guide.
  18.  
  19. *
  20.  
  21. ;=============================================================================
  22. ;                Declarations
  23. ;=============================================================================
  24.  
  25. TRUE    EQU    1
  26. FALSE    EQU    0
  27.  
  28. LARGE    EQU    FALSE            ; TRUE for Large Model
  29.  
  30. if    LARGE
  31. @AB    EQU    6
  32. else
  33. @AB    EQU    4
  34. endif
  35.  
  36. ARG1    EQU    @AB
  37. ARG2    EQU    @AB+2
  38. ARG3    EQU    @AB+4
  39. ARG4    EQU    @AB+6
  40. ARG5    EQU    @AB+8
  41. ARG6    EQU    @AB+10
  42. ARG7    EQU    @AB+12
  43.  
  44. ;=============================================================================
  45. ;                    Data
  46. ;=============================================================================
  47.  
  48. DGROUP    group    _DATA
  49. _DATA    segment word public 'DATA'
  50.     assume    ds:DGROUP
  51.  
  52.     ; Your Data goes here . . .
  53.  
  54. _DATA    ends
  55.  
  56. ;=============================================================================
  57. ;                   Code
  58. ;=============================================================================
  59.  
  60.     assume cs:_text
  61.  
  62. _text    segment public    byte    'code'
  63.  
  64.     public    _shell
  65.  
  66. if    LARGE
  67. _shell    proc    far
  68. else
  69. _shell    proc    near
  70. endif
  71.  
  72.     push    bp             ; Save Base of Stack
  73.     mov    bp,sp            ; Establish Stack Frame
  74.  
  75.     push    si             ; Save MSC's Register Vars
  76.     push    di             ; Save MSC's Register Vars
  77.     push    ds             ; Save Data and Extra Segs
  78.     push    es
  79.  
  80.     ;===============================
  81.     ;       User Code
  82.     ;===============================
  83.     
  84.         mov    bh,[bp+ARG1]        ; Sample of Getting Argument
  85.         mov    ah,[bp+ARG2]        ; Another Sample
  86.  
  87.     pop    es            ; Restore Data and Extra Segs
  88.     pop    ds
  89.     pop    di            ; Restore MSC's Register Vars
  90.     pop    si            ; Restore MSC's Register Vars
  91.  
  92.     mov    sp,bp            ; Restore Stack Pointer
  93.     pop    bp             ; and Base of Stack
  94.  
  95.     ret                ; Return to Caller
  96.  
  97. _shell    endp
  98.  
  99. _text    ends
  100.  
  101. end
  102.