Giter Site home page Giter Site logo

lunaamora / 4orth Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 0.0 239 KB

4orth is a Porth compiler with WASM, WASI and WASM-4 targets

Home Page: https://lunaamora.github.io/4orth/

License: MIT License

Makefile 100.00%
porth wasm-4 wasm compiler fantasy-console webassembly wasi

4orth's Introduction

Hello, my name is Luna ๐Ÿ‘‹

I'm a game design student and work with programming and game development.

Itch.io Linkedin Portfolio

My main technologies ๐Ÿงก


4orth's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

4orth's Issues

Implement the return stack

Local memories in the current version are implemented as a hack, using wasm locals instead of a return stack. This causes problems when using the pointer to a local mem to do things other than direct read or write.

A proper return stack must be implemented to fix this issue and lay the ground work to #1

Cannot manually import procedures with inline WAT

Context

I am currently building a WASM layer for p5.js and, just for fun, I wanted to add Porth support. However, I am running into an issue with importing one of my functions. Since print is a Porth intrinsic, I could not import a procedure with the same name. So I resorted to this:

wasm
  "(import \"env\" \"print\" (func $print (param i32)))"
end
// -- 88 lines of "import proc <name> <signature> in end"
inline proc print-i32 int -- in
  wasm int -- in
    "(call $pop)"
    "(call $print)"
  end
end

However, I get an error from wasm2wat:

web/examples/colors.wat:127:2: error: imports must occur before all non-import definitions
(import "env" "print" (func $print (param i32))) ;; OP_INJECT_CODE 0
 ^^^^^^

I tried putting the (import "env" ...) before include "wasm-core.porth" and it still gives the same error (just different line numbers). Is there anything I can do or do I have to not include this procedure for now until you (maybe) fix it? (I already had to omit quite a few functions because of floats)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.