home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / zen / internal.src < prev    next >
Text File  |  1990-01-09  |  4KB  |  203 lines

  1. \*
  2.  *   ZEN 1.10  Macros and internals
  3.  *     C 1990  by Martin Tracy
  4.  *             Last modified  1.1.90
  5.  *\
  6.  
  7. TRUE EQU LOX?   \ Include locals?
  8. TRUE EQU MUX?   \ Include multitasking?
  9. TRUE EQU VOX?   \ Include vocabularies?
  10.  
  11. ASSEMBLER
  12.  
  13. TRUTH   EQU   0FFFFh     ; Boolean value for true
  14.  
  15. CSDummy LABEL WORD       ; used like:  lods  cs:CSDummy
  16.  
  17. NEXT    MACRO
  18.         lods  cs:CSDummy
  19.         jmp   ax
  20.         ENDM
  21.  
  22. ISCOLON MACRO
  23.         call  DoColon
  24.         ENDM
  25.  
  26. ISCONSTANT MACRO
  27.         jmp   NEAR PTR DoConstant
  28.         ENDM
  29.  
  30. ISVARIABLE MACRO
  31.         jmp   NEAR PTR DoVariable
  32.         ENDM
  33.  
  34. ISCREATE MACRO
  35.         jmp   NEAR PTR DoCreate
  36.         ENDM
  37.  
  38. ISVALUE MACRO
  39.         jmp   NEAR PTR DoValue
  40.         jmp   NEAR PTR DoValTo
  41.         ENDM
  42. ;
  43. ; Code fields
  44. ;
  45. ; Colon definition code field
  46. DoColon PROC
  47.         xchg  bp,sp
  48.         push  si
  49.         xchg  bp,sp
  50.         pop   si
  51.         NEXT
  52. DoColon ENDP
  53.  
  54.  
  55. ; DOES> code field
  56. DoDoes  PROC
  57.         xchg  bp,sp
  58.         push  si
  59.         xchg  bp,sp
  60.         pop   si
  61.         push  bx
  62.         add   ax,3
  63.         xchg  ax,bx
  64.         mov   bx,cs:[bx]
  65.         NEXT
  66. DoDoes  ENDP
  67.  
  68.  
  69. ; CONSTANT VARIABLE and CREATE code fields
  70. DoConstant  PROC  ; ( - w)
  71. DoVariable:
  72. DoCreate:
  73.         push  bx
  74.         add   ax,3
  75.         xchg  ax,bx
  76.         mov   bx,cs:[bx]
  77.         NEXT
  78. DoConstant ENDP
  79.  
  80. ; VALUE 1st code field
  81. DoValue PROC  ; ( - w)
  82.         push  bx
  83.         add   ax,6
  84.         xchg  ax,bx
  85.         mov   bx,cs:[bx]
  86.         mov   bx,[bx]
  87.         NEXT
  88. DoValue ENDP
  89.  
  90. ; VALUE 2nd code field
  91. DoValTo PROC  ; ( w)
  92.         add   ax,3
  93.         xchg  ax,di
  94.         mov   di,cs:[di]
  95.         mov   [di],bx
  96.         pop   bx
  97.         NEXT
  98. DoValTo ENDP
  99. ;
  100. ; In-liners
  101. ;
  102. ; Push following in-line cell onto stack
  103. Lit:    ; ( - w)
  104. Tic:    lods  cs:CSDummy
  105.         push  bx
  106.         mov   bx,ax
  107.         NEXT
  108.  
  109. ; String primitive
  110. SLit:   ; ( - addr u)
  111.         lods  cs:CSDummy
  112.         push  bx
  113.         mov   bx,ax
  114.         inc   ax
  115.         mov   bl,[bx]
  116.         sub   bh,bh
  117.         push  ax
  118.         NEXT
  119. END-CODE
  120.  
  121.  
  122. \ L O C A L s
  123.  
  124. LOX? \*IF
  125. ASSEMBLER
  126. ; Colon definition with local stack frame
  127. DoFrame PROC
  128.         xchg  bp,sp
  129.         push  si
  130.         push  [LXv]
  131.         sub   sp,16
  132.         mov   ax,OFFSET DWClean
  133.         push  ax
  134.         mov   [LXv],bp
  135.         xchg  bp,sp
  136.         pop   si
  137.         NEXT
  138. DoFrame ENDP
  139.  
  140. ; DOES> with local stack frame
  141. DoFramD PROC
  142.         xchg  bp,sp
  143.         push  si
  144.         push  [LXv]
  145.         sub   sp,16
  146.         mov   ax,OFFSET DWClean
  147.         push  ax
  148.         mov   [LXv],bp
  149.         xchg  bp,sp
  150.         pop   si
  151.         push  bx
  152.         add   ax,3
  153.         xchg  ax,bx
  154.         mov   bx,cs:[bx]
  155.         NEXT
  156. DoFramD ENDP
  157.  
  158. ; Discard local stack frame.  Previous EXIT increments bp by 2.
  159. DWClean dw    OFFSET DoClean
  160. DoClean PROC
  161.         xchg  bp,sp
  162.         add   sp,16
  163.         pop   [LXv]
  164.         pop   si
  165.         xchg  bp,sp
  166.         NEXT
  167. DoClean ENDP
  168.  
  169. ; Create a local and its procedure.
  170. ISLOCAL MACRO  n
  171. Loc&n&  PROC
  172.         jmp   Lcl&n&
  173.         jmp   Lcl&n&t
  174. Loc&n&  ENDP
  175.         ENDM
  176.  
  177. ISLOCN  MACRO  n
  178. Lcl&n&  PROC  ; Local 1st code field.
  179.         push  bx
  180.         mov   di,[LXv]
  181.         mov   bx,ss:[di+(n*2)+4]
  182.         NEXT
  183. Lcl&n&  ENDP
  184.  
  185. Lcl&n&t PROC  ; Local 2nd code field.
  186.         mov   di,[LXv]
  187.         mov   ss:[di+(n*2)+4],bx
  188.         pop   bx
  189.         NEXT
  190. Lcl&n&t ENDP
  191.         ENDM
  192.  
  193. ISLOCN 0
  194. ISLOCN 1
  195. ISLOCN 2
  196. ISLOCN 3
  197. ISLOCN 4
  198. ISLOCN 5
  199. ISLOCN 6
  200. ISLOCN 7
  201. END-CODE
  202. *\
  203.