V

256 1024 * value Obj.v.size \ 隨資料量改變

0 value Obj.v

0 value Obj.v.Index

: Obj.v.初始化 ( -- )

 Obj.v.size allocate

 drop dup

 to Obj.v

 to Obj.v.Index

 ;

: Obj.v空間釋放 ( size -- )

  Obj.v free drop 

 ;

: Obj.v.size變更 ( size -- )

 to Obj.v.size

 Obj.v空間釋放

 Obj.v.初始化

 ;

: Obj.v.>Float ( s" float" -- ) 

  >float drop

  Obj.v.Index f!

  Obj.v.Index 8 + to Obj.v.Index

  ;

create  Tag$  256 allot

create arg1$  256 allot

create arg2$  256 allot

create arg3$  256 allot

: ,>            ( -<string">- ) \ compile string delimited by " as a counted string at here

                HERE 

                [CHAR] > PARSE 

                ", 

                0 C, 

                ALIGN 

                COUNT \N->CRLF

                ;

                

\        sp     equ     <esp>   \ Stack Pointer for Forth, the hardware stack

\        rp     equ     <ebp>   \ Return Pointer, Forth's subroutine stack

\        ip     equ     <esi>   \ Instruction Pointer for Forth

\        up     equ     <edx>   \ USER pointer

\        tos    equ     <ebx>   \ Top of stack is in EBX

\                       <edi>   \ CONSTANT ZERO

NCODE (S>)      ( -- addr len )                \ for s" type strings

                push    ebx  

                lea     ecx, 1 [esi]           \ start of string

                movzx   ebx, byte ptr [esi]    \ length of string in TOS

                push    ecx                    \ save addr of string

                lea     esi, 8 [ecx] [ebx]     \ optimised next, account for len & null at end

                and     esi, # -4              \ align

                mov     eax, -4 [esi]          \ next word

                exec    c;                     \ go do it

: v.Compiletime

  s" <td " Tag$ place

  tag$ +place

  \ +>

  \ HTML_Output

  ;  

: v.arg ( --- kiss )

\ ascii > word count HTML$ place

\ BL word count a1$ place

\ ascii ; word count a1$ place    

0x0a word count tag$ place

    tag$ count arg1$ place

    

    arg1$ count 0x20 scan arg2$ place 

    arg1$ c@ arg2$ c@ - arg1$ c! 

    arg2$ count BL skip arg2$ place

    arg2$ count 0x20 scan arg3$ place 

    arg2$ c@ arg3$ c@ - arg2$ c!

    

    arg3$ count BL skip arg3$ place

    ;  

          

: v.RunTime ( -- )  

  v.arg

                             ( tag$ count  cr type   cr )

  arg1$ count Obj.v.>Float   ( Obj.v.Index 8 - f@ f. cr )

  arg2$ count Obj.v.>Float   ( Obj.v.Index 8 - f@ f. cr )

  arg3$ count Obj.v.>Float   ( Obj.v.Index 8 - f@ f. cr )

  ; 

    

: V  \ comp: ( -<string">- ) run: ( -- addr len )

  STATE @            \  0: 執行態  非0: 編譯態

  IF     

   \ 編譯態Compiletime: 

   COMPILE  (S>) ,>

   COMPILE v.Compiletime                  

  ELSE    

  \ 執行態Runtime:

   v.RunTime 

   THEN 

  ; IMMEDIATE