home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / sedcode.seq < prev    next >
Text File  |  1990-05-28  |  6KB  |  169 lines

  1. \ SEDCODE.SEQ   The Assembly code needed for SED        by Tom Zimmer
  2.  
  3. editor definitions
  4.  
  5. headerless
  6.  
  7. code tl:        ( a1 -- lseg a1 )       \ add list segment base to stack
  8.                 pop ax                  \ under a1 in prep for long operation
  9.                 mov dx, ' lseg >body
  10.                 2push
  11.                 end-code
  12.  
  13. code tl+        ( a1 --- a2 )   \ a2 = a1 + 2, the list entry size in bytes
  14.                 pop ax          add ax, # 2
  15.                 1push           end-code
  16.  
  17. code tl-        ( a1 --- a2 )   \ a2 = a1 - 2, the list entry size in bytes
  18.                 pop ax          sub ax, # 2
  19.                 1push           end-code
  20.  
  21. code tl*        ( n1 -- n2 )    \ n2 = n1 * 2, the list entry size in bytes
  22.                 pop ax          shl ax, # 1
  23.                 1push           end-code
  24.  
  25. code getdiskfree        \ return free space from disk
  26.                 ( dv --- avail.clusters bytes/sec secs/cluster )
  27.                 mov ah, # 54
  28.                 pop dx
  29.                 int 33
  30.                 push bx
  31.                 push cx
  32.                 1push
  33.                 end-code
  34.  
  35. code >lineptr   ( n1 --- a1 )
  36.                 pop ax
  37.                 shl ax, # 1
  38.                 1push
  39.                 end-code
  40.  
  41. code lineptr   ( --- a1 )
  42.                 mov ax, ' curline >body
  43.                 shl ax, # 1             \ shift left by 2, for word size
  44.                 1push                   \ of list pointer table.
  45.                 end-code
  46.  
  47. code tl:@       ( a1 -- n1 )
  48.                 pop bx          mov ds, ' lseg >body
  49.                 mov ax, 0 [bx]
  50.                 mov bx, cs      mov ds, bx
  51.                 1push           end-code
  52.  
  53. code tl:!       ( n adr -- )
  54.                 pop bx          mov ds, ' lseg >body
  55.                 pop ax          mov 0 [bx], ax
  56.                 mov bx, cs      mov ds, bx
  57.                 NEXT            END-CODE
  58.  
  59. code tl:+!      ( n adr -- )
  60.                 pop bx          mov ds, ' lseg >body
  61.                 pop ax          add 0 [bx], ax
  62.                 mov bx, cs      mov ds, bx
  63.                 NEXT            END-CODE
  64.  
  65. code endtst?   ( --- f1 )
  66.                 mov bx, ' curline >body
  67.                 shl bx, # 1             \ shift left by 2, for word size
  68.                 sub bx, # 2
  69.                 mov ds, ' lseg >body
  70.                 mov ax, 0 [bx]
  71.                 mov bx, cs      mov ds, bx
  72.                 cmp ax, ' tend >body
  73.            u>=  if      sub ax, ax
  74.                         1push
  75.                 then
  76.                 mov ax, # true
  77.                 1push           end-code
  78.  
  79. code rmsave     ( a1 --- a1 c1 )        \ fetch contents of a1 and returns
  80.                                         \ as c1 and accumulate max as RMMAX
  81.                 pop bx
  82.                 push bx
  83.                 sub ax, ax
  84.                 mov al, 0 [bx]
  85.                 push ax
  86.                 sub ax, # 2
  87.                 cmp ax, ' rmmax >body
  88.              <= if      next
  89.                 then
  90.                 mov ' rmmax >body ax
  91.                 next            end-code
  92.  
  93. code #lineseg   ( n1 --- seg )        \ n1 = line, seg = line memory segment
  94.                 pop bx
  95.                 shl bx, # 1
  96.                 mov ds, ' lseg >body
  97.                 mov ax, 0 [bx]
  98.                 mov bx, cs
  99.                 mov ds, bx              \ restore DS
  100.                 1push           end-code
  101.  
  102. code clipline ( a1 n1 --- a2 n3 )
  103.                 pop ax                          \ AX = n1 = text length
  104.                 pop dx                          \ DX = a1 = text address
  105.                 mov bx, ' winoff >body          \ get window offset
  106.                 add dx, bx                      \ add to text address
  107.                 sub ax, bx                      \ subtract from text length
  108.                 cmp ax, # 0
  109.              0< if      mov ax, # 0             \ limit to zero length
  110.                 then
  111.                 mov bx, ' last.textcol >body
  112.                 sub bx, ' first.textcol >body
  113.                 add bx, # 1
  114.                 cmp ax, bx                      \ no longer than text.width
  115.               > if      mov ax, bx
  116.                 then
  117.                 2push           end-code
  118.  
  119. HEADERS         \ 05/28/90 21:29:20.68 TJZ
  120.  
  121. code window.left ( --- n1 )     \ absolute left edge of window
  122.                 mov ax, ' first.textcol >body
  123.                 sub ax, # 1
  124.                 1push           end-code
  125.  
  126. code window.right ( --- n1 )    \ absolute right edge of window.
  127.                 mov ax, ' last.textcol >body
  128.                 add ax, # 1
  129.                 1push           end-code
  130.  
  131. code text.width ( --- n1 )      \ width of text portion of window
  132.                 mov ax, ' last.textcol >body
  133.                 sub ax, ' first.textcol >body
  134.                 add ax, # 1
  135.                 1push           end-code
  136.  
  137. HEADERLESS      \ 05/28/90 21:29:32.99 TJZ
  138.  
  139. code len-accum  ( n1 --- n1 )   \ sum in byte length n1 to double file length
  140.                 mov ax, # 0     \ in double length variable CURRENTSIZE
  141.                 pop dx
  142.                 push dx
  143.                 mov bx, # currentsize
  144.                 add 2 [bx], dx
  145.                 adc 0 [bx], ax
  146.                 next            end-code
  147.  
  148. \ adjust the line pointer table lines n3 through n2 by n1 segs.
  149.  
  150. code adj_ptr_lines ( n1 n2 n3 --- )
  151.                 pop bx                  \ starting line number
  152.                 pop cx                  \ limit line number
  153.                 sub cx, bx              \ calc times through loop
  154.                 dec cx                  \ correct count
  155.                 shl bx, # 1             \ convert to word offset
  156.                 pop ax                  \ incrementer
  157.                 mov ds, ' lseg >body    \ segment where located
  158.           1 $:  add 0 [bx], ax          \ add incrementer to pointer entry
  159.                 add bx, # 2             \ bump to next entry
  160.                 dec cx                  \ decrement counter
  161.                 j0>= 1 $                 \ are we done
  162.                 mov bx, cs
  163.                 mov ds, bx
  164.                 next            end-code
  165. headers
  166.  
  167. forth definitions
  168.  
  169.