Define CREATE
This commit is contained in:
41
wipforth.wat
41
wipforth.wat
@@ -1861,6 +1861,47 @@
|
||||
|
||||
;; => 0x40 bytes
|
||||
|
||||
;; : CREATE
|
||||
;; HERE @ \ Get initial address
|
||||
;; LATEST @ OVER ! 4+ \ Write link
|
||||
;; 2DUP C! 1+ \ Write length
|
||||
;; 2DUP WORDBUF SWAP COPY + \ Write name
|
||||
;; ALIGN \ Pad to alignment
|
||||
;;
|
||||
;; HERE @ LATEST ! \ Update LATEST
|
||||
;; HERE ! \ Update HERE
|
||||
;; ;
|
||||
|
||||
(data (i32.const 0x0d0c)
|
||||
"\cc\0c\00\00"
|
||||
"\06CREATE\00"
|
||||
"\00\00\00\00"
|
||||
"\84\05\00\00" ;; HERE
|
||||
"\cc\03\00\00" ;; @
|
||||
"\98\05\00\00" ;; LATEST
|
||||
"\cc\03\00\00" ;; @
|
||||
"\54\02\00\00" ;; OVER
|
||||
"\c0\03\00\00" ;; !
|
||||
"\a8\02\00\00" ;; 4+
|
||||
"\64\02\00\00" ;; 2DUP
|
||||
"\f0\03\00\00" ;; C!
|
||||
"\90\02\00\00" ;; 1+
|
||||
"\64\02\00\00" ;; 2DUP
|
||||
"\ac\05\00\00" ;; WORDBUF
|
||||
"\28\02\00\00" ;; SWAP
|
||||
"\fc\0b\00\00" ;; COPY
|
||||
"\c0\02\00\00" ;; +
|
||||
"\5c\0c\00\00" ;; ALIGN
|
||||
"\84\05\00\00" ;; HERE
|
||||
"\cc\03\00\00" ;; @
|
||||
"\98\05\00\00" ;; LATEST
|
||||
"\c0\03\00\00" ;; !
|
||||
"\84\05\00\00" ;; HERE
|
||||
"\c0\03\00\00" ;; !
|
||||
"\0c\04\00\00") ;; EXIT
|
||||
|
||||
;; => 0x6c bytes
|
||||
|
||||
;; The trampoline is a workaround for WebAssembly's lack of indirect
|
||||
;; jumps and code addresses. Instead of jumping into the next
|
||||
;; codeword, NEXT sets the $fn global to the function index of the
|
||||
|
||||
Reference in New Issue
Block a user