Giter Site home page Giter Site logo

dasl's Introduction

It's a Lisp in Python that works as a compiler that spits out DCPU16 assembly. Because I have nothing better to do.

  • This is bad code.
  • This is undocumented code.
  • This is barely tested code.
  • This is slow code.

I might make it better, I might not. Deal with it.

Example:

from dasl import *

def wowser():
  hwq_a, hwq_b, _, _, _ = enable_hwq()
  monitor_id = rvar( 'monitor_id' )
  check_nth = rfunc( 'check_nth' )

  return program( 
    (let, monitor_id, -1),
    
    (defn, check_nth, [ "n", "idh", "idl" ], [],
      (ife, (arg, "n"), (hwn,),
          -1,
          (begin, (hwq, (arg, "n")),
              (ife, hwq_b, (arg, "idl"),
                   (ife, hwq_a, (arg, "idh"),
                        (arg, "n"),
                        (recur, (add, (arg, "n"), 1), (arg, "idh"), (arg, "idl" ))),
                   (recur, (add, (arg, "n"), 1), (arg, "idh"), (arg, "idl")))))),)

print compile( wowser )

Which outputs:

set pc, boot
:_hwq_a dat 0
:_hwq_b dat 0
:_hwq_c dat 0
:_hwq_x dat 0
:_hwq_y dat 0
:_monitor_id dat -1
:boot
set a, a
:hlt set pc, hlt
:_check_nth
set a, [SP+3]
set b, a
hwn a
ife b, a
set pc, __if_then_2572593713
set a, [SP+3]
hwq a
set [_hwq_a], a
set [_hwq_b], b
set [_hwq_c], c
set [_hwq_x], x
set [_hwq_y], y
set a, [SP+1]
ife [_hwq_b], a
set pc, __if_then_968923453
add SP, 4
set a, [SP+65535]
add a, 1
set push, a
set a, [SP+65535]
set push, a
set a, [SP+65535]
set push, a
sub SP, 1
set pc, _check_nth
set pc, __if_end_968923453
:__if_then_968923453
set a, [SP+2]
ife [_hwq_a], a
set pc, __if_then_2394525029
add SP, 4
set a, [SP+65535]
add a, 1
set push, a
set a, [SP+65535]
set push, a
set a, [SP+65535]
set push, a
sub SP, 1
set pc, _check_nth
set pc, __if_end_2394525029
:__if_then_2394525029
set a, [SP+3]
:__if_end_2394525029
:__if_end_968923453
set pc, __if_end_2572593713
:__if_then_2572593713
set a, -1
:__if_end_2572593713
add sp, 0
set z, pop
add sp, 3
set pc, z

dasl's People

Contributors

nulldatamap avatar

Watchers

 avatar

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.