WebAssembly by Forth

38 views
Skip to first unread message

燕南

unread,
Apr 17, 2019, 7:07:08 AM4/17/19
to 符式協會
\ webAssembly

webAssembly

i32.const 1 i32.const 2 i32.add

Forth : ( Win32Forth cell = 4 byte 32bits )

1 2 +


i64.const 1 i64.const 2 i64.add
Forth : ( Win32Forth cell = 4 byte 32bits )
0 1 0 2 d+
or
1 s>d 2 s>d d+


: runtime_i32.const
  bl word count 
  (NUMBER?)
  if
   drop \ ." down32 up32 "
  else
  ." it is not Number! "
  then 
  ;

: i32.const  \ comp: ( -<string">- ) run: ( -- Number32 )
  STATE @            \  true: 編譯態 False: 執行態  
  IF      
   COMPILE Compiletime_i32.const                
  ELSE    
   runtime_i32.const 
   THEN 
  ; IMMEDIATE 

: runtime_i64.const
  bl word count 
  (NUMBER?)
  if
   \ ." down32 up32 "
  else
  ." it is not Number! "
  then 
  ;

: i64.const  \ comp: ( -<string">- ) run: ( -- down32 up32 )
  STATE @            \  true: 編譯態 False: 執行態  
  IF      
   COMPILE Compiletime_i64.const                 
  ELSE    
   runtime_i64.const 
   THEN 
  ; IMMEDIATE 


i64.const 64 i64.const 32 i64.add d. 96  ok
i32.const 64 i32.const 32 i32.add . 96  ok

燕南

unread,
Apr 17, 2019, 7:45:19 AM4/17/19
to 符式協會
defer i32.add
defer i64.add
' + is i32.add 
' d+ is i64.add

燕南於 2019年4月17日星期三 UTC+8下午7時07分08秒寫道:
Reply all
Reply to author
Forward
0 new messages