Skip to content

Commit

Permalink
Updated specs for jump position
Browse files Browse the repository at this point in the history
  • Loading branch information
Nafees10 committed Jan 19, 2020
1 parent e30666e commit 032ea02
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spec/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ Pops n number of values from stack
---

## Jumps
* _`Jump [index - integer>=0]`_
Jump execution to instruction at `index`. **Be careful using this, make sure you have used `Pop` to clear stack of unneeded elements**
* _`JumpIf [index - integer>=0]`_
Pops integer from stack. If it is `1`, jumps execution to instruction at `index`. **Be careful using this, make sure you have used `Pop` to clear stack of unneeded elements**
* _`Jump [jump position - string]`_
Jump execution to instruction at `jump position`. **Be careful using this, make sure you have used `Pop` to clear stack of unneeded elements**
* _`JumpIf [jump position - string]`_
Pops integer from stack. If it is `1`, jumps execution to instruction at `jump position`. **Be careful using this, make sure you have used `Pop` to clear stack of unneeded elements**

---

Expand Down
14 changes: 14 additions & 0 deletions spec/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ def 5

One thing to keep in mind is that although instruction names are not case sensitive, keywords are. So don't write `dEf` instead of `def`.

## Jumps
To use a jump instruction (see `spec/instructions.md`), you need a jump position. This is done like:

```
def 5
# some instructions here
someJumpPosition:
# instructions to be repeated
# some instructions that act as a loop condition
jumpIf someJumpPosition
```

In this example, `someJumpPosition` is the jump position. Jump position names are unique only inside the function. Meaning if you have used `someJumpPosition` in a function, you can not name another position that too, but outside that function, it's fine.

## Whitespace
Whitespace can be either tab(s) or spaces, and is ignored, so whitespace is not necessary

0 comments on commit 032ea02

Please sign in to comment.