home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / CSR30_1.ZIP / CSRSHELL.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-09-10  |  2.3 KB  |  101 lines

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