TIS-100

TIS-100

View Stats:
Proxocasus Jun 1, 2015 @ 11:46pm
How to use labels?
I've not managed to figure this out. I keep getting "UNDEFINED LABEL" even when the boxes are labeled.
< >
Showing 1-5 of 5 comments
Penumbra Jun 2, 2015 @ 12:05am 
Labels only work in the same node (or box), not across nodes. Add your label, followed by a colon at the start of a line, like this

A:
NOP
JMP A

This will do nothing, a lot. If you defined the label "A" in one node, you can't reference it from another. This means you can reuse labels between nodes without conflict. Check out the second example program in section 3 of the manual for a more complex example using labels.
Proxocasus Jun 2, 2015 @ 6:52am 
Ok that doesnt make sense to me. why would i use the label in the same node? This example is bad, but thanks for trying.
MyaMya Jun 2, 2015 @ 7:04am 
Originally posted by Tasley:
Ok that doesnt make sense to me. why would i use the label in the same node? This example is bad, but thanks for trying.
Loops, checks and what not.
also needed to see if number is equal, smaller or larger than 0
Moves values more than or equal to 0 down, else just get new value from up to acc

S: mov up acc
JEZ A
JGZ A
jmp s
a:
Mov acc down
Proxocasus Jun 2, 2015 @ 7:05am 
Thats a bit clearer. Ty Mikaelssen
Penumbra Jun 2, 2015 @ 7:13am 
Look at the last example in section 3. The labels are being used to change where in the code you are "going". Make sure to look at the comments.

The first part of the code is marked as START. It stores a value from the UP port into ACC. The next three lines are jumps to different labels, based on what was just read. It is looking to see if the value read was either greater or less than 0.

The first test goes to POSITIVE. If the value is greater than 0, the current line will change to the code written POSITIVE: and move a value right. If, instead the value were not greater than 0, it would skip the JZL POSITIVE line altogether.

It would then go to the JLZ NEGATIVE line. This will test for ACC being less than 0. Again, this will either jump to the NEGATIVE label, or just skip the jump command altogether and proceed.

In the case that ACC is not less than zero (and, since the only way would could have gotten to the JZL line in the first place was by passing the JGZ line, we know that ACC is 0) the current line will proceed to the JMP START line.

This line is really important, since it stops the code from just running the POSITIVE section on its own. That makes the current line reset back up to the top. This is why the top description says "Zero values are discarded".

I hope that helps.
< >
Showing 1-5 of 5 comments
Per page: 1530 50

Date Posted: Jun 1, 2015 @ 11:46pm
Posts: 5