Giter Club home page Giter Club logo

chip8-script's People

Contributors

pauwell avatar

Watchers

 avatar

chip8-script's Issues

Create built-in functions.

Most important functions:

Chip8Script Opcode Description
cls() 00E0 Clears the screen
draw(w) DXYN draw(Vx,Vy,N) - N is the width
waitKey() FX0A A key press is awaited, and stored in VX (Blocking Operation).
readSprite() FX29 Set I to position of sprite (I=sprite_addr[Vx])

Parsing fails on empty `if`- and `for`-bodies.

if-conditions without any statements in the body messes up the parsing process without showing any errors.

๐Ÿ‘Ž

E.g the following compiler test will fail when doing the token to AST parsing:

c8s::test_compiler(
	" {1} Full set of commands",
		
	"VAR a = 4\n"\
	"IF a == 4:\n"\
	"	VAR b = 8\n"\
	"ENDIF"
);

If conditions without a body lead to parsing fail.

if-conditions without any statements in the body messes up the parsing process without showing any errors.

๐Ÿ‘Ž

The following test fails:

c8s::test_compiler(
        " {1} Full set of commands",
		
	"VAR a = 4\n"\
	"IF a == 4:\n"\
	"        IF a != 4:\n"\
	"        ENDIF\n"\
	"ENDIF"
);

Loop exit condition is only tested for equality

Loop exit-conditions are only tested for equality not greater or less then.
This can result in an infinite loop if e.g: FOR i=5 TO 10 STEP 2 '(i: 5,7,9, 11 ! )

This can be intended behavior..

Missing support for `if` and `for`!

The following is an idea on how to implement if-conditions and for-loops:

Dealing with if-conditions (if a==b ):

if a==2: // 5XY0 Cond if(Vx==Vy) Skips the next instruction if VX equals VY.
NOT TRUE // 1NNN Flow goto 123; Jumps to address NNN.
TRUE // 1NNN Flow goto 345; Jumps to address NNN.
123 NOT_TRUE:
345 TRUE:

Dealing with for-loops (for i=0 TO 10):

Requires:

v[x] = 0
v[y] = i-max(10)

How it works:

  1. [Loop expression]
  2. v[x] += 1; // Inkrementiere V[x]
  3. 5XY0 // V[y] muss i(max) beinhalten
  4. GOTO 1

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.