home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pasos2b.zip / lib / passtart.asm < prev    next >
Assembly Source File  |  1993-11-03  |  4KB  |  154 lines

  1. ;*
  2. ;* FileName:   passtart.inc
  3. ;* $Source: E:/usr/src/c-code/pascal/RCS/LIB/passtart.asm,v $
  4. ;* $Author: wjw $
  5. ;* $Date: 1993/11/03 15:54:50 $
  6. ;* $Locker: wjw $
  7. ;* $State: Exp $
  8. ;* $Revision: 1.1 $
  9. ;* Description:
  10. ;*      Part of the runtime library which comes with PASCAL for OS/2
  11. ;*      
  12. ;*
  13. ;* History:
  14. ;*      First created by Willem Jan Withagen ( wjw@eb.ele.tue.nl ),
  15. ;*                    on Mon July 26 23:30:03 MET 1993
  16. ;* Copyright:
  17. ;*      Copyright (c) 1993 by Willem Jan Withagen and 
  18. ;*                      Digital Information Systems group, TUE
  19. ;*      For copying and distribution information see the file COPYRIGHT.
  20. ;*
  21. ;* 
  22.         .386
  23.         include pashead.inc
  24.  
  25. STACK   SEGMENT
  26.         db 128*1024 DUP(?)
  27. STACK   ENDS        
  28.  
  29. DATA    SEGMENT
  30.         ;  Specify the DISPLAY save location where all the dynamic pointers are 
  31.         ;  kept. 64 Levels should be more than sufficient.
  32. $$display       DD 64 DUP(0)
  33. $$$RetSave      DD 1 DUP(?)
  34. DATA    ENDS
  35.  
  36. CODE    SEGMENT
  37.         EXTERN  DOS32OPEN:PROC
  38.         EXTERN  DOS32CLOSE:PROC
  39.         EXTERN  DOS32WRITE:PROC
  40.         EXTERN  DOS32READ:PROC
  41.         EXTERN  DOS32QUERYHTYPE:PROC
  42.         EXTERN  DOS32EXIT:PROC
  43.         EXTERN  DOS32ALLOCMEM:PROC
  44.         EXTERN  DOS32FREEMEM:PROC
  45.         EXTERN  DOS32SUBALLOC:PROC
  46.         EXTERN  DOS32SUBFREE:PROC
  47.         EXTERN  DOS32SUBSET:PROC
  48.         EXTERN  DOS32SUBUNSET:PROC
  49.         
  50.         ;  Using this macro, it is possible to imitate the C call mechanism
  51.         ;  as long as there is only ONE C call going one at the time.
  52.         ;  'size' indicates the number of parameters
  53. CCALL   MACRO name,size
  54.     $&name  PROC
  55.         pop [$$$retsave]
  56.         call name
  57.         add esp,size*4
  58.         push [$$$retsave]
  59.         ret
  60.     $&name  ENDP        
  61. ENDM
  62.  
  63.         ;  These routines are available with $-prefix to be called from the
  64.         ;  PASCAL programs.
  65. CCALL   DOS32OPEN      ,8
  66. CCALL   DOS32CLOSE     ,1
  67. CCALL   DOS32WRITE     ,4
  68. CCALL   DOS32READ      ,4
  69. CCALL   DOS32QUERYHTYPE,3
  70. CCALL   DOS32EXIT      ,2
  71. CCALL   DOS32AlLOCMEM  ,3
  72. CCALL   DOS32FREEMEM   ,1
  73. CCALL   DOS32SUBALLOC  ,3
  74. CCALL   DOS32SUBFREE   ,3
  75. CCALL   DOS32SUBSET    ,3
  76. CCALL   DOS32SUBUNSET  ,1
  77.  
  78.         EXTERN $$Pmain:PROC
  79. $$$Start PROC
  80.         ;  First set something up which looks like an old Framepointer
  81.         mov ebp,esp
  82.         call $$StdInit     ; Initialise the funtime system
  83.         call $$Pmain       ; Execute the user program
  84.         ;  Probably a call to flush/close all pascal handles?
  85.         call $$StdExit
  86.         ;  Return to the calling system.
  87.         push 0
  88.         push 1
  89.         call DOS32EXIT
  90.         ret
  91. $$$Start ENDP        
  92.  
  93.         ; Additional routines which are use from the generated code
  94.         ; But are not easily programmed in PASCAL straight
  95. $$memcpy PROC
  96. $$memcopy PROC
  97.         ; This will evaluate to use $$$memcpy
  98.         ; But $$..... can not be used from PASCAL.
  99. $$memcopy ENDP
  100.         ; copy param1 to param2 for param3 bytes
  101.         ; Currently just the dumb and simple way, could be better by doing
  102.         ; dword alligned moves, and patches at the begin and and.
  103.         mov edi, [esp+8]       ; Param 2 (Destination)
  104.         mov esi, [esp+4]       ; Param 1 (Source)
  105.         mov ecx, [esp+12]
  106.         cld
  107.         rep movsb
  108.         ret 12
  109. $$memcpy ENDP
  110.  
  111. $$OrWord PROC
  112.         mov eax,[esp+8]
  113.         or  eax,[esp+4]
  114.         ret 8
  115. $$OrWord ENDP
  116.  
  117. $$AndWord PROC
  118.         mov eax,[esp+4]
  119.         and eax,[esp+8]
  120.         ret 8
  121. $$AndWord ENDP
  122.  
  123. $$InvWord PROC
  124.         mov eax,[esp+4]
  125.         not eax
  126.         ret 4
  127. $$InvWord ENDP
  128.  
  129. $$shl   PROC 
  130.         mov eax,[esp+4]
  131.         mov ecx,[esp+8]
  132.         shl eax,cl
  133.         ret 8
  134. $$shl   ENDP
  135.  
  136. $$straddr   PROC
  137.         ; The parameter is actually an address
  138.         ; This is returned
  139.         mov eax,[esp+4]
  140.         ret 4
  141. $$straddr   ENDP
  142.  
  143. CODE    ENDS
  144.                     END $$$Start
  145. ;*
  146. ;* $Log: passtart.asm,v $
  147. ;; Revision 1.1  1993/11/03  15:54:50  wjw
  148. ;; Started adminstration for the RUNTIME LIB
  149. ;;
  150. ;*
  151. ;*      First created by Willem Jan Withagen ( wjw@eb.ele.tue.nl ),
  152. ;*                    on Mon July 26 23:30:03 MET 1993
  153. ;* 
  154.