Skip to content

Varvara/Uxn Concatenated Interpretive Uxntal Assembler REPL.

License

Notifications You must be signed in to change notification settings

Ismael-VC/merlin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Merlin CLI REPL Version 0.8

Varavara/Uxn Concatenated Interpretive Uxntal JIT Assembler

Memory is organized as follows:

0000   0100       @heap         @heap-ptr       @syms-ptr      fc00         ffff
|      |          |             ^               ^         @syms|@input         |
v ZPpt v          v             |               |              v   input-ptr   v
+--^---+----------+-------------*---------------*--------------+-------^-------+
| <ZP> | <kernel> | <user code> | <free memory> | <syms table> | <input buff>  |
+--*---+----------+-------------*---------------*--------------+-------*-------+
|==>   |##########|=============>               <==============|=======>
 (256B)                        ( growth direction )                  (1Kb)

Operator Interaction

       Merlin CLI REPL
   █▄  Version 0.8 (06/06/2024).
 ▐ █ ▌ Concatenated Interpretive Uxntal JIT Assembler.
  ▀█   ©MMXXIV Ismael Venegas Castelló, MIT License.
       57865 bytes free (bytecode: 0, symbols: 1331 bytes used).

փ > #2a18 DEO
*
WST 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|<
RST 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|<

փ > @star #2a18 DEO JMP2r

WST 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|<
RST 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|<

փ > star
*
WST 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|<
RST 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|<

փ >

Under the Hood

A parent label starts assembly mode, this will do the following:

  1. Assemble the input buffer and place the code after the current position of @here, and update the @here pointer.
  2. Add an entry to the "dictionary" ("header" format still under design) and update it's pointer.

Note: [ and ] allow multiline input.

փ > @star ( -- ) [
...   [ LIT2 "* -Console/write ] DEO
...   JMP2r
... ]

WST 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|<
RST 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|<

փ > star
*
WST 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|<
RST 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|<

փ >

Doubts:

  • star JSI semantics (but not syntax) will need to be adapted to jump to an absolute address in REPL mode?
  • How to allow multiline input without using [ ]?

@here

The assembled code area will be concatenated as if assembling Uxntal normally.

| @here ( 1337 )
| a0 2a 18 17 6c  ( #2a18 DEO JMP2r )
|
∨ @here ( 133c )

@dict

The dictionary will grow in the contrary direction at a constant size for each entry. Instead of a linked list in tipycal Threaded Interpretive Languages (TILs), concatenating in inverse order to an array. When searching for a routine searching from last entry to first as done by TILs is accomplished by starting the search from the "physical beginning" of the array, where the current @dict pointer points to.

∧ @dict ( ????-n entry bytes )
|
| identifier                           addr
| s  t  a  r  ( pad to n max bytes )   1337
| 73 74 61 72 00 00 00 00 00 00 00 00  13 37
| @dict ( ???? )
| ( primitives )

Reasoning

Concatenating instead of threading the routines allows for the usage of Uxntal and not another Uxntal like language with new or different syntax though some semantics may need to be adapted.

փ > [
...   @<pdec> ( dec* -- )
...     DUP #64 DIV <pnum>/try
...     DUP #0a DIV <pnum>/try
...     ( >> )
...
...   @<pnum> ( num* -- )
...     #0a MOD [ LIT "0 ] ADD .Console/write DEO
...     JMP2r
...
...     &try ( num* -- )
...       DUP ?<pnum>
...       POP JMP2r
... ]

WST 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|<
RST 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|<

փ > #002a <pdec>
42
WST 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|<
RST 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|<

փ >

In this case calling <pdec> would fall through to <pnum> body as in normal Uxntal, something that would not be possible with a tipical threaded implementation.

Drifblim VS drifloon

Zero Page

  • Drifblim uses Console and File, drifloon only Console.
  • loon uses @token $2 while blim uses @token $1 buf $30.

on-init

  • loon uses <assemble> and <read>.
  • blim uses only <assemble> on files.

TODO

  • Return to repl when when evaluating break BRK expression, by pressing Enter 3 times.
  • #foo! should be a Number error (fixed in drifblim).
  • Reset symbols and heap after expression evaluation, just like done with the heap.
  • Clear heap and symbols after error.
  • Reset PC after absolute padding expression?
  • Fix lambdas, not being binary compatible with uxnasm.
  • Reinstate include rune.
  • Make multiline more robust.
  • Use walkcomment and allow nesting.
  • Make <pmem> take the lenght to dump.
  • Make rom smaller (no unused space in between code/data).
  • Make symbols store code length
  • Implement macros.
  • Implement library path.
  • Make debugging toggleable.
  • [], {}, () parse these correctly.
  • Comment out debugging for release.
  • Refactor into something better the file hierarchy.
  • Remove uneeded experiments.

About

Varvara/Uxn Concatenated Interpretive Uxntal Assembler REPL.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages